當前位置: 首頁>>代碼示例>>C#>>正文


C# Support.RootObjectDefinition類代碼示例

本文整理匯總了C#中Spring.Objects.Factory.Support.RootObjectDefinition的典型用法代碼示例。如果您正苦於以下問題:C# RootObjectDefinition類的具體用法?C# RootObjectDefinition怎麽用?C# RootObjectDefinition使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RootObjectDefinition類屬於Spring.Objects.Factory.Support命名空間,在下文中一共展示了RootObjectDefinition類的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: 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

示例3: ParseInternal

        protected override AbstractObjectDefinition ParseInternal(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder = BuildObjectDefinition(element, parserContext);
            ManagedList interceptors = null;
            XmlElement interceptorsElement = DomUtils.GetChildElementByTagName(element, "interceptors");

            if(interceptorsElement != null) {
                ChannelInterceptorParser interceptorParser = new ChannelInterceptorParser();
                interceptors = interceptorParser.ParseInterceptors(interceptorsElement, new ParserContext(parserContext.ParserHelper, builder.RawObjectDefinition));
            }
            if(interceptors == null) {
                interceptors = new ManagedList();
            }

            string datatypeAttr = element.GetAttribute("datatype");
            if(StringUtils.HasText(datatypeAttr)) {
                string[] datatypes = StringUtils.CommaDelimitedListToStringArray(datatypeAttr);
                RootObjectDefinition selectorDef = new RootObjectDefinition();
                selectorDef.ObjectTypeName = IntegrationNamespaceUtils.SELECTOR_PACKAGE + ".PayloadTypeSelector";
                selectorDef.ConstructorArgumentValues.AddGenericArgumentValue(datatypes);
                string selectorObjectName = parserContext.ReaderContext.RegisterWithGeneratedName(selectorDef);

                RootObjectDefinition interceptorDef = new RootObjectDefinition();
                interceptorDef.ObjectTypeName = IntegrationNamespaceUtils.CHANNEL_INTERCEPTOR_PACKAGE + ".MessageSelectingInterceptor";
                interceptorDef.ConstructorArgumentValues.AddGenericArgumentValue(new RuntimeObjectReference(selectorObjectName));
                string interceptorObjectName = parserContext.ReaderContext.RegisterWithGeneratedName(interceptorDef);

                interceptors.Add(new RuntimeObjectReference(interceptorObjectName));
            }

            builder.AddPropertyValue("interceptors", interceptors);
            return builder.ObjectDefinition;
        }
開發者ID:rlxrlxrlx,項目名稱:spring-net-integration,代碼行數:33,代碼來源:AbstractChannelParser.cs

示例4: CanProxyFactoryMethodProducts

        public void CanProxyFactoryMethodProducts()
        {
            GenericApplicationContext ctx = new GenericApplicationContext();
            ctx.ObjectFactory.AddObjectPostProcessor(new DefaultAdvisorAutoProxyCreator());

            CapturingAdvice capturingAdvice = new CapturingAdvice();
            ctx.ObjectFactory.RegisterSingleton("logging", new DefaultPointcutAdvisor(TruePointcut.True, capturingAdvice));

            // register "factory" object 
            RootObjectDefinition rod;
            rod = new RootObjectDefinition(typeof(TestObjectFactoryObject));
            ctx.ObjectFactory.RegisterObjectDefinition("test", rod);

            // register product, referencing the factory object
            rod = new RootObjectDefinition(typeof(ITestObject));
            rod.FactoryObjectName = "test";
            rod.FactoryMethodName = "CreateTestObject";
            ctx.ObjectFactory.RegisterObjectDefinition("testProduct", rod);

            ctx.Refresh();

            ITestObjectFactoryObject fo = (ITestObjectFactoryObject) ctx.GetObject("test");
            Assert.IsTrue( AopUtils.IsAopProxy(fo) );
            Assert.AreEqual("CreateTestObject", ((IMethodInvocation)capturingAdvice.CapturedCalls[0]).Method.Name);

            capturingAdvice.CapturedCalls.Clear();
            ITestObject to = (ITestObject)ctx.GetObject("testProduct");
            Assert.IsTrue( AopUtils.IsAopProxy(to) );
            Assert.AreEqual("TheName", to.Name);
            Assert.AreEqual("get_Name", ((IMethodInvocation)capturingAdvice.CapturedCalls[0]).Method.Name);
        }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:31,代碼來源:DefaultAdvisorAutoProxyCreatorTests.cs

示例5: ChokesOnCircularReferenceToPlaceHolder

        public void ChokesOnCircularReferenceToPlaceHolder()
        {
            RootObjectDefinition def = new RootObjectDefinition();
            def.ObjectType = typeof (TestObject);
            ConstructorArgumentValues args = new ConstructorArgumentValues();
            args.AddNamedArgumentValue("name", "${foo}");
            def.ConstructorArgumentValues = args;

            NameValueCollection properties = new NameValueCollection();
            const string expectedName = "ba${foo}r";
            properties.Add("foo", expectedName);

            IConfigurableListableObjectFactory mock = (IConfigurableListableObjectFactory) mocks.CreateMock(typeof (IConfigurableListableObjectFactory));
            Expect.Call(mock.GetObjectDefinitionNames()).Return(new string[] {"foo"});
            Expect.Call(mock.GetObjectDefinition(null)).IgnoreArguments().Return(def);
            mocks.ReplayAll();

            PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
            cfg.Properties = properties;
            try
            {
                cfg.PostProcessObjectFactory(mock);
                Assert.Fail("Should have raised an ObjectDefinitionStoreException by this point.");
            }
            catch (ObjectDefinitionStoreException)
            {
            }
            mocks.VerifyAll();
        }
開發者ID:tobi-tobsen,項目名稱:spring-net,代碼行數:29,代碼來源:PropertyPlaceholderConfigurerTests.cs

示例6: Setup

        public void Setup()
        {
            _applicationContext = new GenericApplicationContext();

            var objDef = new RootObjectDefinition(typeof (InitDestroyAttributeObjectPostProcessor));
            objDef.Role = ObjectRole.ROLE_INFRASTRUCTURE;
            _applicationContext.ObjectFactory.RegisterObjectDefinition("InitDestroyAttributeObjectPostProcessor", objDef);

            objDef = new RootObjectDefinition(typeof(PostContructTestObject1));
            _applicationContext.ObjectFactory.RegisterObjectDefinition("PostContructTestObject1", objDef);

            objDef = new RootObjectDefinition(typeof(PostContructTestObject2));
            _applicationContext.ObjectFactory.RegisterObjectDefinition("PostContructTestObject2", objDef);
            
            objDef = new RootObjectDefinition(typeof(PostContructTestObject3));
            _applicationContext.ObjectFactory.RegisterObjectDefinition("PostContructTestObject3", objDef);

            objDef = new RootObjectDefinition(typeof(PostContructTestObject4));
            objDef.Scope = "prototype";
            _applicationContext.ObjectFactory.RegisterObjectDefinition("PostContructTestObject4", objDef);

            objDef = new RootObjectDefinition(typeof(PostContructTestObject5));
            _applicationContext.ObjectFactory.RegisterObjectDefinition("PostContructTestObject5", objDef);

            objDef = new RootObjectDefinition(typeof(PostContructTestObject1));
            objDef.InitMethodName = "Init1";
            _applicationContext.ObjectFactory.RegisterObjectDefinition("PostContructTestObject6", objDef);

            _applicationContext.Refresh();
        }
開發者ID:fgq841103,項目名稱:spring-net,代碼行數:30,代碼來源:PostConstructAttributeTests.cs

示例7: InstantiationWithClassName

 public void InstantiationWithClassName()
 {
     RootObjectDefinition def
         = new RootObjectDefinition( typeof( TestObject ).AssemblyQualifiedName, new ConstructorArgumentValues(), new MutablePropertyValues() );
     Assert.IsFalse( def.HasObjectType );
     Assert.IsNull( def.ObjectType ); // must bail...
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:7,代碼來源:RootObjectDefinitionTests.cs

示例8: createTypeSetPropertiesAndInvokeMethod

        public static object createTypeSetPropertiesAndInvokeMethod(Type tTargetType, String sMethodToInvoke,
                                                                    Dictionary<String, Object> dProperties)
        {
            string sFactoryObject = "FactoryObject";
            string sInvokeResult = "InvokeResult";
            var ctx = new GenericApplicationContext();

            // create factory Object,  add (if required) its properties to it and register it
            var rodFactoryObject = new RootObjectDefinition {ObjectType = tTargetType};
            if (dProperties != null)
                foreach (String sProperty in dProperties.Keys)
                    rodFactoryObject.PropertyValues.Add(sProperty, dProperties[sProperty]);

            ctx.RegisterObjectDefinition(sFactoryObject, rodFactoryObject);

            // create object to invoke method and register it

            var rodMethodToInvoke = new RootObjectDefinition
                                        {
                                            FactoryMethodName = sMethodToInvoke,
                                            FactoryObjectName = sFactoryObject
                                        };

            ctx.RegisterObjectDefinition(sInvokeResult, rodMethodToInvoke);

            // when we get the rodMethodToInvoke object, the rodFactoryObject will be created
            return ctx.GetObject(sInvokeResult);
        }
開發者ID:pusp,項目名稱:o2platform,代碼行數:28,代碼來源:SpringExec.cs

示例9: ParseInternal

        /// <summary>
        /// Central template method to actually parse the supplied XmlElement
        /// into one or more IObjectDefinitions.
        /// </summary>
        /// <param name="element">The element that is to be parsed into one or more <see cref="IObjectDefinition"/>s</param>
        /// <param name="parserContext">The the object encapsulating the current state of the parsing process;
        /// provides access to a <see cref="IObjectDefinitionRegistry"/></param>
        /// <returns>
        /// The primary IObjectDefinition resulting from the parsing of the supplied XmlElement
        /// </returns>
        protected override AbstractObjectDefinition ParseInternal(XmlElement element, ParserContext parserContext)
        {
            ConfigureAutoProxyCreator(parserContext, element);
           
            //Create the TransactionAttributeSource
            RootObjectDefinition sourceDef = new RootObjectDefinition(typeof(AttributesTransactionAttributeSource));
            sourceDef.Role = ObjectRole.ROLE_INFRASTRUCTURE;
            string sourceName = parserContext.ReaderContext.RegisterWithGeneratedName(sourceDef);

            //Create the TransactionInterceptor definition.
            RootObjectDefinition interceptorDefinition = new RootObjectDefinition(typeof(TransactionInterceptor));
            interceptorDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE;
            RegisterTransactionManager(element, interceptorDefinition);
            interceptorDefinition.PropertyValues.Add(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, new RuntimeObjectReference(sourceName));
            String interceptorName = parserContext.ReaderContext.RegisterWithGeneratedName(interceptorDefinition);

            // Create the TransactionAttributeSourceAdvisor definition.
            RootObjectDefinition advisorDef = new RootObjectDefinition(typeof(ObjectFactoryTransactionAttributeSourceAdvisor));
            advisorDef.Role = ObjectRole.ROLE_INFRASTRUCTURE;
            advisorDef.PropertyValues.Add("transactionAttributeSource", new RuntimeObjectReference(sourceName));
            advisorDef.PropertyValues.Add("adviceObjectName", interceptorName);
            
            if (element.HasAttribute(ORDER))
            {
                advisorDef.PropertyValues.Add(ORDER, GetAttributeValue(element, ORDER));
            }

            return advisorDef;
        }
開發者ID:Binodesk,項目名稱:spring-net,代碼行數:39,代碼來源:AttributeDrivenObjectDefinitionParser.cs

示例10: RegisterAttributeConfigProcessors

        /// <summary>
        /// Registers the attribute config processors.
        /// </summary>
        /// <param name="registry">The registry.</param>
        public static void RegisterAttributeConfigProcessors(IObjectDefinitionRegistry registry)
        {
            if (!registry.ContainsObjectDefinition(CONFIGURATION_ATTRIBUTE_PROCESSOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(typeof(ConfigurationClassPostProcessor));
                RegisterPostProcessor(registry, objectDefinition, CONFIGURATION_ATTRIBUTE_PROCESSOR_OBJECT_NAME);
            }

            if (!registry.ContainsObjectDefinition(AUTOWIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(typeof(AutowiredAttributeObjectPostProcessor));
                RegisterPostProcessor(registry, objectDefinition, AUTOWIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME);
            }

            if (!registry.ContainsObjectDefinition(REQUIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(typeof(RequiredAttributeObjectPostProcessor));
                RegisterPostProcessor(registry, objectDefinition, REQUIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME);
            }

            if (!registry.ContainsObjectDefinition(INITDESTROY_ATTRIBUTE_PROCESSOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(typeof(InitDestroyAttributeObjectPostProcessor));
                RegisterPostProcessor(registry, objectDefinition, INITDESTROY_ATTRIBUTE_PROCESSOR_OBJECT_NAME);
            }
        }
開發者ID:spring-projects,項目名稱:spring-net-codeconfig,代碼行數:30,代碼來源:AttributeConfigUtils.cs

示例11: 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

示例12: VisitPropertyValues

        public void VisitPropertyValues()
        {
            IObjectDefinition od = new RootObjectDefinition();
            od.PropertyValues.Add("PropertyName", "$Property");

            ObjectDefinitionVisitor odv = new ObjectDefinitionVisitor(new ObjectDefinitionVisitor.ResolveHandler(ParseAndResolveVariables));
            odv.VisitObjectDefinition(od);

            Assert.AreEqual("Value", od.PropertyValues.GetPropertyValue("PropertyName").Value);
        }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:10,代碼來源:ObjectDefinitionVisitorTests.cs

示例13: VisitObjectTypeName

        public void VisitObjectTypeName()
        {
            IObjectDefinition od = new RootObjectDefinition();
            od.ObjectTypeName = "$Property";

            ObjectDefinitionVisitor odv = new ObjectDefinitionVisitor(new ObjectDefinitionVisitor.ResolveHandler(ParseAndResolveVariables));
            odv.VisitObjectDefinition(od);

            Assert.AreEqual("Value", od.ObjectTypeName);
        }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:10,代碼來源:ObjectDefinitionVisitorTests.cs

示例14: RegisterAutoProxyCreatorIfNecessary

        /// <summary>
        /// Registers the internal auto proxy creator if necessary.
        /// </summary>
        public static void RegisterAutoProxyCreatorIfNecessary(IObjectDefinitionRegistry registry)
        {
            AssertUtils.ArgumentNotNull(registry, "registry");

            if (!registry.ContainsObjectDefinition(AUTO_PROXY_CREATOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(InfrastructureAutoProxyCreatorType);
                objectDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE;
                objectDefinition.PropertyValues.Add("order", int.MaxValue);
                registry.RegisterObjectDefinition(AUTO_PROXY_CREATOR_OBJECT_NAME, objectDefinition);
            }
        }
開發者ID:hazzik,項目名稱:nh-contrib-everything,代碼行數:15,代碼來源:AopNamespaceUtils.cs

示例15: RegisterAttributeConfigProcessors

        /// <summary>
        /// Registers the attribute config processors.
        /// </summary>
        /// <param name="registry">The registry.</param>
        public static void RegisterAttributeConfigProcessors(IObjectDefinitionRegistry registry)
        {
            if (!registry.ContainsObjectDefinition(CONFIGURATION_ATTRIBUTE_PROCESSOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(typeof(ConfigurationClassPostProcessor));
                RegisterPostProcessor(registry, objectDefinition, CONFIGURATION_ATTRIBUTE_PROCESSOR_OBJECT_NAME);
            }

            //AUTOWIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME

            //REQUIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME
        }
開發者ID:thenapoleon,項目名稱:spring-net-codeconfig,代碼行數:16,代碼來源:AttributeConfigUtils.cs


注:本文中的Spring.Objects.Factory.Support.RootObjectDefinition類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。