• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Config.ConstructorArgumentValues类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例3: Instantiation

		public void Instantiation()
		{
			ConstructorArgumentValues values = new ConstructorArgumentValues();
			Assert.IsNotNull(values.GenericArgumentValues, "The 'GenericArgumentValues' property was not initialised.");
			Assert.IsNotNull(values.IndexedArgumentValues, "The 'IndexedArgumentValues' property was not initialised.");
			Assert.IsNotNull(values.NamedArgumentValues, "The 'NamedArgumentValues' property was not initialised.");
			Assert.AreEqual(0, values.ArgumentCount, "There were some arguments in a newly initialised instance.");
			Assert.IsTrue(values.Empty, "A newly initialised instance was not initially empty.");
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:9,代码来源:ConstructorArgumentValuesTests.cs


示例4: AbstractObjectDefinition

 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Support.AbstractObjectDefinition"/>
 /// class.
 /// </summary>
 /// <remarks>
 /// <p>
 /// This is an <see langword="abstract"/> class, and as such exposes no
 /// public constructors.
 /// </p>
 /// </remarks>
 protected AbstractObjectDefinition(ConstructorArgumentValues arguments, MutablePropertyValues properties)
 {
     constructorArgumentValues =
         (arguments != null) ? arguments : new ConstructorArgumentValues();
     propertyValues =
         (properties != null) ? properties : new MutablePropertyValues();
     eventHandlerValues = new EventValues();
     DependsOn = StringUtils.EmptyStrings;
 }
开发者ID:likesea,项目名称:spring.net,代码行数:20,代码来源:AbstractObjectDefinition.cs


示例5: GetGeneric_Untyped_ArgumentValue

		public void GetGeneric_Untyped_ArgumentValue()
		{
			ConstructorArgumentValues values = new ConstructorArgumentValues();
			const string expectedValue = "Rick";
			values.AddGenericArgumentValue(expectedValue);

			ConstructorArgumentValues.ValueHolder name = values.GetGenericArgumentValue(null, null);
			Assert.IsNotNull(name,
				"Must get non-null valueholder back if no required type is specified.");
			Assert.AreEqual(expectedValue, name.Value);
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:11,代码来源:ConstructorArgumentValuesTests.cs


示例6: getConstructorArgumentValues

 private ConstructorArgumentValues getConstructorArgumentValues(TypeRegistration registrationEntry)
 {
    ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues();
    int index = 0;
    foreach (ParameterValue constructorParameter in registrationEntry.ConstructorParameters)
    {
       constructorArgs.AddIndexedArgumentValue(index++,getInjectionParameterValue(constructorParameter));
    }
    
    return constructorArgs;
 }
开发者ID:ericklombardo,项目名称:Nuaguil.Net,代码行数:11,代码来源:SpringContainerConfigurator.cs


示例7: GetGenericArgumentValueIgnoresAlreadyUsedValues

		public void GetGenericArgumentValueIgnoresAlreadyUsedValues()
		{
			ISet used = new ListSet();

			ConstructorArgumentValues values = new ConstructorArgumentValues();
			values.AddGenericArgumentValue(1);
			values.AddGenericArgumentValue(2);
			values.AddGenericArgumentValue(3);

			Type intType = typeof (int);
			ConstructorArgumentValues.ValueHolder one = values.GetGenericArgumentValue(intType, used);
			Assert.AreEqual(1, one.Value);
			used.Add(one);
			ConstructorArgumentValues.ValueHolder two = values.GetGenericArgumentValue(intType, used);
			Assert.AreEqual(2, two.Value);
			used.Add(two);
			ConstructorArgumentValues.ValueHolder three = values.GetGenericArgumentValue(intType, used);
			Assert.AreEqual(3, three.Value);
			used.Add(three);
			ConstructorArgumentValues.ValueHolder four = values.GetGenericArgumentValue(intType, used);
			Assert.IsNull(four);
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:22,代码来源:ConstructorArgumentValuesTests.cs


示例8: DoubleBooleanAutowire

        public void DoubleBooleanAutowire()
        {
            RootObjectDefinition def = new RootObjectDefinition(typeof(DoubleBooleanConstructorObject));
            ConstructorArgumentValues args = new ConstructorArgumentValues();
            args.AddGenericArgumentValue(true, "bool");
            def.ConstructorArgumentValues = args;
            def.AutowireMode = AutoWiringMode.Constructor;
            def.IsSingleton = true;

            DefaultListableObjectFactory fac = new DefaultListableObjectFactory();
            fac.RegisterObjectDefinition("foo", def);

            fac.GetObject("foo");
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:14,代码来源:DefaultListableObjectFactoryTests.cs


示例9: CreateObjectWithMixOfIndexedAndTwoNamedSameTypeCtorArguments

        public void CreateObjectWithMixOfIndexedAndTwoNamedSameTypeCtorArguments()
        {
            // this object will be passed in as a named constructor argument
            string expectedCompany = "Griffin's Foosball Arcade";
            MutablePropertyValues autoProps = new MutablePropertyValues();
            autoProps.Add(new PropertyValue("Company", expectedCompany));
            RootObjectDefinition autowired = new RootObjectDefinition(typeof(NestedTestObject), autoProps);

            // this object will be passed in as a named constructor argument
            string expectedLawyersCompany = "Pollack, Pounce, & Pulverise";
            MutablePropertyValues lawyerProps = new MutablePropertyValues();
            lawyerProps.Add(new PropertyValue("Company", expectedLawyersCompany));
            RootObjectDefinition lawyer = new RootObjectDefinition(typeof(NestedTestObject), lawyerProps);

            // this simple string object will be passed in as an indexed constructor argument
            string expectedName = "Bingo";

            // this simple integer object will be passed in as a named constructor argument
            int expectedAge = 1023;

            ConstructorArgumentValues values = new ConstructorArgumentValues();

            // lets mix the order up a little...
            values.AddNamedArgumentValue("age", expectedAge);
            values.AddIndexedArgumentValue(0, expectedName);
            values.AddNamedArgumentValue("doctor", new RuntimeObjectReference("a_doctor"));
            values.AddNamedArgumentValue("lawyer", new RuntimeObjectReference("a_lawyer"));

            RootObjectDefinition def = new RootObjectDefinition(typeof(TestObject), values, new MutablePropertyValues());

            DefaultListableObjectFactory fac = new DefaultListableObjectFactory();
            // the object we're attempting to resolve...
            fac.RegisterObjectDefinition("foo", def);
            // the object that will be looked up and passed as a named parameter to a ctor call...
            fac.RegisterObjectDefinition("a_doctor", autowired);
            // another object that will be looked up and passed as a named parameter to a ctor call...
            fac.RegisterObjectDefinition("a_lawyer", lawyer);

            ITestObject foo = fac["foo"] as ITestObject;
            Assert.IsNotNull(foo, "Couldn't pull manually registered instance out of the factory.");
            Assert.AreEqual(expectedName, foo.Name, "Dependency 'name' was not resolved an indexed ctor arg.");
            Assert.AreEqual(expectedAge, foo.Age, "Dependency 'age' was not resolved using a named ctor arg.");
            Assert.AreEqual(expectedCompany, foo.Doctor.Company, "Dependency 'doctor.Company' was not resolved using autowiring.");
            Assert.AreEqual(expectedLawyersCompany, foo.Lawyer.Company, "Dependency 'lawyer.Company' was not resolved using another named ctor arg.");
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:45,代码来源:DefaultListableObjectFactoryTests.cs


示例10: CreateObjectWithMixOfNamedAndIndexedAndAutowiredCtorArguments

        public void CreateObjectWithMixOfNamedAndIndexedAndAutowiredCtorArguments()
        {
            string expectedCompany = "Griffin's Foosball Arcade";
            MutablePropertyValues autoProps = new MutablePropertyValues();
            autoProps.Add(new PropertyValue("Company", expectedCompany));
            RootObjectDefinition autowired = new RootObjectDefinition(typeof(NestedTestObject), autoProps);

            string expectedName = "Bingo";
            int expectedAge = 1023;
            ConstructorArgumentValues values = new ConstructorArgumentValues();
            values.AddNamedArgumentValue("age", expectedAge);
            values.AddIndexedArgumentValue(0, expectedName);
            RootObjectDefinition def = new RootObjectDefinition(typeof(TestObject), values, new MutablePropertyValues());
            def.AutowireMode = AutoWiringMode.Constructor;
            DefaultListableObjectFactory fac = new DefaultListableObjectFactory();
            fac.RegisterObjectDefinition("foo", def);
            fac.RegisterObjectDefinition("doctor", autowired);

            ITestObject foo = fac["foo"] as ITestObject;
            Assert.IsNotNull(foo, "Couldn't pull manually registered instance out of the factory.");
            Assert.AreEqual(expectedName, foo.Name, "Dependency 'name' was not resolved an indexed ctor arg.");
            Assert.AreEqual(expectedAge, foo.Age, "Dependency 'age' was not resolved using a named ctor arg.");
            Assert.AreEqual(expectedCompany, foo.Doctor.Company, "Dependency 'doctor.Company' was not resolved using autowiring.");
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:24,代码来源:DefaultListableObjectFactoryTests.cs


示例11: CreateObjectWithMixOfNamedAndIndexedCtorArguments

        public void CreateObjectWithMixOfNamedAndIndexedCtorArguments()
        {
            string expectedName = "Bingo";
            int expectedAge = 1023;
            ConstructorArgumentValues values = new ConstructorArgumentValues();
            values.AddNamedArgumentValue("age", expectedAge);
            values.AddIndexedArgumentValue(0, expectedName);
            RootObjectDefinition def = new RootObjectDefinition(typeof(TestObject), values, new MutablePropertyValues());
            DefaultListableObjectFactory fac = new DefaultListableObjectFactory();
            fac.RegisterObjectDefinition("foo", def);

            ITestObject foo = fac["foo"] as ITestObject;
            Assert.IsNotNull(foo, "Couldn't pull manually registered instance out of the factory.");
            Assert.AreEqual(expectedName, foo.Name, "Dependency 'name' was not resolved an indexed ctor arg.");
            Assert.AreEqual(expectedAge, foo.Age, "Dependency 'age' was not resolved using a named ctor arg.");
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:16,代码来源:DefaultListableObjectFactoryTests.cs


示例12: ResolveConstructorArguments

        /// <summary>
        /// Resolves the <see cref="Spring.Objects.Factory.Config.ConstructorArgumentValues"/>
        /// of the supplied <paramref name="definition"/>.
        /// </summary>
        /// <param name="objectName">The name of the object that is being resolved by this factory.</param>
        /// <param name="definition">The rod.</param>
        /// <param name="wrapper">The wrapper.</param>
        /// <param name="cargs">The cargs.</param>
        /// <param name="resolvedValues">Where the resolved constructor arguments will be placed.</param>
        /// <returns>
        /// The minimum number of arguments that any constructor for the supplied
        /// <paramref name="definition"/> must have.
        /// </returns>
        /// <remarks>
        /// 	<p>
        /// 'Resolve' can be taken to mean that all of the <paramref name="definition"/>s
        /// constructor arguments is resolved into a concrete object that can be plugged
        /// into one of the <paramref name="definition"/>s constructors. Runtime object
        /// references to other objects in this (or a parent) factory are resolved,
        /// type conversion is performed, etc.
        /// </p>
        /// 	<p>
        /// These resolved values are plugged into the supplied
        /// <paramref name="resolvedValues"/> object, because we wouldn't want to touch
        /// the <paramref name="definition"/>s constructor arguments in case it (or any of
        /// its constructor arguments) is a prototype object definition.
        /// </p>
        /// 	<p>
        /// This method is also used for handling invocations of static factory methods.
        /// </p>
        /// </remarks>
        private int ResolveConstructorArguments(string objectName, RootObjectDefinition definition, ObjectWrapper wrapper,
                                                ConstructorArgumentValues cargs,
                                                ConstructorArgumentValues resolvedValues)
        {
//            ObjectDefinitionValueResolver valueResolver = new ObjectDefinitionValueResolver(objectFactory);
            int minNrOfArgs = cargs.ArgumentCount;

            foreach (KeyValuePair<int, ConstructorArgumentValues.ValueHolder> entry in cargs.IndexedArgumentValues)
            {
                int index = Convert.ToInt32(entry.Key);
                if (index < 0)
                {
                    throw new ObjectCreationException(definition.ResourceDescription, objectName,
                                                      "Invalid constructor agrument index: " + index);
                }
                if (index > minNrOfArgs)
                {
                    minNrOfArgs = index + 1;
                }
                ConstructorArgumentValues.ValueHolder valueHolder = entry.Value;
                string argName = "constructor argument with index " + index;
                object resolvedValue =
                    valueResolver.ResolveValueIfNecessary(objectName, definition, argName, valueHolder.Value);
                resolvedValues.AddIndexedArgumentValue(index, resolvedValue,
                                                       StringUtils.HasText(valueHolder.Type)
                                                           ? TypeResolutionUtils.ResolveType(valueHolder.Type).
                                                                 AssemblyQualifiedName
                                                           : null);
            }

            foreach (ConstructorArgumentValues.ValueHolder valueHolder in definition.ConstructorArgumentValues.GenericArgumentValues)
            {
                string argName = "constructor argument";
                object resolvedValue =
                    valueResolver.ResolveValueIfNecessary(objectName, definition, argName, valueHolder.Value);
                resolvedValues.AddGenericArgumentValue(resolvedValue,
                                                       StringUtils.HasText(valueHolder.Type)
                                                           ? TypeResolutionUtils.ResolveType(valueHolder.Type).
                                                                 AssemblyQualifiedName
                                                           : null);
            }
            foreach (KeyValuePair<string, object> namedArgumentEntry in definition.ConstructorArgumentValues.NamedArgumentValues)
            {
                string argumentName = namedArgumentEntry.Key;
                string syntheticArgumentName = "constructor argument with name " + argumentName;
                ConstructorArgumentValues.ValueHolder valueHolder =
                    (ConstructorArgumentValues.ValueHolder)namedArgumentEntry.Value;
                object resolvedValue =
                    valueResolver.ResolveValueIfNecessary(objectName, definition, syntheticArgumentName, valueHolder.Value);
                resolvedValues.AddNamedArgumentValue(argumentName, resolvedValue);
            }
            return minNrOfArgs;
        }
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:84,代码来源:ConstructorResolver.cs


示例13: GetGeneric_Untyped_ArgumentValueWithOnlyStronglyTypedValuesInTheCtorValueList

		public void GetGeneric_Untyped_ArgumentValueWithOnlyStronglyTypedValuesInTheCtorValueList()
		{
			ConstructorArgumentValues values = new ConstructorArgumentValues();
			const string expectedValue = "Rick";
			values.AddGenericArgumentValue(expectedValue, typeof(string).FullName);

			ConstructorArgumentValues.ValueHolder name = values.GetGenericArgumentValue(null, null);
			Assert.IsNull(name,
				"Must get null valueholder back if no required type is specified but only " +
				"strongly typed values are present in the ctor values list.");
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:11,代码来源:ConstructorArgumentValuesTests.cs


示例14: RootWebObjectDefinition

 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Support.RootObjectDefinition"/> class
 /// for a singleton, providing property values and constructor arguments.
 /// </summary>
 /// <param name="typeName">
 /// The assembly qualified <see cref="System.Type.FullName"/> of the object to instantiate.
 /// </param>
 /// <param name="properties">
 /// The <see cref="Spring.Objects.MutablePropertyValues"/> to be applied to
 /// a new instance of the object.
 /// </param>
 /// <param name="arguments">
 /// The <see cref="Spring.Objects.Factory.Config.ConstructorArgumentValues"/>
 /// to be applied to a new instance of the object.
 /// </param>
 /// <remarks>
 /// <p>
 /// Takes an object class name to avoid eager loading of the object class.
 /// </p>
 /// </remarks>
 public RootWebObjectDefinition(
     string typeName,
     ConstructorArgumentValues arguments,
     MutablePropertyValues properties)
     : base(typeName, arguments, properties)
 {}
开发者ID:spring-projects,项目名称:spring-net,代码行数:27,代码来源:RootWebObjectDefinition.cs


示例15: InstantiateUsingFactoryMethod

        /// <summary>
        /// Instantiate an object instance using a named factory method.
        /// </summary>
        /// <remarks>
        /// <p>
        /// The method may be static, if the <paramref name="definition"/>
        /// parameter specifies a class, rather than a
        /// <see cref="Spring.Objects.Factory.IFactoryObject"/> instance, or an
        /// instance variable on a factory object itself configured using Dependency
        /// Injection.
        /// </p>
        /// <p>
        /// Implementation requires iterating over the static or instance methods
        /// with the name specified in the supplied <paramref name="definition"/>
        /// (the method may be overloaded) and trying to match with the parameters.
        /// We don't have the types attached to constructor args, so trial and error
        /// is the only way to go here.
        /// </p>
        /// </remarks>
        /// <param name="name">
        /// The name associated with the supplied <paramref name="definition"/>.
        /// </param>
        /// <param name="definition">
        /// The definition describing the instance that is to be instantiated.
        /// </param>
        /// <param name="arguments">
        /// Any arguments to the factory method that is to be invoked.
        /// </param>
        /// <returns>
        /// The result of the factory method invocation (the instance).
        /// </returns>
        public virtual IObjectWrapper InstantiateUsingFactoryMethod(string name, RootObjectDefinition definition, object[] arguments)
        {
            ObjectWrapper wrapper = new ObjectWrapper();
            Type factoryClass = null;
            bool isStatic = true;


            ConstructorArgumentValues cargs = definition.ConstructorArgumentValues;
            ConstructorArgumentValues resolvedValues = new ConstructorArgumentValues();
            int expectedArgCount = 0;

            // we don't have arguments passed in programmatically, so we need to resolve the
            // arguments specified in the constructor arguments held in the object definition...
            if (arguments == null || arguments.Length == 0)
            {
                expectedArgCount = cargs.ArgumentCount;
                ResolveConstructorArguments(name, definition, wrapper, cargs, resolvedValues);
            }
            else
            {
                // if we have constructor args, don't need to resolve them...
                expectedArgCount = arguments.Length;
            }


            if (StringUtils.HasText(definition.FactoryObjectName))
            {
                // it's an instance method on the factory object's class...
                factoryClass = objectFactory.GetObject(definition.FactoryObjectName).GetType();
                isStatic = false;
            }
            else
            {
                // it's a static factory method on the object class...
                factoryClass = definition.ObjectType;
            }

            GenericArgumentsHolder genericArgsInfo = new GenericArgumentsHolder(definition.FactoryMethodName);
            IList<MethodInfo> factoryMethodCandidates = FindMethods(genericArgsInfo.GenericMethodName, expectedArgCount, isStatic, factoryClass);

            bool autowiring = (definition.AutowireMode == AutoWiringMode.Constructor);

            // try all matching methods to see if they match the constructor arguments...
            for (int i = 0; i < factoryMethodCandidates.Count; i++)
            {
                MethodInfo factoryMethodCandidate = factoryMethodCandidates[i];
                if (genericArgsInfo.ContainsGenericArguments)
                {
                    string[] unresolvedGenericArgs = genericArgsInfo.GetGenericArguments();
                    if (factoryMethodCandidate.GetGenericArguments().Length != unresolvedGenericArgs.Length)
                        continue;

                    Type[] paramTypes = new Type[unresolvedGenericArgs.Length];
                    for (int j = 0; j < unresolvedGenericArgs.Length; j++)
                    {
                        paramTypes[j] = TypeResolutionUtils.ResolveType(unresolvedGenericArgs[j]);
                    }
                    factoryMethodCandidate = factoryMethodCandidate.MakeGenericMethod(paramTypes);
                }
                if (arguments == null || arguments.Length == 0)
                {
                    Type[] paramTypes = ReflectionUtils.GetParameterTypes(factoryMethodCandidate.GetParameters());
                    // try to create the required arguments...
                    UnsatisfiedDependencyExceptionData unsatisfiedDependencyExceptionData = null;
                    ArgumentsHolder args = CreateArgumentArray(name, definition, resolvedValues, wrapper, paramTypes,
                                                               factoryMethodCandidate, autowiring, out unsatisfiedDependencyExceptionData);
                    if (args == null)
                    {
                        arguments = null;
//.........这里部分代码省略.........
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:101,代码来源:ConstructorResolver.cs


示例16: ParseConstructorArgSubElements

 /// <summary>
 /// Parse constructor argument subelements of the given object element.
 /// </summary>
 protected ConstructorArgumentValues ParseConstructorArgSubElements(
     string name, XmlElement element, ParserContext parserContext)
 {
     ConstructorArgumentValues arguments = new ConstructorArgumentValues();
     foreach (XmlNode node in this.SelectNodes(element, ObjectDefinitionConstants.ConstructorArgElement))
     {
         ParseConstructorArgElement(name, arguments, (XmlElement)node, parserContext);
     }
     return arguments;
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:13,代码来源:ObjectsNamespaceParser.cs


示例17: UsingCustomMarkers

        public void UsingCustomMarkers()
        {
            RootObjectDefinition def = new RootObjectDefinition();
            def.ObjectType = typeof (TestObject);
            ConstructorArgumentValues args = new ConstructorArgumentValues();
            args.AddNamedArgumentValue("name", "#hope.floats#");
            def.ConstructorArgumentValues = args;

            NameValueCollection properties = new NameValueCollection();
            const string expectedName = "Rick";
            properties.Add("hope.floats", 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.PlaceholderPrefix = cfg.PlaceholderSuffix = "#";
            cfg.Properties = properties;
            cfg.PostProcessObjectFactory(mock);

            mocks.VerifyAll();

            Assert.AreEqual(expectedName,
                def.ConstructorArgumentValues.GetNamedArgumentValue("name").Value,
                "Named argument placeholder value was not replaced.");
        }
开发者ID:tobi-tobsen,项目名称:spring-net,代码行数:28,代码来源:PropertyPlaceholderConfigurerTests.cs


示例18: SunnyDay

        public void SunnyDay()
        {
            StaticApplicationContext ac = new StaticApplicationContext();

            MutablePropertyValues pvs = new MutablePropertyValues();
            pvs.Add("age", "${age}");
            RootObjectDefinition def
                = new RootObjectDefinition("${fqn}", new ConstructorArgumentValues(), pvs);
            ac.RegisterObjectDefinition("tb3", def);

            pvs = new MutablePropertyValues();
            pvs.Add("age", "${age}");
            pvs.Add("name", "name${var}${");
            pvs.Add("spouse", new RuntimeObjectReference("${ref}"));
            ac.RegisterSingleton("tb1", typeof (TestObject), pvs);

            ConstructorArgumentValues cas = new ConstructorArgumentValues();
            cas.AddIndexedArgumentValue(1, "${age}");
            cas.AddGenericArgumentValue("${var}name${age}");

            pvs = new MutablePropertyValues();
            ArrayList friends = new ManagedList();
            friends.Add("na${age}me");
            friends.Add(new RuntimeObjectReference("${ref}"));
            pvs.Add("friends", friends);

            ISet someSet = new ManagedSet();
            someSet.Add("na${age}me");
            someSet.Add(new RuntimeObjectReference("${ref}"));
            pvs.Add("someSet", someSet);

            IDictionary someDictionary = new ManagedDictionary();
            someDictionary["key1"] = new RuntimeObjectReference("${ref}");
            someDictionary["key2"] = "${age}name";
            MutablePropertyValues innerPvs = new MutablePropertyValues();
            someDictionary["key3"] = new RootObjectDefinition(typeof (TestObject), innerPvs);
            someDictionary["key4"] = new ChildObjectDefinition("tb1", innerPvs);
            pvs.Add("someMap", someDictionary);

            RootObjectDefinition definition = new RootObjectDefinition(typeof (TestObject), cas, pvs);
            ac.DefaultListableObjectFactory.RegisterObjectDefinition("tb2", definition);

            pvs = new MutablePropertyValues();
            pvs.Add("Properties", "<spring-config><add key=\"age\" value=\"98\"/><add key=\"var\" value=\"${m}var\"/><add key=\"ref\" value=\"tb2\"/><add key=\"m\" value=\"my\"/><add key=\"fqn\" value=\"Spring.Objects.TestObject, Spring.Core.Tests\"/></spring-config>");
            ac.RegisterSingleton("configurer", typeof (PropertyPlaceholderConfigurer), pvs);
            ac.Refresh();

            TestObject tb1 = (TestObject) ac.GetObject("tb1");
            TestObject tb2 = (TestObject) ac.GetObject("tb2");
            TestObject tb3 = (TestObject) ac.GetObject("tb3");
            Assert.AreEqual(98, tb1.Age);
            Assert.AreEqual(98, tb2.Age);
            Assert.AreEqual(98, tb3.Age);
            Assert.AreEqual("namemyvar${", tb1.Name);
            Assert.AreEqual("myvarname98", tb2.Name);
            Assert.AreEqual(tb2, tb1.Spouse);
            Assert.AreEqual(2, tb2.Friends.Count);
            IEnumerator ie = tb2.Friends.GetEnumerator();
            ie.MoveNext();
            Assert.AreEqual("na98me", ie.Current);
            ie.MoveNext();
            Assert.AreEqual(tb2, ie.Current);
            Assert.AreEqual(2, tb2.SomeSet.Count);
            Assert.IsTrue(tb2.SomeSet.Contains("na98me"));
            Assert.IsTrue(tb2.SomeSet.Contains(tb2));
            Assert.AreEqual(4, tb2.SomeMap.Count);
            Assert.AreEqual(tb2, tb2.SomeMap["key1"]);
            Assert.AreEqual("98name", tb2.SomeMap["key2"]);
            TestObject inner1 = (TestObject) tb2.SomeMap["key3"];
            TestObject inner2 = (TestObject) tb2.SomeMap["key4"];
            Assert.AreEqual(0, inner1.Age);
            Assert.AreEqual(null, inner1.Name);
            Assert.AreEqual(98, inner2.Age);
            Assert.AreEqual("namemyvar${", inner2.Name);
        }
开发者ID:tobi-tobsen,项目名称:spring-net,代码行数:75,代码来源:PropertyPlaceholderConfigurerTests.cs


示例19: ConstructorArgumentValues

 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Config.ConstructorArgumentValues"/>
 /// class.
 /// </summary>
 /// <param name="other">
 /// The <see cref="Spring.Objects.Factory.Config.ConstructorArgumentValues"/>
 /// to be used to populate this instance.
 /// </param>
 public ConstructorArgumentValues(ConstructorArgumentValues other)
 {
     AddAll(other);
 }
开发者ID:adamlepkowski,项目名称:spring-net,代码行数:13,代码来源:ConstructorArgumentValues.cs


示例20: AddAll

 /// <summary>
 /// Copy all given argument values into this object.
 /// </summary>
 /// <param name="other">
 /// The <see cref="Spring.Objects.Factory.Config.ConstructorArgumentValues"/>
 /// to be used to populate this instance.
 /// </param>
 public void AddAll(ConstructorArgumentValues other)
 {
     if (other != null)
     {
         foreach (object o in other.GenericArgumentValues)
         {
             GenericArgumentValues.Add(o);
         }
         foreach (DictionaryEntry entry in other.IndexedArgumentValues)
         {
             ValueHolder vh = entry.Value as ValueHolder;
             if (vh != null)
             {
                 AddOrMergeIndexedArgumentValues( (int) entry.Key, vh.Copy());
             }
         }
         foreach (DictionaryEntry entry in other.NamedArgumentValues)
         {
             AddOrMergeNamedArgumentValues(entry.Key, entry.Value);
             //NamedArgumentValues.Add(entry.Key, entry.Value);
         }
     }
 }
开发者ID:adamlepkowski,项目名称:spring-net,代码行数:30,代码来源:ConstructorArgumentValues.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Support.DefaultListableObjectFactory类代码示例发布时间:2022-05-26
下一篇:
C# Objects.TestObject类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap