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


C# RootObjectDefinition.OverrideFrom方法代碼示例

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


在下文中一共展示了RootObjectDefinition.OverrideFrom方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OverrideFromOther

        public void OverrideFromOther()
        {
            RootObjectDefinition rod = new RootObjectDefinition( typeof( TestObject ), AutoWiringMode.Constructor );
            rod.IsSingleton = false;
            rod.InitMethodName = "Umberto Eco";
            rod.DestroyMethodName = "Pedulismus";
            rod.ConstructorArgumentValues = new ConstructorArgumentValues();
            rod.ConstructorArgumentValues.AddGenericArgumentValue( "Wulf", "Sternhammer" );
            rod.DependencyCheck = DependencyCheckingMode.Objects;
            rod.DependsOn = new string[] { "Jimmy", "Joyce" };
            rod.IsAbstract = true;
            rod.IsLazyInit = true;
            rod.FactoryMethodName = "IfINeedYouIllJustUseYourSimpleName";
            rod.FactoryObjectName = "PerspirationShop";
            rod.ResourceDescription = "Ohhh";
            rod.PropertyValues = new MutablePropertyValues();
            rod.PropertyValues.Add( "Age", 100 );
            rod.EventHandlerValues = new EventValues();
            InstanceEventHandlerValue handler = new InstanceEventHandlerValue( new TestObject(), "Ping" );
            handler.EventName = "Bing";
            rod.EventHandlerValues.AddHandler( handler );

            ChildObjectDefinition cod = new ChildObjectDefinition( "parent" );
            cod.ObjectTypeName = "ChildObjectTypeName";
            cod.IsSingleton = true;
            cod.AutowireMode = AutoWiringMode.ByType;
            cod.InitMethodName = "InitChild";
            cod.DestroyMethodName = "DestroyChild";
            cod.ConstructorArgumentValues = new ConstructorArgumentValues();
            cod.ConstructorArgumentValues.AddNamedArgumentValue( "ctorarg", "ctorarg-value" );
            cod.DependencyCheck = DependencyCheckingMode.None;
            cod.DependsOn = new string[] { "Aleks", "Mark" };
            cod.IsAbstract = false;
            cod.IsLazyInit = false;
            cod.FactoryMethodName = "ChildFactoryMethodName";
            cod.FactoryObjectName = "ChildFactoryObjectName";
            cod.ResourceDescription = "ChildResourceDescription";
            cod.PropertyValues = new MutablePropertyValues();
            cod.PropertyValues.Add( "Prop1", "Val1" );
            cod.PropertyValues.Add( "Age", 50 );
            cod.EventHandlerValues = new EventValues();
            handler = new InstanceEventHandlerValue( new TestObject(), "Pong" );
            handler.EventName = "Bong";
            cod.EventHandlerValues.AddHandler( handler );

            rod.OverrideFrom( cod );

            // ...
            Assert.AreEqual( "ChildObjectTypeName", rod.ObjectTypeName );
            Assert.AreEqual( AutoWiringMode.ByType, rod.AutowireMode );
            Assert.AreEqual( true, rod.IsSingleton );
            Assert.AreEqual( "InitChild", rod.InitMethodName );
            Assert.AreEqual( "DestroyChild", rod.DestroyMethodName );
            Assert.AreEqual( DependencyCheckingMode.None, rod.DependencyCheck );
            Assert.AreEqual( 4, rod.DependsOn.Count);
            Assert.AreEqual( false, rod.IsAbstract );
            Assert.AreEqual( false, rod.IsLazyInit );
            Assert.AreEqual( "ChildFactoryMethodName", rod.FactoryMethodName );
            Assert.AreEqual( "ChildFactoryObjectName", rod.FactoryObjectName );
            Assert.AreEqual( "ChildResourceDescription", rod.ResourceDescription );
            Assert.AreEqual( 2, rod.ConstructorArgumentValues.ArgumentCount );
            Assert.AreEqual( 2, rod.PropertyValues.PropertyValues.Count );
            Assert.AreEqual( "Val1", rod.PropertyValues.GetPropertyValue("Prop1").Value);
            Assert.AreEqual( 50, rod.PropertyValues.GetPropertyValue("Age").Value);
            Assert.AreEqual( 2, rod.EventHandlerValues.Events.Count );
        }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:66,代碼來源:RootObjectDefinitionTests.cs


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