Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Assets/MRTK/Core/Services/BaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public abstract class BaseService : IMixedRealityService, IMixedRealityServiceSt
{
public const uint DefaultPriority = 10;

public BaseService()
{
typeName = new[] { GetType().ToString() };
}

#region IMixedRealityService Implementation

/// <inheritdoc />
Expand Down Expand Up @@ -68,12 +73,18 @@ public virtual void Destroy()

private bool? isInitialized = null;

private readonly string[] typeName = null;

private const string IsInitializedAssert = "{0} has not set a value for IsInitialized; returning false.";
private const string IsEnabledAssert = "{0} has not set a value for IsEnabled; returning false.";
private const string IsMarkedDestroyedAssert = "{0} has not set a value for IsMarkedDestroyed; returning false.";

/// <inheritdoc />
public virtual bool IsInitialized
{
get
{
Debug.Assert(isInitialized.HasValue, $"{GetType()} has not set a value for IsInitialized, returning false.");
Debug.AssertFormat(isInitialized.HasValue, IsInitializedAssert, typeName);
return isInitialized ?? false;
}

Expand All @@ -87,7 +98,7 @@ public virtual bool IsEnabled
{
get
{
Debug.Assert(isEnabled.HasValue, $"{GetType()} has not set a value for IsEnabled, returning false.");
Debug.AssertFormat(isEnabled.HasValue, IsEnabledAssert, typeName);
return isEnabled ?? false;
}

Expand All @@ -101,7 +112,7 @@ public virtual bool IsMarkedDestroyed
{
get
{
Debug.Assert(isMarkedDestroyed.HasValue, $"{GetType()} has not set a value for IsMarkedDestroyed, returning false.");
Debug.AssertFormat(isMarkedDestroyed.HasValue, IsMarkedDestroyedAssert, typeName);
return isMarkedDestroyed ?? false;
}

Expand Down