private ObjectDefinitionHolder ParseTestObjectDefinition(XmlElement rootElement, ParserContext parserContext)
        {
            MutablePropertyValues properties = new MutablePropertyValues();
            
            XmlNodeList childNodes = rootElement.ChildNodes;

            //Get all properties (from non whitespace nodes)
            foreach (XmlNode childNode in childNodes)
            {                
                if (XmlNodeType.Whitespace != childNode.NodeType)
                {
                    properties.Add(new PropertyValue(childNode.LocalName, childNode.InnerText));
                }
            }
            IConfigurableObjectDefinition od = new RootObjectDefinition(typeof (TestObject), null, properties);
            od.IsSingleton = false;

            //HardCoded for now.
            string id = "testObject";
            //id = ObjectDefinitionReaderUtils.GenerateObjectName(od, reader.ObjectReader.Registry);

            return new ObjectDefinitionHolder(od, id);


        }
 public void Instantiation () {
     MutablePropertyValues root = new MutablePropertyValues ();
     root.Add (new PropertyValue ("Name", "Fiona Apple"));
     root.Add (new PropertyValue ("Age", 24));
     MutablePropertyValues props = new MutablePropertyValues (root);
     Assert.AreEqual (2, props.PropertyValues.Count);
 }
 public void AddAllInNullMap()
 {
     MutablePropertyValues props = new MutablePropertyValues ();
     props.Add (new PropertyValue ("Name", "Fiona Apple"));
     props.AddAll ((IDictionary) null);
     Assert.AreEqual (1, props.PropertyValues.Length);
 }
 public void InstantiationWithNulls () 
 {
     MutablePropertyValues props = new MutablePropertyValues ((IDictionary<string, object>) null);
     Assert.AreEqual (0, props.PropertyValues.Count);
     MutablePropertyValues props2 = new MutablePropertyValues ((IPropertyValues) null);
     Assert.AreEqual (0, props2.PropertyValues.Count);
 }
        public void ChangesSince()
        {
            IDictionary <string, object> map = new Dictionary <string, object>();
            PropertyValue propName           = new PropertyValue("Name", "Fiona Apple");

            map.Add(propName.Name, propName.Value);
            map.Add("Age", 24);
            MutablePropertyValues props    = new MutablePropertyValues(map);
            MutablePropertyValues newProps = new MutablePropertyValues(map);

            // change the name... this is the change we'll be looking for
            newProps.SetPropertyValueAt(new PropertyValue(propName.Name, "Naomi Woolf"), 0);
            IPropertyValues changes = newProps.ChangesSince(props);

            Assert.AreEqual(1, changes.PropertyValues.Count);
            // the name was changed, so its the name property that should be in the changed list
            Assert.IsTrue(changes.Contains("name"));

            newProps.Add(new PropertyValue("Commentator", "Naomi Woolf"));
            changes = newProps.ChangesSince(props);
            Assert.AreEqual(2, changes.PropertyValues.Count);
            // the Commentator was added, so its the Commentator property that should be in the changed list
            Assert.IsTrue(changes.Contains("commentator"));
            // the name was changed, so its the name property that should be in the changed list
            Assert.IsTrue(changes.Contains("name"));
        }
        /// <summary>
        /// Return the difference (changes, additions, but not removals) of
        /// property values between the supplied argument and the values
        /// contained in the collection.
        /// </summary>
        /// <param name="old">Another property values collection.</param>
        /// <returns>
        /// The collection of property values that are different than the supplied one.
        /// </returns>
        public IPropertyValues ChangesSince(IPropertyValues old)
        {
            MutablePropertyValues changes = new MutablePropertyValues();

            if (old == this)
            {
                return(changes);
            }
            // for each property value in this (the newer set)
            foreach (PropertyValue newProperty in propertyValuesList)
            {
                PropertyValue oldProperty = old.GetPropertyValue(newProperty.Name);
                if (oldProperty == null)
                {
                    // if there wasn't an old one, add it
                    changes.Add(newProperty);
                }
                else if (!oldProperty.Equals(newProperty))
                {
                    // it's changed
                    changes.Add(newProperty);
                }
            }
            return(changes);
        }
 /// <summary> 
 /// Create the job instance, populating it with property values taken
 /// from the scheduler context, job data map and trigger data map.
 /// </summary>
 protected override object CreateJobInstance(TriggerFiredBundle bundle)
 {
     ObjectWrapper ow = new ObjectWrapper(bundle.JobDetail.JobType);
     if (IsEligibleForPropertyPopulation(ow.WrappedInstance))
     {
         MutablePropertyValues pvs = new MutablePropertyValues();
         if (schedulerContext != null)
         {
             pvs.AddAll(schedulerContext);
         }
         pvs.AddAll(bundle.JobDetail.JobDataMap);
         pvs.AddAll(bundle.Trigger.JobDataMap);
         if (ignoredUnknownProperties != null)
         {
             for (int i = 0; i < ignoredUnknownProperties.Length; i++)
             {
                 string propName = ignoredUnknownProperties[i];
                 if (pvs.Contains(propName))
                 {
                     pvs.Remove(propName);
                 }
             }
             ow.SetPropertyValues(pvs);
         }
         else
         {
             ow.SetPropertyValues(pvs, true);
         }
     }
     return ow.WrappedInstance;
 }
 public void AddAllInNullList()
 {
     MutablePropertyValues props = new MutablePropertyValues ();
     props.Add (new PropertyValue ("Name", "Fiona Apple"));
     props.Add (new PropertyValue ("Age", 24));
     props.AddAll ((IList) null);
     Assert.AreEqual (2, props.PropertyValues.Length);
 }
 public void AddAllInList()
 {
     MutablePropertyValues props = new MutablePropertyValues ();
     props.AddAll (new PropertyValue [] {
         new PropertyValue ("Name", "Fiona Apple"),
         new PropertyValue ("Age", 24)});
     Assert.AreEqual (2, props.PropertyValues.Length);
 }
        public void AddAllInNullMap()
        {
            MutablePropertyValues props = new MutablePropertyValues();

            props.Add(new PropertyValue("Name", "Fiona Apple"));
            props.AddAll((IDictionary)null);
            Assert.AreEqual(1, props.PropertyValues.Length);
        }
        public void AddAllInNullMap()
        {
            MutablePropertyValues props = new MutablePropertyValues();

            props.Add(new PropertyValue("Name", "Fiona Apple"));
            props.AddAll((IDictionary <string, object>)null);
            Assert.AreEqual(1, props.PropertyValues.Count);
        }
        public void InstantiationWithNulls()
        {
            MutablePropertyValues props = new MutablePropertyValues((IDictionary <string, object>)null);

            Assert.AreEqual(0, props.PropertyValues.Count);
            MutablePropertyValues props2 = new MutablePropertyValues((IPropertyValues)null);

            Assert.AreEqual(0, props2.PropertyValues.Count);
        }
 public void AddAllInMap()
 {
     MutablePropertyValues props = new MutablePropertyValues ();
     IDictionary map = new Hashtable ();
     map.Add ("Name", "Fiona Apple");
     map.Add ("Age", 24);
     props.AddAll (map);
     Assert.AreEqual (2, props.PropertyValues.Length);
 }
        public void Contains()
        {
            MutablePropertyValues props = new MutablePropertyValues();

            props.Add(new PropertyValue("Name", "Fiona Apple"));
            props.Add(new PropertyValue("Age", 24));
            // must be case insensitive to be CLS compliant...
            Assert.IsTrue(props.Contains("nAmE"));
        }
        public void AddAllInNullList()
        {
            MutablePropertyValues props = new MutablePropertyValues();

            props.Add(new PropertyValue("Name", "Fiona Apple"));
            props.Add(new PropertyValue("Age", 24));
            props.AddAll((IList <PropertyValue>)null);
            Assert.AreEqual(2, props.PropertyValues.Count);
        }
        public void InstantiationWithNulls()
        {
            MutablePropertyValues props = new MutablePropertyValues((IDictionary)null);

            Assert.AreEqual(0, props.PropertyValues.Length);
            MutablePropertyValues props2 = new MutablePropertyValues((IPropertyValues)null);

            Assert.AreEqual(0, props2.PropertyValues.Length);
        }
        public void AddAllInMap()
        {
            MutablePropertyValues        props = new MutablePropertyValues();
            IDictionary <string, object> map   = new Dictionary <string, object>();

            map.Add("Name", "Fiona Apple");
            map.Add("Age", 24);
            props.AddAll(map);
            Assert.AreEqual(2, props.PropertyValues.Count);
        }
        public void RemoveByName()
        {
            MutablePropertyValues props = new MutablePropertyValues();

            props.Add(new PropertyValue("Name", "Fiona Apple"));
            props.Add(new PropertyValue("Age", 24));
            Assert.AreEqual(2, props.PropertyValues.Count);
            props.Remove("name");
            Assert.AreEqual(1, props.PropertyValues.Count);
        }
        public void AddAllInMap()
        {
            MutablePropertyValues props = new MutablePropertyValues();
            IDictionary           map   = new Hashtable();

            map.Add("Name", "Fiona Apple");
            map.Add("Age", 24);
            props.AddAll(map);
            Assert.AreEqual(2, props.PropertyValues.Length);
        }
        public void Instantiation()
        {
            MutablePropertyValues root = new MutablePropertyValues();

            root.Add(new PropertyValue("Name", "Fiona Apple"));
            root.Add(new PropertyValue("Age", 24));
            MutablePropertyValues props = new MutablePropertyValues(root);

            Assert.AreEqual(2, props.PropertyValues.Count);
        }
        public void AddAllInList()
        {
            MutablePropertyValues props = new MutablePropertyValues();

            props.AddAll(new PropertyValue [] {
                new PropertyValue("Name", "Fiona Apple"),
                new PropertyValue("Age", 24)
            });
            Assert.AreEqual(2, props.PropertyValues.Count);
        }
      private MutablePropertyValues getMutablePropertyValues(TypeRegistration registrationEntry)
      {
         MutablePropertyValues properties = new MutablePropertyValues();
         foreach (InjectedProperty property in registrationEntry.InjectedProperties)
         {
            properties.Add(new PropertyValue(property.PropertyName,getInjectionParameterValue(property.PropertyValue)));
         }

         return properties;
      }
        public void RemoveByPropertyValue()
        {
            MutablePropertyValues props    = new MutablePropertyValues();
            PropertyValue         propName = new PropertyValue("Name", "Fiona Apple");

            props.Add(propName);
            props.Add(new PropertyValue("Age", 24));
            Assert.AreEqual(2, props.PropertyValues.Length);
            props.Remove(propName);
            Assert.AreEqual(1, props.PropertyValues.Length);
        }
        public void ChangesSinceWithSelf()
        {
            IDictionary <string, object> map = new Dictionary <string, object>();

            map.Add("Name", "Fiona Apple");
            map.Add("Age", 24);
            MutablePropertyValues props = new MutablePropertyValues(map);

            props.Remove("name");
            // get all of the changes between self and self again (there should be none);
            IPropertyValues changes = props.ChangesSince(props);

            Assert.AreEqual(0, changes.PropertyValues.Count);
        }
Beispiel #25
0
		/// <summary> 
		/// This implementation applies the passed-in job data map as object property
		/// values, and delegates to <code>ExecuteInternal</code> afterwards.
		/// </summary>
		/// <seealso cref="ExecuteInternal" />
        public void Execute(IJobExecutionContext context)
		{
			try
			{
				ObjectWrapper bw = new ObjectWrapper(this);
				MutablePropertyValues pvs = new MutablePropertyValues();
				pvs.AddAll(context.Scheduler.Context);
				pvs.AddAll(context.MergedJobDataMap);
				bw.SetPropertyValues(pvs, true);
			}
			catch (SchedulerException ex)
			{
				throw new JobExecutionException(ex);
			}
			ExecuteInternal(context);
		}
        public override IPropertyValues PostProcessPropertyValues(IPropertyValues propertyValues, PropertyInfo[] propertyInfos, object objectInstance, string objectName)
        {
            MutablePropertyValues mpv = new MutablePropertyValues(propertyValues);

            IConfigurableObjectDefinition objectDefinition = (IConfigurableObjectDefinition)_objectFactory.GetObjectDefinition(objectName);
            DependencyCheckingMode checkMode = objectDefinition.DependencyCheck;
            PropertyInfo[] unresolvedProperties = AutowireUtils.GetUnsatisfiedDependencies(propertyInfos, propertyValues, checkMode);
            foreach(PropertyInfo propertyInfo in unresolvedProperties)
            {
                object value = ResolveDependency(objectName, objectDefinition, new ObjectWrapper(objectInstance), propertyInfo);
                if (value != null)
                {
                    mpv.Add(propertyInfo.Name, value);
                }
            }

            return base.PostProcessPropertyValues(mpv, propertyInfos, objectInstance, objectName);
        }
        public void ChangesSince()
        {
            IDictionary map = new Hashtable ();
            PropertyValue propName = new PropertyValue ("Name", "Fiona Apple");
            map.Add (propName.Name, propName.Value);
            map.Add ("Age", 24);
            MutablePropertyValues props = new MutablePropertyValues (map);
            MutablePropertyValues newProps = new MutablePropertyValues (map);

            // change the name... this is the change we'll be looking for
            newProps.SetPropertyValueAt (new PropertyValue (propName.Name, "Naomi Woolf"), 0);
            IPropertyValues changes = newProps.ChangesSince (props);
            Assert.AreEqual (1, changes.PropertyValues.Length);
            // the name was changed, so its the name property that should be in the changed list
            Assert.IsTrue (changes.Contains ("name"));

            newProps.Add (new PropertyValue ("Commentator", "Naomi Woolf"));
            changes = newProps.ChangesSince (props);
            Assert.AreEqual (2, changes.PropertyValues.Length);
            // the Commentator was added, so its the Commentator property that should be in the changed list
            Assert.IsTrue (changes.Contains ("commentator"));
            // the name was changed, so its the name property that should be in the changed list
            Assert.IsTrue (changes.Contains ("name"));
        }
        /// <summary>
        /// Configures the NVelocity resource loader definitions from the xml definition
        /// </summary>
        /// <param name="element">the root resource loader element</param>
        /// <param name="objectDefinitionProperties">the MutablePropertyValues used to configure this object</param>
        /// <param name="properties">the properties used to initialize the velocity engine</param>
        private void ParseResourceLoader(XmlElement element, MutablePropertyValues objectDefinitionProperties, IDictionary<string, object> properties) {
            string caching = GetAttributeValue(element, TemplateDefinitionConstants.AttributeTemplateCaching);
            string defaultCacheSize = GetAttributeValue(element, TemplateDefinitionConstants.AttributeDefaultCacheSize);
            string modificationCheckInterval = GetAttributeValue(element, TemplateDefinitionConstants.AttributeModificationCheckInterval);

            if (!string.IsNullOrEmpty(defaultCacheSize)) {
                properties.Add(RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE, defaultCacheSize);
            }

            XmlNodeList loaderElements = element.ChildNodes;
            switch (loaderElements[0].LocalName) {
                case VelocityConstants.File:
                    AppendFileLoaderProperties(loaderElements, properties);
                    AppendResourceLoaderGlobalProperties(properties, VelocityConstants.File, caching,
                                                         modificationCheckInterval);
                    break;
                case VelocityConstants.Assembly:
                    AppendAssemblyLoaderProperties(loaderElements, properties);
                    AppendResourceLoaderGlobalProperties(properties, VelocityConstants.Assembly, caching, null);
                    break;
                case TemplateDefinitionConstants.Spring:
                    AppendResourceLoaderPaths(loaderElements, objectDefinitionProperties);
                    AppendResourceLoaderGlobalProperties(properties, TemplateDefinitionConstants.Spring, caching, null);
                    break;
                case TemplateDefinitionConstants.Custom:
                    XmlElement firstElement = (XmlElement)loaderElements.Item(0);
                    AppendCustomLoaderProperties(firstElement, properties);
                    AppendResourceLoaderGlobalProperties(properties, firstElement.LocalName, caching, modificationCheckInterval);
                    break;
                default:
                    throw new ArgumentException(string.Format("undefined element for resource loadre type: {0}", element.LocalName));
            }
        }
        /// <summary>
        /// Parses child element definitions for the NVelocity engine. Typically resource loaders and locally defined properties are parsed here
        /// </summary>
        /// <param name="childElements">the XmlNodeList representing the child configuration of the root NVelocity engine element</param>
        /// <param name="parserContext">the parser context</param>
        /// <param name="objectDefinitionProperties">the MutablePropertyValues used to configure this object</param>
        private void ParseChildDefinitions(XmlNodeList childElements, ParserContext parserContext, MutablePropertyValues objectDefinitionProperties) {
            IDictionary<string, object> properties = new Dictionary<string, object>();

            foreach (XmlElement element in childElements) {
                switch (element.LocalName) {
                    case TemplateDefinitionConstants.ElementResourceLoader:
                        ParseResourceLoader(element, objectDefinitionProperties, properties);
                        break;
                    case TemplateDefinitionConstants.ElementNVelocityProperties:
                        ParseNVelocityProperties(element, parserContext, properties);
                        break;
                }
            }

            if (properties.Count > 0) {
                objectDefinitionProperties.Add(TemplateDefinitionConstants.PropertyVelocityProperties, properties);
            }
        }
        /// <summary>
        /// Creates an error message action based on the specified message element.
        /// </summary>
        /// <param name="message">The message element.</param>
        /// <param name="parserContext">The parser helper.</param>
        /// <returns>The error message action definition.</returns>
        private static IObjectDefinition ParseErrorMessageAction(XmlElement message, ParserContext parserContext)
        {
            string messageId = GetAttributeValue(message, MessageConstants.IdAttribute);
            string[] providers = GetAttributeValue(message, MessageConstants.ProvidersAttribute).Split(',');
            ArrayList parameters = new ArrayList();

            foreach (XmlElement param in message.ChildNodes)
            {
                IExpression paramExpression = Expression.Parse(GetAttributeValue(param, MessageConstants.ParameterValueAttribute));
                parameters.Add(paramExpression);
            }

            string typeName = "Spring.Validation.Actions.ErrorMessageAction, Spring.Core";
            ConstructorArgumentValues ctorArgs = new ConstructorArgumentValues();
            ctorArgs.AddGenericArgumentValue(messageId);
            ctorArgs.AddGenericArgumentValue(providers);

            string when = GetAttributeValue(message, ValidatorDefinitionConstants.WhenAttribute);
            MutablePropertyValues properties = new MutablePropertyValues();
            if (StringUtils.HasText(when))
            {
                properties.Add("When", when);
            }
            if (parameters.Count > 0)
            {
                properties.Add("Parameters", parameters.ToArray(typeof(IExpression)));
            }

            IConfigurableObjectDefinition action =
                parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(typeName, null, parserContext.ReaderContext.Reader.Domain);
            action.ConstructorArgumentValues = ctorArgs;
            action.PropertyValues = properties;

            return action;
        }
 public void ChangesSinceWithSelf () 
 {
     IDictionary<string, object> map = new Dictionary<string, object>();
     map.Add("Name", "Fiona Apple");
     map.Add ("Age", 24);
     MutablePropertyValues props = new MutablePropertyValues (map);
     props.Remove ("name");
     // get all of the changes between self and self again (there should be none);
     IPropertyValues changes = props.ChangesSince (props);
     Assert.AreEqual (0, changes.PropertyValues.Count);
 }
        public void DoTestMessageAccess(bool hasParentContext, bool useCodeAsDefaultMessage)
        {
            StaticApplicationContext ac = new StaticApplicationContext();
            if (hasParentContext)
            {
                StaticApplicationContext parent = new StaticApplicationContext();
                parent.Refresh();
                ac.ParentContext = parent;
            }

            MutablePropertyValues pvs = new MutablePropertyValues();
            pvs.Add("resourceManagers", resourceManagerList);
            if (useCodeAsDefaultMessage)
            {
                pvs.Add("UseCodeAsDefaultMessage", true);
            }
            ac.RegisterSingleton("messageSource", typeof(ResourceSetMessageSource), pvs);
            ac.Refresh();


            // Localizaiton fallbacks
            GetMessageLocalizationFallbacks(ac);

            // MessageSourceAccessor functionality
            MessageSourceAccessor accessor = new MessageSourceAccessor(ac);
            Assert.AreEqual("message3", accessor.GetMessage("code3", CultureInfo.CurrentUICulture, (object[])null));

            // IMessageSourceResolveable
            Assert.AreEqual("message3", ac.GetMessage("code3", CultureInfo.CurrentUICulture, (object[])null));
            IMessageSourceResolvable resolvable = new DefaultMessageSourceResolvable("code3");

            Assert.AreEqual("message3", ac.GetMessage(resolvable, CultureInfo.CurrentUICulture));
            resolvable = new DefaultMessageSourceResolvable(new string[] { "code4", "code3" });
            Assert.AreEqual("message3", ac.GetMessage(resolvable, CultureInfo.CurrentUICulture));

            Assert.AreEqual("message3", ac.GetMessage("code3", CultureInfo.CurrentUICulture, (object[])null));
            resolvable = new DefaultMessageSourceResolvable(new string[] { "code4", "code3" });
            Assert.AreEqual("message3", ac.GetMessage(resolvable, CultureInfo.CurrentUICulture));

            object[] arguments = new object[] { "Hello", new DefaultMessageSourceResolvable(new string[] { "code1" }) };
            Assert.AreEqual("Hello, message1", ac.GetMessage("hello", CultureInfo.CurrentUICulture, arguments));


            // test default message without and with args
            Assert.AreEqual("default", ac.GetMessage(null, "default", CultureInfo.CurrentUICulture, null));
            Assert.AreEqual("default", ac.GetMessage(null, "default", CultureInfo.CurrentUICulture, arguments));

            /* not supported 
            Assert.AreEqual("{0}, default", ac.GetMessage(null, "{0}, default", CultureInfo.CurrentUICulture, null));
             */

            Assert.AreEqual("Hello, default", ac.GetMessage(null, "{0}, default", CultureInfo.CurrentUICulture, arguments));

            // test resolvable with default message, without and with args
            resolvable = new DefaultMessageSourceResolvable(null, null, "default");
            Assert.AreEqual("default", ac.GetMessage(resolvable, CultureInfo.CurrentUICulture));
            resolvable = new DefaultMessageSourceResolvable(null, arguments, "default");
            Assert.AreEqual("default", ac.GetMessage(resolvable, CultureInfo.CurrentUICulture));

            /* not supported 
                resolvable = new DefaultMessageSourceResolvable(null, null, "{0}, default");
                Assert.AreEqual("{0}, default", ac.GetMessage(resolvable, CultureInfo.CurrentUICulture));
            */

            resolvable = new DefaultMessageSourceResolvable(null, arguments, "{0}, default");
            Assert.AreEqual("Hello, default", ac.GetMessage(resolvable, CultureInfo.CurrentUICulture));


            // test message args
            Assert.AreEqual("Arg1, Arg2", ac.GetMessage("hello", CultureInfo.CurrentUICulture, new object[] { "Arg1", "Arg2" }));

            /* not supported 
                Assert.AreEqual("{0}, {1}", ac.GetMessage("hello", CultureInfo.CurrentUICulture, null));
            */


            /* not supported 
                Assert.AreEqual("Hello\nWorld", ac.GetMessage("escaped"));
            }
            else
            {
                Assert.AreEqual("Hello\\nWorld", ac.GetMessage("escaped"));
            }
            */


            try
            {
                Assert.AreEqual("MyNonExistantMessage", ac.GetMessage("MyNonExistantMessage"));
                if (!useCodeAsDefaultMessage)
                {
                    Assert.Fail("Should have thrown NoSuchMessagException");
                }
            }
            catch (NoSuchMessageException e)
            {
                if (useCodeAsDefaultMessage)
                {
                    Assert.Fail("Should have returned code as default message.");
                    e.ToString();
                }
            }

        }
 public void RemoveByPropertyValue () 
 {
     MutablePropertyValues props = new MutablePropertyValues ();
     PropertyValue propName = new PropertyValue ("Name", "Fiona Apple");
     props.Add (propName);
     props.Add (new PropertyValue ("Age", 24));
     Assert.AreEqual (2, props.PropertyValues.Count);
     props.Remove (propName);
     Assert.AreEqual (1, props.PropertyValues.Count);
 }
        private IObjectDefinition ParseExceptionAction(XmlElement element, ParserContext parserContext)
        {
            string typeName = "Spring.Validation.Actions.ExceptionAction, Spring.Core";
            string throwExpression = GetAttributeValue(element, ValidatorDefinitionConstants.ThrowAttribute);

            
            ConstructorArgumentValues ctorArgs = new ConstructorArgumentValues();
            ctorArgs.AddGenericArgumentValue(throwExpression);

            string when = GetAttributeValue(element, ValidatorDefinitionConstants.WhenAttribute);
            MutablePropertyValues properties = new MutablePropertyValues();
            if (StringUtils.HasText(when))
            {
                properties.Add("When", when);
            }

            IConfigurableObjectDefinition action =
                parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(typeName, null, parserContext.ReaderContext.Reader.Domain);
            action.ConstructorArgumentValues = ctorArgs;
            action.PropertyValues = properties;

            return action;
        }
        /// <summary>
        /// Parses the CaoExporter definition.
        /// </summary>
        /// <param name="element">The element to parse.</param>
        /// <param name="name">The name of the object definition.</param>
        /// <param name="parserContext">The parser context.</param>
        /// <returns>CaoExporter object definition.</returns>
        private IConfigurableObjectDefinition ParseCaoExporter(
            XmlElement element, string name, ParserContext parserContext)
        {
            string typeName = GetTypeName(element);
            string targetName = element.GetAttribute(CaoExporterConstants.TargetNameAttribute);
            string infinite = element.GetAttribute(CaoExporterConstants.InfiniteAttribute);

            MutablePropertyValues properties = new MutablePropertyValues();
            if (StringUtils.HasText(targetName))
            {
                properties.Add("TargetName", targetName);
            }
            if (StringUtils.HasText(infinite))
            {
                properties.Add("Infinite", infinite);
            }

            foreach (XmlElement child in element.ChildNodes)
            {
                switch (child.LocalName)
                {
                    case LifeTimeConstants.LifeTimeElement:
                        ParseLifeTime(properties, child, parserContext);
                        break;
                    case InterfacesConstants.InterfacesElement:
                        properties.Add("Interfaces", base.ParseListElement(child, name, parserContext));
                        break;
                }
            }

            IConfigurableObjectDefinition cod = parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(
                typeName, null, parserContext.ReaderContext.Reader.Domain);
            cod.PropertyValues = properties;

            return cod;
        }
        /// <summary>
        /// Parses the LifeTime definition.
        /// </summary>
        private void ParseLifeTime(MutablePropertyValues properties, XmlElement child, ParserContext parserContext)
        {
            string initialLeaseTime = child.GetAttribute(LifeTimeConstants.InitialLeaseTimeAttribute);
            string renewOnCallTime = child.GetAttribute(LifeTimeConstants.RenewOnCallTimeAttribute);
            string sponsorshipTimeout = child.GetAttribute(LifeTimeConstants.SponsorshipTimeoutAttribute);

            if (StringUtils.HasText(initialLeaseTime))
            {
                properties.Add("InitialLeaseTime", initialLeaseTime);
            }
            if (StringUtils.HasText(renewOnCallTime))
            {
                properties.Add("RenewOnCallTime", renewOnCallTime);
            }
            if (StringUtils.HasText(sponsorshipTimeout))
            {
                properties.Add("SponsorshipTimeout", sponsorshipTimeout);
            }
        }
        /// <summary>
        /// Parses the CaoFactoryObject definition.
        /// </summary>
        /// <param name="element">The element to parse.</param>
        /// <param name="name">The name of the object definition.</param>
        /// <param name="parserContext">The parser context.</param>
        /// <returns>CaoFactoryObject object definition.</returns>
        private IConfigurableObjectDefinition ParseCaoFactoryObject(
            XmlElement element, string name, ParserContext parserContext)
        {
            string typeName = GetTypeName(element);
            string remoteTargetName = element.GetAttribute(CaoFactoryObjectConstants.RemoteTargetNameAttribute);
            string serviceUrl = element.GetAttribute(CaoFactoryObjectConstants.ServiceUrlAttribute);

            MutablePropertyValues properties = new MutablePropertyValues();
            if (StringUtils.HasText(remoteTargetName))
            {
                properties.Add("RemoteTargetName", remoteTargetName);
            }
            if (StringUtils.HasText(serviceUrl))
            {
                properties.Add("ServiceUrl", serviceUrl);
            }

            foreach (XmlElement child in element.ChildNodes)
            {
                switch (child.LocalName)
                {
                    case CaoFactoryObjectConstants.ConstructorArgumentsElement:
                        properties.Add("ConstructorArguments", base.ParseListElement(child, name, parserContext));
                        break;
                }
            }

            IConfigurableObjectDefinition cod = parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(
                typeName, null, parserContext.ReaderContext.Reader.Domain);
            cod.PropertyValues = properties;

            return cod;
        }
        /// <summary>
        /// Parses the SaoFactoryObject definition.
        /// </summary>
        /// <param name="element">The element to parse.</param>
        /// <param name="name">The name of the object definition.</param>
        /// <param name="parserContext">The parser context.</param>
        /// <returns>SaoFactoryObject object definition.</returns>
        private IConfigurableObjectDefinition ParseSaoFactoryObject(
            XmlElement element, string name, ParserContext parserContext)
        {
            string typeName = GetTypeName(element);
            string serviceInterface = element.GetAttribute(SaoFactoryObjectConstants.ServiceInterfaceAttribute);
            string serviceUrl = element.GetAttribute(SaoFactoryObjectConstants.ServiceUrlAttribute);

            MutablePropertyValues properties = new MutablePropertyValues();
            if (StringUtils.HasText(serviceInterface))
            {
                properties.Add("ServiceInterface", serviceInterface);
            }
            if (StringUtils.HasText(serviceUrl))
            {
                properties.Add("ServiceUrl", serviceUrl);
            }
            IConfigurableObjectDefinition cod = parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(
                typeName, null, parserContext.ReaderContext.Reader.Domain);
            cod.PropertyValues = properties;
            return cod;
        }
        /// <summary>
        /// Parses the RemotingConfigurer definition.
        /// </summary>
        /// <param name="element">The element to parse.</param>
        /// <param name="name">The name of the object definition.</param>
        /// <param name="parserContext">The parser context.</param>
        /// <returns>RemotingConfigurer object definition.</returns>
        private IConfigurableObjectDefinition ParseRemotingConfigurer(
            XmlElement element, string name, ParserContext parserContext)
        {
            string typeName = GetTypeName(element);
            string filename = element.GetAttribute(RemotingConfigurerConstants.FilenameAttribute);
            string useConfigFile = element.GetAttribute(RemotingConfigurerConstants.UseConfigFileAttribute);
            string ensureSecurity = element.GetAttribute(RemotingConfigurerConstants.EnsureSecurityAttribute);

            MutablePropertyValues properties = new MutablePropertyValues();
            if (StringUtils.HasText(filename))
            {
                properties.Add("Filename", filename);
            }
            if (StringUtils.HasText(useConfigFile))
            {
                properties.Add("UseConfigFile", useConfigFile);
            }
            if (StringUtils.HasText(ensureSecurity))
            {
                properties.Add("EnsureSecurity", ensureSecurity);
            }

            IConfigurableObjectDefinition cod = parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(
                typeName, null, parserContext.ReaderContext.Reader.Domain);
            cod.PropertyValues = properties;
            return cod;
        }
 /// <summary>
 /// Creates a spring resource loader by setting the ResourceLoaderPaths of the
 /// engine factory (the resource loader itself will be created internally either as 
 /// spring or as file resource loader based on the value of prefer-file-system-access
 /// attribute).
 /// </summary>
 /// <param name="elements">list of resource loader path elements</param>
 /// <param name="objectDefinitionProperties">the MutablePropertyValues to set the property for the engine factory</param>
 private void AppendResourceLoaderPaths(XmlNodeList elements, MutablePropertyValues objectDefinitionProperties) {
     IList<string> paths = new List<string>();
     foreach (XmlElement element in elements) {
         string path = GetAttributeValue(element, TemplateDefinitionConstants.AttributeUri);
         paths.Add(path);
     }
     objectDefinitionProperties.Add(TemplateDefinitionConstants.PropertyResourceLoaderPaths, paths);
 }
 public void AddAllInMap () 
 {
     MutablePropertyValues props = new MutablePropertyValues ();
     IDictionary<string, object> map = new Dictionary<string, object>();
     map.Add("Name", "Fiona Apple");
     map.Add ("Age", 24);
     props.AddAll (map);
     Assert.AreEqual (2, props.PropertyValues.Count);
 }
        /// <summary>
        /// Parses the object definition for the engine object, configures a single NVelocity template engine based 
        /// on the element definitions.
        /// </summary>
        /// <param name="element">the root element defining the velocity engine</param>
        /// <param name="parserContext">the parser context</param>
        private IConfigurableObjectDefinition ParseNVelocityEngine(XmlElement element, ParserContext parserContext) {
            string typeName = GetTypeName(element);
            IConfigurableObjectDefinition configurableObjectDefinition = parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(
                typeName, null, parserContext.ReaderContext.Reader.Domain);

            string preferFileSystemAccess = GetAttributeValue(element, TemplateDefinitionConstants.AttributePreferFileSystemAccess);
            string overrideLogging = GetAttributeValue(element, TemplateDefinitionConstants.AttributeOverrideLogging);
            string configFile = GetAttributeValue(element, TemplateDefinitionConstants.AttributeConfigFile);

            MutablePropertyValues objectDefinitionProperties = new MutablePropertyValues();
            if (StringUtils.HasText(preferFileSystemAccess)) {
                objectDefinitionProperties.Add(TemplateDefinitionConstants.PropertyPreferFileSystemAccess, preferFileSystemAccess);
            }

            if (StringUtils.HasText(overrideLogging)) {
                objectDefinitionProperties.Add(TemplateDefinitionConstants.PropertyOverrideLogging, overrideLogging);
            }

            if (StringUtils.HasText(configFile)) {
                objectDefinitionProperties.Add(TemplateDefinitionConstants.PropertyConfigFile, configFile);
            }

            XmlNodeList childElements = element.ChildNodes;
            if (childElements.Count > 0) {
                ParseChildDefinitions(childElements, parserContext, objectDefinitionProperties);
            }
            configurableObjectDefinition.PropertyValues = objectDefinitionProperties;
            return configurableObjectDefinition;
        }
 public void AddAllInNullMap () 
 {
     MutablePropertyValues props = new MutablePropertyValues ();
     props.Add (new PropertyValue ("Name", "Fiona Apple"));
     props.AddAll ((IDictionary<string, object>) null);
     Assert.AreEqual (1, props.PropertyValues.Count);
 }
 public void Contains () 
 {
     MutablePropertyValues props = new MutablePropertyValues ();
     props.Add (new PropertyValue ("Name", "Fiona Apple"));
     props.Add (new PropertyValue ("Age", 24));
     // must be case insensitive to be CLS compliant...
     Assert.IsTrue (props.Contains ("nAmE"));
 }
        /// <summary>
        /// Creates object definition for the validator reference.
        /// </summary>
        /// <param name="element">The action definition element.</param>
        /// <param name="parserContext">The parser helper.</param>
        /// <returns>Generic validation action definition.</returns>
        private IObjectDefinition ParseValidatorReference(XmlElement element, ParserContext parserContext)
        {
            string typeName = "Spring.Validation.ValidatorReference, Spring.Core";
            string name = GetAttributeValue(element, ValidatorDefinitionConstants.ReferenceNameAttribute);
            string context = GetAttributeValue(element, ValidatorDefinitionConstants.ReferenceContextAttribute);
            string when = GetAttributeValue(element, ValidatorDefinitionConstants.WhenAttribute);

            MutablePropertyValues properties = new MutablePropertyValues();
            properties.Add("Name", name);
            if (StringUtils.HasText(context))
            {
                properties.Add("Context", context);
            }
            if (StringUtils.HasText(when))
            {
                properties.Add("When", when);
            }

            IConfigurableObjectDefinition reference =
                parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(typeName, null, parserContext.ReaderContext.Reader.Domain);
            reference.PropertyValues = properties;
            return reference;
        }