当前位置: 首页>>代码示例>>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;未经允许,请勿转载。