Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates an instances.
 /// </summary>
 /// <returns></returns>
 public static RevitContext CreateInstance()
 {
     return(SingletonFactory <RevitContext> .CreateInstance());
 }
Exemplo n.º 4
0
 public MainClass()
 {
     this.Singleton = SingletonFactory.CreateInstance();
 }
Exemplo n.º 5
0
        /// <summary>
        ///     Creates an instances.
        /// </summary>
        /// <param name="version"></param>
        /// <returns></returns>
        public static RevitContext CreateInstance(int version)
        {
            _version = version.ToString();

            return(SingletonFactory <RevitContext> .CreateInstance());
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Creates an instances.
        /// </summary>
        /// <param name="version"></param>
        /// <returns></returns>
        public static RevitContext CreateInstance(string version)
        {
            _version = version;

            return(SingletonFactory <RevitContext> .CreateInstance());
        }
Exemplo n.º 7
0
        /// <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());
        }