public static void Main(string[] args) { SingletonRegistry.Register(AlgorithmOptions.Instance); SingletonRegistry.Register(CollectionSeeder <int> .Instance); var algorithmOptions = SingletonRegistry.Retrieve(nameof(AlgorithmOptions)) as AlgorithmOptions; Console.WriteLine(algorithmOptions.GetAlgorithmOption("BFS_Multiplier")); Console.WriteLine(algorithmOptions.GetAlgorithmOption("NeuralNetwork_Depth")); var collectionSeeder = SingletonRegistry.Retrieve(nameof(CollectionSeeder <int>)) as CollectionSeeder <int>; Console.WriteLine(collectionSeeder.SeedCollection(typeof(List <int>), 3).Count); Console.WriteLine(collectionSeeder.SeedCollection(typeof(HashSet <int>), 5).Count); Console.ReadKey(); }
static void Main(string[] args) { for (int i = 0; i < 10; i++) { SingletonClass.Instance.Show(); } //SingletonRegistry var o1 = SingletonRegistry.GetInstance <Class1>(); var o2 = new Class1(); var o4 = SingletonRegistry.GetInstance <Class2>(); var o3 = SingletonRegistry.GetInstance <Class1>(); Console.WriteLine(object.ReferenceEquals(o1, o2)); Console.WriteLine(object.ReferenceEquals(o1, o3)); Console.WriteLine(object.ReferenceEquals(o3, o4)); Console.ReadLine(); }