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


C# Builder.BuildUp方法代码示例

本文整理汇总了C#中Builder.BuildUp方法的典型用法代码示例。如果您正苦于以下问题:C# Builder.BuildUp方法的具体用法?C# Builder.BuildUp怎么用?C# Builder.BuildUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Builder的用法示例。


在下文中一共展示了Builder.BuildUp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanCreateInstances

		public void CanCreateInstances()
		{
			string config =
				@"<object-builder-config xmlns=""pag-object-builder"">
               <build-rules>
						<build-rule type=""" + FullNameSimpleObject + @""" mode=""Instance"">
							<constructor-params>
								<value-param type=""System.Int32"">12</value-param>
							</constructor-params>
						</build-rule>
					</build-rules>
				</object-builder-config>";

			Builder builder = new Builder(ObjectBuilderXmlConfig.FromXml(config));
			Locator locator = CreateLocator();

			SimpleObject m1 = builder.BuildUp<SimpleObject>(locator, null, null);
			SimpleObject m2 = builder.BuildUp<SimpleObject>(locator, null, null);

			Assert.IsNotNull(m1);
			Assert.IsNotNull(m2);
			Assert.AreEqual(12, m1.IntParam);
			Assert.AreEqual(12, m2.IntParam);
			Assert.IsTrue(m1 != m2);
		}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:25,代码来源:BuilderConfigTests.cs

示例2: TestBuildUp

 public void TestBuildUp()
 {
     var builder = new Builder<Car>();
     var car = builder.BuildUp();
     Assert.IsNotNull(car);
     Assert.AreEqual<int>(2 + 1, car.Log.Count);
     Assert.AreEqual<string>(car.Log[2],"wheel");
 }
开发者ID:thornfieldhe,项目名称:TAF,代码行数:8,代码来源:BuildTest.cs

示例3: EmptyBuilderWillCreateAnyValueTypeWithDefaultValue

		public void EmptyBuilderWillCreateAnyValueTypeWithDefaultValue()
		{
			Builder builder = new Builder();
			Locator locator = CreateLocator();

			int actual = builder.BuildUp<int>(locator, null, null);
			Assert.AreEqual(default(int), actual);
		}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:8,代码来源:BuilderFixture.cs

示例4: EmptyBuilderWillCreateSimpleInstances

		public void EmptyBuilderWillCreateSimpleInstances()
		{
			Builder builder = new Builder();
			Locator locator = CreateLocator();

			SimpleObject o = builder.BuildUp<SimpleObject>(locator, null, null);

			Assert.IsNotNull(o);
			Assert.AreEqual(0, o.IntParam);
		}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:10,代码来源:BuilderFixture.cs

示例5: EmptyBuilderWillCreateComplexInstances

		public void EmptyBuilderWillCreateComplexInstances()
		{
			Builder builder = new Builder();
			Locator locator = CreateLocator();

			ComplexObject o = builder.BuildUp<ComplexObject>(locator, null, null);

			Assert.IsNotNull(o);
			Assert.IsNotNull(o.SimpleObject);
			Assert.AreEqual(default(int), o.SimpleObject.IntParam);
		}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:11,代码来源:BuilderFixture.cs

示例6: BuilderWithNoStrategiesThrowsWhenBuilding

        public void BuilderWithNoStrategiesThrowsWhenBuilding()
        {
            string config =
                @"<object-builder-config xmlns=""pag-object-builder"">
                    <strategies include-default=""false"" />
                </object-builder-config>";

            Builder builder = new Builder(ObjectBuilderXmlConfig.FromXml(config));
            Locator locator = CreateLocator();

            builder.BuildUp<object>(locator, null, null);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:12,代码来源:BuilderConfigTests.cs

示例7: BuilderCanTakeTransientPolicies

        public void BuilderCanTakeTransientPolicies()
        {
            Builder builder = new Builder();
            Locator locator = CreateLocator();
            PolicyList policies = new PolicyList();

            PropertySetterPolicy policy = new PropertySetterPolicy();
            policy.Properties.Add("IntProp", new PropertySetterInfo("IntProp", new ValueParameter<int>(96)));
            policies.Set<IPropertySetterPolicy>(policy, typeof(PropertyObject), null);

            PropertyObject obj = builder.BuildUp<PropertyObject>(locator, null, null, policies);

            Assert.AreEqual(96, obj.IntProp);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:14,代码来源:BuilderFixture.cs

示例8: CanAddPoliciesToBuilder

        public void CanAddPoliciesToBuilder()
        {
            Builder builder = new Builder();
            Locator locator = CreateLocator();

            ConstructorPolicy policy = new ConstructorPolicy();
            policy.AddParameter(new ValueParameter<int>(12));
            builder.Policies.Set<ICreationPolicy>(policy, typeof(MockObject), null);

            MockObject obj = builder.BuildUp<MockObject>(locator, null, null);

            Assert.IsNotNull(obj);
            Assert.AreEqual(12, obj.IntValue);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:14,代码来源:BuilderFixture.cs

示例9: CanCreateInterceptedObjectInOBChain

        public void CanCreateInterceptedObjectInOBChain()
        {
			Builder builder = new Builder();

			InterceptableClass instance
				= (InterceptableClass)builder.BuildUp(null,
													   null,
													   CreatePolicyList(GetInjectionSettings(), true),
													   baseStrategyChain.MakeStrategyChain(),
													   NamedTypeBuildKey.Make<InterceptableClass>(string.Empty),
													   null);

            Assert.IsNotNull(instance);
            Assert.IsTrue(RemotingServices.IsTransparentProxy(instance));
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:15,代码来源:ObjectBuilderIntegrationFixture.cs

示例10: RegularInstanceIsReturnedWhenInterceptionIsSwitchedOf

        public void RegularInstanceIsReturnedWhenInterceptionIsSwitchedOf()
        {
			Builder builder = new Builder();

			InterceptableClass instance
				= (InterceptableClass)builder.BuildUp(null,
													   null,
													   CreatePolicyList(new PolicyInjectionSettings(), true),
													   baseStrategyChain.MakeStrategyChain(),
													   NamedTypeBuildKey.Make<InterceptableClass>(string.Empty),
													   null);

            Assert.IsNotNull(instance);
            Assert.IsFalse(RemotingServices.IsTransparentProxy(instance));
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:15,代码来源:ObjectBuilderIntegrationFixture.cs

示例11: CanCreateConcreteObjectByAskingForInterface

        public void CanCreateConcreteObjectByAskingForInterface()
        {
            string config =
                @"<object-builder-config xmlns=""pag-object-builder"">
               <build-rules>
                        <build-rule type=""" + FullNameISimpleObject + @""" mode=""Instance"">
                            <mapped-type type=""" + FullNameSimpleObject + @""" />
                        </build-rule>
                    </build-rules>
                </object-builder-config>";

            Builder builder = new Builder(ObjectBuilderXmlConfig.FromXml(config));
            Locator locator = CreateLocator();

            ISimpleObject sm = builder.BuildUp<ISimpleObject>(locator, null, null);

            Assert.IsNotNull(sm);
            Assert.IsTrue(sm is SimpleObject);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:19,代码来源:BuilderConfigTests.cs

示例12: CanInjectMultiplePropertiesIncludingCreatedObjects

        public void CanInjectMultiplePropertiesIncludingCreatedObjects()
        {
            string config =
                @"<object-builder-config xmlns=""pag-object-builder"">
               <build-rules>
                        <build-rule type=""" + FullNameSimpleObject + @""" mode=""Instance"">
                            <constructor-params>
                                <value-param type=""System.Int32"">15</value-param>
                            </constructor-params>
                        </build-rule>
                        <build-rule type=""" + FullNameComplexObject + @""" mode=""Instance"">
                            <property name=""StringProperty"">
                                <value-param type=""System.String"">Bar is here</value-param>
                            </property>
                            <property name=""SimpleObject"">
                                <ref-param type=""" + FullNameSimpleObject + @""" />
                            </property>
                        </build-rule>
                    </build-rules>
                </object-builder-config>";

            Builder builder = new Builder(ObjectBuilderXmlConfig.FromXml(config));
            Locator locator = CreateLocator();

            ComplexObject co = builder.BuildUp<ComplexObject>(locator, null, null);

            Assert.IsNotNull(co);
            Assert.IsNotNull(co.SimpleObject);
            Assert.AreEqual("Bar is here", co.StringProperty);
            Assert.AreEqual(15, co.SimpleObject.IntParam);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:31,代码来源:BuilderConfigTests.cs

示例13: TransientPoliciesOverrideBuilderPolicies

        public void TransientPoliciesOverrideBuilderPolicies()
        {
            Builder builder = new Builder();
            Locator locator = CreateLocator();
            PolicyList policies = new PolicyList();

            PropertySetterPolicy builderPolicy = new PropertySetterPolicy();
            builderPolicy.Properties.Add("IntProp", new PropertySetterInfo("IntProp", new ValueParameter<int>(11)));
            builder.Policies.Set<IPropertySetterPolicy>(builderPolicy, typeof(PropertyObject), null);

            PropertySetterPolicy transientPolicy = new PropertySetterPolicy();
            transientPolicy.Properties.Add("IntProp", new PropertySetterInfo("IntProp", new ValueParameter<int>(22)));
            policies.Set<IPropertySetterPolicy>(transientPolicy, typeof(PropertyObject), null);

            PropertyObject obj = builder.BuildUp<PropertyObject>(locator, null, null, policies);

            Assert.AreEqual(22, obj.IntProp);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:18,代码来源:BuilderFixture.cs

示例14: SingletonPolicyBasedOnConcreteTypeRatherThanRequestedType

        public void SingletonPolicyBasedOnConcreteTypeRatherThanRequestedType()
        {
            Builder builder = new Builder();
            Locator locator = CreateLocator();
            builder.Policies.Set<ITypeMappingPolicy>(new TypeMappingPolicy(typeof(Foo), null), typeof(IFoo), null);
            builder.Policies.SetDefault<ISingletonPolicy>(new SingletonPolicy(true));

            object obj1 = builder.BuildUp(locator, typeof(IFoo), null, null);
            object obj2 = builder.BuildUp(locator, typeof(IFoo), null, null);

            Assert.AreSame(obj1, obj2);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:12,代码来源:BuilderFixture.cs

示例15: CanMapTypesWithDefaultObjectBuilder

        public void CanMapTypesWithDefaultObjectBuilder()
        {
            Builder builder = new Builder();
            Locator locator = CreateLocator();

            TypeMappingPolicy policy = new TypeMappingPolicy(typeof(MockObject), null);
            builder.Policies.Set<ITypeMappingPolicy>(policy, typeof(IMockObject), null);

            IMockObject obj = builder.BuildUp<IMockObject>(locator, null, null);

            Assert.IsTrue(obj is MockObject);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:12,代码来源:BuilderFixture.cs


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