当前位置: 首页>>代码示例>>C#>>正文


C# Support.DefaultListableObjectFactory类代码示例

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


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


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