Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerCarrol committed Jun 2, 2024
1 parent eee9b2b commit c61c9a0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion TJC.Singleton.Tests/Helpers/MocSingletonFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class MocSingletonFactory
public static List<T> GetInstances<T>(Func<T> getSingleton, int amount)
{
var singletons = new List<T>();
var threads = new List<Thread>();
var threads = new List<Thread>();

for (var i = 0; i < amount; i++)
threads.Add(new Thread(() => singletons.Add(getSingleton())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

internal class MockSingletonPrivateConstructorWithParameters : SingletonBaseClass<MockSingletonPrivateConstructorWithParameters>, IIdentifier
{
#pragma warning disable IDE0051
private MockSingletonPrivateConstructorWithParameters(Guid? id = null)
#pragma warning restore IDE0051
{
Id = id ?? Guid.NewGuid();
}

public Guid Id { get; }
}
4 changes: 1 addition & 3 deletions TJC.Singleton.Tests/Mocks/Valid/MockSingletonInstantiated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

internal class MockSingletonInstantiated : SingletonBaseClass<MockSingletonInstantiated>, IIdentifier
{
private MockSingletonInstantiated() {}//=> IsInstantiated = true;
private MockSingletonInstantiated() { }

public Guid Id { get; } = Guid.NewGuid();

//public static bool IsInstantiated { get; private set; }
}
4 changes: 2 additions & 2 deletions TJC.Singleton/Factories/SingletonFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ private class PlaceholderSingleton : SingletonBaseClass<PlaceholderSingleton>;

#endregion

public static void InstantiatedAll(bool trace = true,
public static void InstantiatedAll(bool trace = true,
bool throwIfFailed = false)
{
var failedToInstantiate = new List<string>();
var singletons = GetSingletonTypes();
var singletons = GetSingletonTypes();

if (trace)
Trace.WriteLine($"{singletons.Count} Singletons Found");
Expand Down
4 changes: 2 additions & 2 deletions TJC.Singleton/Helpers/SingletonIdentifierHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
public static class SingletonIdentifierHelpers
{
public static bool IsConcreteSingleton(Type type)
{
{
// Ensure type is a concrete class
if (!type.IsClass || type.IsAbstract)
return false;

// Ensure type derives from singleton
var openGenericType = typeof(SingletonBaseClass<>);

var baseType = type.BaseType;
while (baseType != null)
{
Expand Down
2 changes: 1 addition & 1 deletion TJC.Singleton/SingletonBaseClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private static TDerivedClass CreateInstance()
{
// Use reflection to create an instance of the derived class.
var ctor = SingletonConstructorHelpers.GetSingletonConstructor<TDerivedClass>();
return (TDerivedClass)ctor.Invoke(null) ??
return (TDerivedClass)ctor.Invoke(null) ??
throw new SingletonInitializationException($"[{typeof(TDerivedClass)}] singleton failed to initialize");
}

Expand Down

0 comments on commit c61c9a0

Please sign in to comment.