Skip to content

Commit

Permalink
Merge pull request #25 from techno-dwarf-works/feature/refactoring
Browse files Browse the repository at this point in the history
Rollback ServiceProperty
  • Loading branch information
uurha committed May 29, 2024
1 parent ba21bfa commit 0d724a2
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 402 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions Runtime/Properties/ServiceProperty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#if BETTER_SERVICES
using Better.Services.Runtime.Interfaces;

namespace Better.Locators.Runtime
{
public sealed class ServiceProperty<T> where T : IService
{
private T _cachedService;

public T CachedService
{
get
{
if (_cachedService == null)
{
_cachedService = ServiceLocator.Get<T>();
}

return _cachedService;
}
}

public bool IsRegistered => ServiceLocator.HasRegistered<T>();
}
}
#endif
3 changes: 3 additions & 0 deletions Runtime/Properties/ServiceProperty.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions Samples~/TestSamples/Scripts/TestGetService.cs

This file was deleted.

3 changes: 0 additions & 3 deletions Samples~/TestSamples/Scripts/TestGetService.cs.meta

This file was deleted.

Loading

0 comments on commit 0d724a2

Please sign in to comment.