• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Support.DefaultListableObjectFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Spring.Objects.Factory.Support.DefaultListableObjectFactory的典型用法代码示例。如果您正苦于以下问题:C# DefaultListableObjectFactory类的具体用法?C# DefaultListableObjectFactory怎么用?C# DefaultListableObjectFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DefaultListableObjectFactory类属于Spring.Objects.Factory.Support命名空间,在下文中一共展示了DefaultListableObjectFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: InitFactory

        private void InitFactory(DefaultListableObjectFactory factory)
        {
            Console.WriteLine("init factory");
            RootObjectDefinition tee = new RootObjectDefinition(typeof(Tee), true);
            tee.IsLazyInit = true;
            ConstructorArgumentValues teeValues = new ConstructorArgumentValues();
            teeValues.AddGenericArgumentValue("test");
            tee.ConstructorArgumentValues = teeValues;

            RootObjectDefinition bar = new RootObjectDefinition(typeof(BBar), false);
            ConstructorArgumentValues barValues = new ConstructorArgumentValues();
            barValues.AddGenericArgumentValue(new RuntimeObjectReference("tee"));
            barValues.AddGenericArgumentValue(5);
            bar.ConstructorArgumentValues = barValues;

            RootObjectDefinition foo = new RootObjectDefinition(typeof(FFoo), false);
            MutablePropertyValues fooValues = new MutablePropertyValues();
            fooValues.Add("i", 5);
            fooValues.Add("bar", new RuntimeObjectReference("bar"));
            fooValues.Add("copy", new RuntimeObjectReference("bar"));
            fooValues.Add("s", "test");
            foo.PropertyValues = fooValues;

            factory.RegisterObjectDefinition("foo", foo);
            factory.RegisterObjectDefinition("bar", bar);
            factory.RegisterObjectDefinition("tee", tee);
        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:27,代码来源:DefaultListableObjectFactoryPerfTests.cs


示例2: DoesNotAcceptInfrastructureAdvisorsDuringScanning

        public void DoesNotAcceptInfrastructureAdvisorsDuringScanning()
        {
            DefaultListableObjectFactory of = new DefaultListableObjectFactory();

            GenericObjectDefinition infrastructureAdvisorDefinition = new GenericObjectDefinition();
            infrastructureAdvisorDefinition.ObjectType = typeof (TestAdvisor);
            infrastructureAdvisorDefinition.PropertyValues.Add("Name", "InfrastructureAdvisor");
            infrastructureAdvisorDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE;
            of.RegisterObjectDefinition("infrastructure", infrastructureAdvisorDefinition);

            GenericObjectDefinition regularAdvisorDefinition = new GenericObjectDefinition();
            regularAdvisorDefinition.ObjectType = typeof (TestAdvisor);
            regularAdvisorDefinition.PropertyValues.Add("Name", "RegularAdvisor");
            //            regularAdvisorDefinition.Role = ObjectRole.ROLE_APPLICATION;
            of.RegisterObjectDefinition("regular", regularAdvisorDefinition);

            TestAdvisorAutoProxyCreator apc = new TestAdvisorAutoProxyCreator();
            apc.ObjectFactory = of;
            object[] advisors = apc.GetAdvicesAndAdvisorsForObject(typeof (object), "dummyTarget");
            Assert.AreEqual(1, advisors.Length);
            Assert.AreEqual( "RegularAdvisor", ((TestAdvisor)advisors[0]).Name );

            Assert.AreEqual(1, apc.CheckedAdvisors.Count);
            Assert.AreEqual("regular", apc.CheckedAdvisors[0]);
        }
开发者ID:adamlepkowski,项目名称:spring-net,代码行数:25,代码来源:AbstractAdvisorAutoProxyCreatorTests.cs


示例3: ClearWithDynamicProxies

        public void ClearWithDynamicProxies()
        {
            CompositionProxyTypeBuilder typeBuilder = new CompositionProxyTypeBuilder();
            typeBuilder.TargetType = typeof(TestObject);
            Type proxyType = typeBuilder.BuildProxyType();

            DefaultListableObjectFactory of = new DefaultListableObjectFactory();
            RootObjectDefinition od1 = new RootObjectDefinition(proxyType, false);
            od1.PropertyValues.Add("Name", "Bruno");
            of.RegisterObjectDefinition("testObject", od1);

            GenericApplicationContext ctx1 = new GenericApplicationContext(of);
            ContextRegistry.RegisterContext(ctx1);

            ITestObject to1 = ContextRegistry.GetContext().GetObject("testObject") as ITestObject;
            Assert.IsNotNull(to1);
            Assert.AreEqual("Bruno", to1.Name);

            DefaultListableObjectFactory of2 = new DefaultListableObjectFactory();
            RootObjectDefinition od2 = new RootObjectDefinition(proxyType, false);
            od2.PropertyValues.Add("Name", "Baia");
            of2.RegisterObjectDefinition("testObject", od2);
            GenericApplicationContext ctx2 = new GenericApplicationContext(of2);

            ContextRegistry.Clear();

            ITestObject to2 = ctx2.GetObject("testObject") as ITestObject;
            Assert.IsNotNull(to2);
            Assert.AreEqual("Baia", to2.Name);
        }
开发者ID:serra,项目名称:spring-net,代码行数:30,代码来源:ContextRegistryTests.cs


示例4: LoadConfiguration

        /// <summary>
        /// Load all registered configuration into spring. This method should only be called internally by the FluentApplicationContext, i.e. you shouldn't call it.
        /// </summary>
        /// <param name="objectFactory">The object factory.</param>
        public static void LoadConfiguration(DefaultListableObjectFactory objectFactory)
        {
            // This check is mainly for backward compability and avoid people trying to register their configuration twice.
            if (!_configurationRegistry.ContainsConfiguration())
            {
                if (_assembliesList.Count == 0)
                {
                    _assembliesList.Add(() => AppDomain.CurrentDomain.GetAssemblies());
                }

                IList<Type> applicationContextConfigurerTypes = new List<Type>();
                // only load the configuration once (in case the assembly was registered twice)
                foreach (Type type in from assemblies in _assembliesList
                                      from assembly in assemblies()
                                      from type in assembly.GetTypes()
                                      where type.GetInterfaces().Contains(typeof (ICanConfigureApplicationContext))
                                      where !applicationContextConfigurerTypes.Contains(type)
                                      select type)
                {
                    applicationContextConfigurerTypes.Add(type);
                }
                // load each class containing configuration.
                foreach (ICanConfigureApplicationContext contextConfigurer in
                    applicationContextConfigurerTypes.Select(applicationContextConfigurerType => (ICanConfigureApplicationContext) Activator.CreateInstance(applicationContextConfigurerType)))
                {
                    contextConfigurer.Configure();
                }
            }

            _configurationRegistry.LoadObjectDefinitions(objectFactory);
        }
开发者ID:thenapoleon,项目名称:Fluent-API-for-Spring.Net,代码行数:35,代码来源:FluentStaticConfiguration.cs


示例5: SetUp

        protected void SetUp()
        {
            parent = new DefaultListableObjectFactory();
            IDictionary<string, object> m = new Dictionary<string, object>();
            m["name"] = "Albert";
            parent.RegisterObjectDefinition("father", new RootObjectDefinition(typeof(TestObject), new MutablePropertyValues(m)));
            m = new Dictionary<string, object>();
            m["name"] = "Roderick";
            parent.RegisterObjectDefinition("rod", new RootObjectDefinition(typeof(TestObject), new MutablePropertyValues(m)));

            // for testing dynamic ctor arguments + parent.GetObject() call propagation 
            parent.RegisterObjectDefinition("namedfather", new RootObjectDefinition(typeof(TestObject), false));
            parent.RegisterObjectDefinition("typedfather", new RootObjectDefinition(typeof(TestObject), false));

            // add unsupported IObjectDefinition implementation...
            //UnsupportedObjectDefinitionImplementation unsupportedDefinition = new UnsupportedObjectDefinitionImplementation();
            //parent.RegisterObjectDefinition("unsupportedDefinition", unsupportedDefinition);

            XmlObjectFactory factory;
            factory = new XmlObjectFactory(new ReadOnlyXmlTestResource("test.xml", GetType()), parent);

            // TODO: should this be allowed?
            //this.factory.RegisterObjectDefinition("typedfather", new RootObjectDefinition(typeof(object), false));
            factory.AddObjectPostProcessor(new AnonymousClassObjectPostProcessor());
            factory.AddObjectPostProcessor(new LifecycleObject.PostProcessor());

            factory.PreInstantiateSingletons();
            base.ObjectFactory = factory;
        }
开发者ID:spring-projects,项目名称:spring-net,代码行数:29,代码来源:XmlListableObjectFactoryTests.cs


示例6: Find

            private static NamedObjectDefinition Find( string url, string objectName )
            {
                DefaultListableObjectFactory of = new DefaultListableObjectFactory();
                RootObjectDefinition rod = new RootObjectDefinition( typeof( Type1 ) );
                of.RegisterObjectDefinition( objectName, rod );

                return FindWebObjectDefinition( url, of );
            }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:8,代码来源:AbstractHandlerFactoryTests.cs


示例7: Can_Create_Custom_Scan_Routine

 public void Can_Create_Custom_Scan_Routine()
 {
     var scanner = new ScanOverridingAssemblyObjectDefinitionScanner();
     var registry = new DefaultListableObjectFactory();
     scanner.ScanAndRegisterTypes(registry);
     Assert.That(registry.ObjectDefinitionCount, Is.EqualTo(1), "found multiple definitions");
     Assert.That(registry.GetObject<ComponentScan.ScanComponentsAndAddToContext.ConfigurationImpl>(), Is.Not.Null,
                 "correct single defintion was not registered");
 }
开发者ID:spring-projects,项目名称:spring-net-codeconfig,代码行数:9,代码来源:AssemblyObjectDefinitionScannerTests.cs


示例8: LoadObjectDefinitions

 protected override void LoadObjectDefinitions(DefaultListableObjectFactory objectFactory)
 {
     //wrap the objectFactory with our own proxy so that we keep track of the objects ids defined in the Spring.NET context
     callbacks.Add(new BeanohObjectFactoryMethodInterceptor(objectFactory));
     ProxyGenerator generator = new ProxyGenerator();
     DefaultListableObjectFactory wrapper = (DefaultListableObjectFactory)generator.CreateClassProxy(objectFactory.GetType(), callbacks.ToArray());
     //delegate to our proxy
     base.LoadObjectDefinitions(wrapper);
 }
开发者ID:mattcvincent,项目名称:beanoh.NET,代码行数:9,代码来源:BeanohApplicationContext.cs


示例9: CanCreateHostTwice

        public void CanCreateHostTwice()
        {
            DefaultListableObjectFactory of = new DefaultListableObjectFactory();

            string svcRegisteredName = System.Guid.NewGuid().ToString();

            of.RegisterObjectDefinition(svcRegisteredName, new RootObjectDefinition(new RootObjectDefinition(typeof(Service))));
            SpringServiceHost ssh = new SpringServiceHost(svcRegisteredName, of, true);
            SpringServiceHost ssh1 = new SpringServiceHost(svcRegisteredName, of, true);
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:10,代码来源:SpringServiceHostTests.cs


示例10: StaticEventWiring

 public virtual void StaticEventWiring()
 {
     DefaultListableObjectFactory factory = new DefaultListableObjectFactory();
     XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(factory);
     reader.LoadObjectDefinitions(new ReadOnlyXmlTestResource("event-wiring.xml", GetType()));
     TestEventHandler staticHandler = factory["staticEventListener"] as TestEventHandler;
     // raise the event... handlers should be notified at this point (obviously)
     TestObject.OnStaticClick();
     Assert.IsTrue(staticHandler.EventWasHandled,
                   "The instance handler did not get notified when the static event was raised (and was probably not wired up in the first place).");
 }
开发者ID:fgq841103,项目名称:spring-net,代码行数:11,代码来源:EventWiringTests.cs


示例11: AddPersistenceExceptionTranslation

        protected override void AddPersistenceExceptionTranslation(ProxyFactory pf, IPersistenceExceptionTranslator pet)
        {
            if (AttributeUtils.FindAttribute(pf.TargetType, typeof(RepositoryAttribute)) != null)
            {
                DefaultListableObjectFactory of = new DefaultListableObjectFactory();
                of.RegisterObjectDefinition("peti", new RootObjectDefinition(typeof(PersistenceExceptionTranslationInterceptor)));
                of.RegisterSingleton("pet", pet);
                pf.AddAdvice((PersistenceExceptionTranslationInterceptor) of.GetObject("peti"));

            }
        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:11,代码来源:PersistenceExceptionTranslationInterceptorTests.cs


示例12: BailsIfTargetNotFound

 public void BailsIfTargetNotFound()
 {
     using (DefaultListableObjectFactory of = new DefaultListableObjectFactory())
     {
         SaoExporter saoExporter = new SaoExporter();
         saoExporter.ObjectFactory = of;
         saoExporter.TargetName = "DOESNOTEXIST";
         saoExporter.ServiceName = "RemotedSaoSingletonCounter";
         saoExporter.AfterPropertiesSet();
     }
 }
开发者ID:Binodesk,项目名称:spring-net,代码行数:11,代码来源:SaoExporterTests.cs


示例13: EventWiringInstanceSinkToPrototypeSource

 public virtual void EventWiringInstanceSinkToPrototypeSource()
 {
     DefaultListableObjectFactory factory = new DefaultListableObjectFactory();
     XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(factory);
     reader.LoadObjectDefinitions(new ReadOnlyXmlTestResource("event-wiring-prototypes.xml", GetType()));
     TestEventHandler instanceHandler = factory["instanceSink"] as TestEventHandler;
     ITestObject source = factory["source"] as ITestObject;
     // raise the event... handlers should be notified at this point (obviously)
     source.OnClick();
     Assert.IsTrue(instanceHandler.EventWasHandled,
                   "The instance handler did not get notified when the instance event was raised (and was probably not wired up in the first place).");
 }
开发者ID:fgq841103,项目名称:spring-net,代码行数:12,代码来源:EventWiringTests.cs


示例14: ProxyObjectWithoutInterface

        public void ProxyObjectWithoutInterface()
        {
            DefaultListableObjectFactory of = new DefaultListableObjectFactory();
            of.RegisterObjectDefinition("bar", new RootObjectDefinition(typeof(ObjectWithoutInterface)));

            TestAutoProxyCreator apc = new TestAutoProxyCreator(of);
            of.AddObjectPostProcessor(apc);

            ObjectWithoutInterface o = of.GetObject("bar") as ObjectWithoutInterface;
            Assert.IsTrue(AopUtils.IsAopProxy(o));
            o.Foo();
            Assert.AreEqual(1, apc.NopInterceptor.Count);
        }
开发者ID:smnbss,项目名称:spring-net,代码行数:13,代码来源:AbstractAutoProxyCreatorTests.cs


示例15: SetUp

		public void SetUp()
		{
			_singletonDefinition = new RootObjectDefinition(typeof (TestObject), AutoWiringMode.No);
			_singletonDefinitionWithFactory = new RootObjectDefinition(_singletonDefinition);
			_singletonDefinitionWithFactory.FactoryMethodName = "GetObject";
			_singletonDefinitionWithFactory.FactoryObjectName = "TestObjectFactoryDefinition";
			_testObjectFactory = new RootObjectDefinition(typeof (TestObjectFactory), AutoWiringMode.No);
			DefaultListableObjectFactory myFactory = new DefaultListableObjectFactory();
			myFactory.RegisterObjectDefinition("SingletonObjectDefinition", SingletonDefinition);
			myFactory.RegisterObjectDefinition("SingletonDefinitionWithFactory", SingletonDefinitionWithFactory);
			myFactory.RegisterObjectDefinition("TestObjectFactoryDefinition", TestObjectFactoryDefinition);
			_factory = myFactory;
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:13,代码来源:SimpleInstantiationStrategyTests.cs


示例16: ConvertsWriteConcernCorrectly

        public void ConvertsWriteConcernCorrectly()
        {
            DefaultListableObjectFactory factory = new DefaultListableObjectFactory();
            factory.RegisterCustomConverter(typeof(WriteConcern), new WriteConcernTypeConverter());

            RootObjectDefinition definition = new RootObjectDefinition(typeof(MongoFactoryObject));
            definition.PropertyValues.Add("Url", "mongodb://localhost");
            definition.PropertyValues.Add("WriteConcern", "Acknowledged");
            factory.RegisterObjectDefinition("factory", definition);

            MongoFactoryObject obj = factory.GetObject<MongoFactoryObject>("&factory");
            Assert.That(ReflectionUtils.GetInstanceFieldValue(obj, "_writeConcern"),
                        Is.EqualTo(WriteConcern.Acknowledged));
        }
开发者ID:thomast74,项目名称:spring-net-data-mongodb,代码行数:14,代码来源:MongoFactoryObjectTests.cs


示例17: ExportSingleton

        public void ExportSingleton()
        {
            using (DefaultListableObjectFactory of = new DefaultListableObjectFactory())
            {
                of.RegisterSingleton("simpleCounter", new SimpleCounter());
                SaoExporter saoExporter = new SaoExporter();
                saoExporter.ObjectFactory = of;
                saoExporter.TargetName = "simpleCounter";
                saoExporter.ServiceName = "RemotedSaoSingletonCounter";
                saoExporter.AfterPropertiesSet();
                of.RegisterSingleton("simpleCounterExporter", saoExporter); // also tests SaoExporter.Dispose()!

                AssertExportedService(saoExporter.ServiceName, 2);
            }
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:15,代码来源:SaoExporterTests.cs


示例18: Test

        public void Test()
        {
            int numIterations = 10000;
            start = DateTime.Now;
            DefaultListableObjectFactory factory = new DefaultListableObjectFactory();
            InitFactory(factory);
            for (int i = 0; i < numIterations; i++)
            {
              FFoo foo = (FFoo)factory.GetObject("foo");
            }
            stop = DateTime.Now;
            double timeElapsed = Elapsed;
            PrintTest("Creations", numIterations, timeElapsed);


        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:16,代码来源:DefaultListableObjectFactoryPerfTests.cs


示例19: ShouldAllowConfigurationClassInheritance

        public void ShouldAllowConfigurationClassInheritance()
        {
            var factory = new DefaultListableObjectFactory();
            factory.RegisterObjectDefinition("DerivedConfiguration", new GenericObjectDefinition
                                                                         {
                                                                             ObjectType = typeof(DerivedConfiguration)
                                                                         });

            var processor = new ConfigurationClassPostProcessor();

            processor.PostProcessObjectFactory(factory);

            // we should get singleton instances only
            TestObject testObject = (TestObject) factory.GetObject("DerivedDefinition");
            string singletonParent = (string) factory.GetObject("BaseDefinition");

            Assert.That(testObject.Value, Is.SameAs(singletonParent));
        }
开发者ID:spring-projects,项目名称:spring-net-codeconfig,代码行数:18,代码来源:ConfigurationClassPostProcessorTests.cs


示例20: SunnyDayReplaceMethod

		public void SunnyDayReplaceMethod()
		{
			RootObjectDefinition replacerDef = new RootObjectDefinition(typeof (NewsFeedFactory));

			RootObjectDefinition managerDef = new RootObjectDefinition(typeof (ReturnsNullNewsFeedManager));
			managerDef.MethodOverrides.Add(new ReplacedMethodOverride("CreateNewsFeed", "replacer"));

			DefaultListableObjectFactory factory = new DefaultListableObjectFactory();
			factory.RegisterObjectDefinition("manager", managerDef);
			factory.RegisterObjectDefinition("replacer", replacerDef);
			INewsFeedManager manager = (INewsFeedManager) factory["manager"];
			NewsFeed feed1 = manager.CreateNewsFeed();
			Assert.IsNotNull(feed1, "The CreateNewsFeed() method is not being replaced.");
			Assert.AreEqual(NewsFeedFactory.DefaultName, feed1.Name);
			NewsFeed feed2 = manager.CreateNewsFeed();
			// NewsFeedFactory always yields a new NewsFeed (see class definition below)...
			Assert.IsFalse(ReferenceEquals(feed1, feed2));
		}
开发者ID:Binodesk,项目名称:spring-net,代码行数:18,代码来源:MethodReplacerTests.cs



注:本文中的Spring.Objects.Factory.Support.DefaultListableObjectFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Support.RootObjectDefinition类代码示例发布时间:2022-05-26
下一篇:
C# Config.ConstructorArgumentValues类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap