コード例 #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);
        }
コード例 #2
0
ファイル: FactoryTests.cs プロジェクト: slieser/LinFu
        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);
        }
コード例 #3
0
 /// <summary>
 /// Creates an instances.
 /// </summary>
 /// <returns></returns>
 public static RevitContext CreateInstance()
 {
     return(SingletonFactory <RevitContext> .CreateInstance());
 }
コード例 #4
0
 public MainClass()
 {
     this.Singleton = SingletonFactory.CreateInstance();
 }
コード例 #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());
        }
コード例 #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());
        }
コード例 #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());
        }