public void SingletonFactoryShouldCreateTheSameInstanceOnce() { var factory = new SingletonFactory <ISerializable>(createInstance); var container = new ServiceContainer(); var request = new FactoryRequest { ServiceName = null, Arguments = new object[0], Container = container, ServiceType = typeof(ISerializable) }; ISerializable first = factory.CreateInstance(request); ISerializable second = factory.CreateInstance(request); // Both instances must be the same Assert.AreSame(first, second); Assert.IsNotNull(first); Assert.IsNotNull(second); }
public void SingletonFactoryShouldCreateTheSameInstanceOnce() { var factory = new SingletonFactory<ISerializable>(createInstance); var container = new ServiceContainer(); var request = new FactoryRequest() { ServiceName = null, Arguments = new object[0], Container = container, ServiceType = typeof(ISerializable) }; ISerializable first = factory.CreateInstance(request); ISerializable second = factory.CreateInstance(request); // Both instances must be the same Assert.AreSame(first, second); Assert.IsNotNull(first); Assert.IsNotNull(second); }
/// <summary> /// Creates an instances. /// </summary> /// <returns></returns> public static RevitContext CreateInstance() { return(SingletonFactory <RevitContext> .CreateInstance()); }
public MainClass() { this.Singleton = SingletonFactory.CreateInstance(); }
/// <summary> /// Creates an instances. /// </summary> /// <param name="version"></param> /// <returns></returns> public static RevitContext CreateInstance(int version) { _version = version.ToString(); return(SingletonFactory <RevitContext> .CreateInstance()); }
/// <summary> /// Creates an instances. /// </summary> /// <param name="version"></param> /// <returns></returns> public static RevitContext CreateInstance(string version) { _version = version; return(SingletonFactory <RevitContext> .CreateInstance()); }
/// <summary> /// Creates an instances. /// </summary> /// <param name="version"></param> /// <returns></returns> public static RevitContext CreateInstance(RevitVersion version) { _version = version.ToString().Replace("Revit", string.Empty); return(SingletonFactory <RevitContext> .CreateInstance()); }