public void MergeEmptyChild()
 {
     ManagedDictionary parent = new ManagedDictionary();
     parent.Add("one", "one");
     parent.Add("two", "two");
     ManagedDictionary child = new ManagedDictionary();
     child.MergeEnabled = true;
     IDictionary mergedMap = (IDictionary)child.Merge(parent);
     Assert.AreEqual(2, mergedMap.Count);
 }
 public void MergeSunnyDay()
 {
     ManagedDictionary parent = new ManagedDictionary();
     parent.Add("one", "one");
     parent.Add("two", "two");
     ManagedDictionary child = new ManagedDictionary();
     child.Add("three", "three");
     child.MergeEnabled = true;
     IDictionary mergedList = (IDictionary)child.Merge(parent);
     Assert.AreEqual(3, mergedList.Count);
 }
Пример #3
0
 public void MergeChildValueOverrideTheParents()
 {
     ManagedDictionary parent = new ManagedDictionary();
     parent.Add("one", "one");
     parent.Add("two", "two");
     ManagedDictionary child = new ManagedDictionary();
     child.Add("one", "fork");
     child.MergeEnabled = true;
     IDictionary mergedMap = (IDictionary)child.Merge(parent);
     Assert.AreEqual(2, mergedMap.Count);
     Assert.AreEqual("fork", mergedMap["one"]);
 }
 protected override void PostProcessHeaders(XmlElement element, ManagedDictionary headers, ParserContext parserContext)
 {
     XmlNodeList childNodes = element.ChildNodes;
     for(int i = 0; i < childNodes.Count; i++) {
         XmlNode node = childNodes.Item(i);
         if(node.NodeType == XmlNodeType.Element && node.LocalName.Equals("header")) {
             XmlElement headerElement = (XmlElement)node;
             string name = headerElement.GetAttribute("name");
             string value = headerElement.GetAttribute("value");
             string refatr = headerElement.GetAttribute("ref");
             bool isValue = StringUtils.HasText(value);
             bool isRef = StringUtils.HasText(refatr);
             if(!(isValue ^ isRef)) {
                 parserContext.ReaderContext.ReportException(headerElement, headerElement.Name, "Exactly one of the 'value' or 'ref' attributes is required.");
             }
             if(isValue) {
                 headers.Add(name, value);
             }
             else {
                 headers.Add(name, new RuntimeObjectReference(refatr));
             }
         }
     }
 }
 public void MergeNotAllowedWhenMergeNotEnabled()
 {
     ManagedDictionary child = new ManagedDictionary();
     Assert.Throws<InvalidOperationException>(() => child.Merge(null), "Not allowed to merge when the 'MergeEnabled' property is set to 'false'");
 }
 public void MergeWithNullParent()
 {
     ManagedDictionary child = new ManagedDictionary();
     child.MergeEnabled = true;
     Assert.AreSame(child, child.Merge(null));
 }
        public void ResolvesMergedGenericType()
        {
            ManagedDictionary parent = new ManagedDictionary();
            parent.Add("one", 1);
            parent.Add("two", 2);
            parent.KeyTypeName = "string";
            parent.ValueTypeName = "int";
            
            ManagedDictionary child = new ManagedDictionary();
            child.MergeEnabled = true;
            child.Add("one", -1);
            child.Add("three", 3);
             
            ManagedDictionary merged = (ManagedDictionary) child.Merge(parent);

            IDictionary resolved = (IDictionary) merged.Resolve("somename", new RootObjectDefinition(typeof(object)), "prop",
                (name, definition, argumentName, element) => element);
            
            Assert.IsInstanceOf<IDictionary<string,int>>(resolved);
            Assert.AreEqual(3, resolved.Count);
            Assert.AreEqual(typeof(int), resolved["two"].GetType());
            Assert.AreEqual(-1, resolved["one"]);
        }
 /**
  * Subclasses may implement this method to provide additional headers.
  */
 protected virtual void PostProcessHeaders(XmlElement element, ManagedDictionary headers, ParserContext parserContext)
 {
 }
Пример #9
0
        /// <summary>
        /// Visits the ManagedSet properties KeyTypeName and ValueTypeName and 
        /// calls <see cref="ResolveValue"/> for dictionary's value element.
        /// </summary>
        protected virtual void VisitManagedDictionary(ManagedDictionary dictVal)
        {
            string keyTypeName = dictVal.KeyTypeName;
            if (keyTypeName != null)
            {
                string resolvedName = ResolveStringValue(keyTypeName);
                if (!keyTypeName.Equals(resolvedName))
                {
                    dictVal.KeyTypeName = resolvedName;
                }
            }

            string valueTypeName = dictVal.ValueTypeName;
            if (valueTypeName != null)
            {
                string resolvedName = ResolveStringValue(valueTypeName);
                if (!valueTypeName.Equals(resolvedName))
                {
                    dictVal.ValueTypeName = resolvedName;
                }
            }

            Hashtable mods = new Hashtable();
            bool entriesModified = false;
            foreach (DictionaryEntry entry in dictVal)
            {
                /*

                object oldValue = entry.Value;
                object newValue = ResolveValue(oldValue);
                if (!ObjectUtils.NullSafeEquals(newValue, oldValue))
                {
                    mods[entry.Key] = newValue;
                }*/

                object key = entry.Key;
                object newKey = ResolveValue(key);
                object oldValue = entry.Value;
                object newValue = ResolveValue(oldValue);

                if (!ObjectUtils.NullSafeEquals(newValue, oldValue) || key != newKey)
                {
                    entriesModified = true;
                }
                mods[newKey] = newValue;

            }
            if (entriesModified)
            {
                dictVal.Clear();
                foreach (DictionaryEntry entry in mods)
                {
                    dictVal[entry.Key] = entry.Value;
                }
            }
        }
        public void VisitManagedDictionary()
        {
            IObjectDefinition od = new RootObjectDefinition();
            ManagedDictionary md = new ManagedDictionary();
            md.KeyTypeName = "$Property";
            md.ValueTypeName = "$Property";
            md.Add("Key", "$Property");
            od.PropertyValues.Add("PropertyName", md);

            ObjectDefinitionVisitor odv = new ObjectDefinitionVisitor(new ObjectDefinitionVisitor.ResolveHandler(ParseAndResolveVariables));
            odv.VisitObjectDefinition(od);

            ManagedDictionary dictionary = od.PropertyValues.GetPropertyValue("PropertyName").Value as ManagedDictionary;

            Assert.AreEqual("Value", dictionary.KeyTypeName);
            Assert.AreEqual("Value", dictionary.ValueTypeName);
            Assert.AreEqual("Value", dictionary["Key"]);
        }
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
 public void MergeWithNonCompatibleParentType()
 {
     ManagedDictionary child = new ManagedDictionary();
     child.MergeEnabled = true;
     child.Merge("hello");
 }
Пример #14
0
 public void MergeNotAllowedWhenMergeNotEnabled()
 {
     ManagedDictionary child = new ManagedDictionary();
     child.Merge(null);
 }
        protected override void ParseTransformer(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {
            ManagedDictionary headers = new ManagedDictionary();
            XmlAttributeCollection attributes = element.Attributes;
            for (int i = 0; i < attributes.Count; i++) {
            XmlNode node = attributes.Item(i);
            String name = node.LocalName;
            if (IsEligibleHeaderName(name)) {
                name = Conventions.AttributeNameToPropertyName(name);
                object value;
                if(ReferenceAttributesContains(name))
                    value = new RuntimeObjectReference(node.Value);
                else
                    value = node.Value;

                if (_prefix != null) {
                    name = _prefix + name;
                }
                headers.Add(name, value);
            }
            }
            PostProcessHeaders(element, headers, parserContext);
            builder.AddConstructorArg(headers);
            builder.AddPropertyValue("overwrite", ShouldOverwrite(element));
        }
 public void MergeWithNonCompatibleParentType()
 {
     ManagedDictionary child = new ManagedDictionary();
     child.MergeEnabled = true;
     Assert.Throws<InvalidOperationException>(() => child.Merge("hello"));
 }
Пример #17
0
	    /// <summary>
	    /// Merges the current value set with that of the supplied object.
	    /// </summary>
	    /// <remarks>The supplied object is considered the parent, and values in the 
	    /// callee's value set must override those of the supplied object.
	    /// </remarks>
	    /// <param name="parent">The parent object to merge with</param>
	    /// <returns>The result of the merge operation</returns>
	    /// <exception cref="ArgumentNullException">If the supplied parent is <code>null</code></exception>
	    /// <exception cref="InvalidOperationException">If merging is not enabled for this instance,
	    /// (i.e. <code>MergeEnabled</code> equals <code>false</code>.</exception>
	    public object Merge(object parent)
	    {       
	    	if (!this.mergeEnabled)
            	{
            		throw new InvalidOperationException(
                    		"Not allowed to merge when the 'MergeEnabled' property is set to 'false'");
            	}
            	if (parent == null)
            	{
                	return this;
            	}
            	var pDict = parent as IDictionary;
            	if (pDict == null)
            	{
            		throw new InvalidOperationException("Cannot merge with object of type [" + parent.GetType() + "]");
            	}
            	var merged = new ManagedDictionary();
            	var pManagedDict = pDict as ManagedDictionary;
            	if (pManagedDict != null)
            	{
            		merged.KeyTypeName = pManagedDict.keyTypeName;
            		merged.valueTypeName = pManagedDict.valueTypeName;
            	}
	    	foreach (DictionaryEntry dictionaryEntry in pDict)
	    	{
	            merged[dictionaryEntry.Key] = dictionaryEntry.Value;
	        }
	        foreach (DictionaryEntry entry in this)
	        {
	            merged[entry.Key] = entry.Value;
	        }
            	return merged;
	    }
        public void ResolvesInternalGenericTypes()
        {
            ManagedDictionary dict2 = new ManagedDictionary();
            dict2.Add("1", "stringValue");
            dict2.KeyTypeName = "int";
            dict2.ValueTypeName = typeof(InternalType).FullName;

            IDictionary resolved = (IDictionary) dict2.Resolve("other", new RootObjectDefinition(typeof (object)), "prop",
                                                               delegate(string name, IObjectDefinition definition, string argumentName, object element)
                                                                   {
                                                                       if ("stringValue".Equals(element))
                                                                       {
                                                                           return new InternalType();
                                                                       }
                                                                       return element;
                                                                   }
                                                     );
            Assert.AreEqual( typeof(InternalType), resolved[1].GetType() );
        }
        /// <summary>
        /// Gets a dictionary definition.
        /// </summary>
        /// <param name="mapEle">The element describing the dictionary definition.</param>
        /// <param name="name">The name of the object (definition) associated with the dictionary definition.</param>
        /// <param name="parserContext">The namespace-aware parser.</param>
        /// <returns>The dictionary definition.</returns>
        protected IDictionary ParseDictionaryElement(XmlElement mapEle, string name, ParserContext parserContext)
        {
            ManagedDictionary dictionary = new ManagedDictionary();
            string keyTypeName = GetAttributeValue(mapEle, "key-type");
            string valueTypeName = GetAttributeValue(mapEle, "value-type");
            if (StringUtils.HasText(keyTypeName))
            {
                dictionary.KeyTypeName = keyTypeName;
            }
            if (StringUtils.HasText(valueTypeName))
            {
                dictionary.ValueTypeName = valueTypeName;
            }
            dictionary.MergeEnabled = ParseMergeAttribute(mapEle, parserContext.ParserHelper);

            XmlNodeList entryElements = SelectNodes(mapEle, ObjectDefinitionConstants.EntryElement);
            foreach (XmlElement entryEle in entryElements)
            {
                #region Key

                object key = null;

                XmlAttribute keyAtt = entryEle.Attributes[ObjectDefinitionConstants.KeyAttribute];
                if (keyAtt != null)
                {
                    key = keyAtt.Value;
                }
                else
                {
                    // ok, we're not using the 'key' attribute; lets check for the ref shortcut...
                    XmlAttribute keyRefAtt = entryEle.Attributes[ObjectDefinitionConstants.DictionaryKeyRefShortcutAttribute];
                    if (keyRefAtt != null)
                    {
                        key = new RuntimeObjectReference(keyRefAtt.Value);
                    }
                    else
                    {
                        // so check for the 'key' element...
                        XmlNode keyNode = SelectSingleNode(entryEle, ObjectDefinitionConstants.KeyElement);
                        if (keyNode == null)
                        {
                            throw new ObjectDefinitionStoreException(
                                parserContext.ReaderContext.Resource, name,
                                string.Format("One of either the '{0}' element, or the the '{1}' or '{2}' attributes " +
                                              "is required for the <{3}/> element.",
                                              ObjectDefinitionConstants.KeyElement,
                                              ObjectDefinitionConstants.KeyAttribute,
                                              ObjectDefinitionConstants.DictionaryKeyRefShortcutAttribute,
                                              ObjectDefinitionConstants.EntryElement));
                        }
                        XmlElement keyElement = (XmlElement)keyNode;
                        XmlNodeList keyNodes = keyElement.GetElementsByTagName("*");
                        if (keyNodes == null || keyNodes.Count == 0)
                        {
                            throw new ObjectDefinitionStoreException(
                                parserContext.ReaderContext.Resource, name,
                                string.Format("Malformed <{0}/> element... the value of the key must be " +
                                    "specified as a child value-style element.",
                                              ObjectDefinitionConstants.KeyElement));
                        }
                        key = ParsePropertySubElement((XmlElement)keyNodes.Item(0), name, parserContext);
                    }
                }

                #endregion

                #region Value

                XmlAttribute inlineValueAtt = entryEle.Attributes[ObjectDefinitionConstants.ValueAttribute];
                if (inlineValueAtt != null)
                {
                    // ok, we're using the value attribute shortcut...
                    dictionary[key] = inlineValueAtt.Value;
                }
                else if (entryEle.Attributes[ObjectDefinitionConstants.DictionaryValueRefShortcutAttribute] != null)
                {
                    // ok, we're using the value-ref attribute shortcut...
                    XmlAttribute inlineValueRefAtt = entryEle.Attributes[ObjectDefinitionConstants.DictionaryValueRefShortcutAttribute];
                    RuntimeObjectReference ror = new RuntimeObjectReference(inlineValueRefAtt.Value);
                    dictionary[key] = ror;
                }
                else if (entryEle.Attributes[ObjectDefinitionConstants.ExpressionAttribute] != null)
                {
                    // ok, we're using the expression attribute shortcut...
                    XmlAttribute inlineExpressionAtt = entryEle.Attributes[ObjectDefinitionConstants.ExpressionAttribute];
                    ExpressionHolder expHolder = new ExpressionHolder(inlineExpressionAtt.Value);
                    dictionary[key] = expHolder;
                }
                else
                {
                    XmlNode keyNode = SelectSingleNode(entryEle, ObjectDefinitionConstants.KeyElement);
                    if (keyNode != null)
                    {
                        entryEle.RemoveChild(keyNode);
                    }
                    // ok, we're using the original full-on value element...
                    XmlNodeList valueElements = entryEle.GetElementsByTagName("*");
                    if (valueElements == null || valueElements.Count == 0)
                    {
                        throw new ObjectDefinitionStoreException(
                            parserContext.ReaderContext.Resource, name,
                            string.Format("One of either the '{0}' or '{1}' attributes, or a value-style element " +
                                "is required for the <{2}/> element.",
                                          ObjectDefinitionConstants.ValueAttribute, ObjectDefinitionConstants.DictionaryValueRefShortcutAttribute, ObjectDefinitionConstants.EntryElement));
                    }
                    dictionary[key] = ParsePropertySubElement((XmlElement)valueElements.Item(0), name, parserContext);
                }

                #endregion
            }
            return dictionary;
        }
        public void ResolvesGenericTypeNames()
        {
            ManagedDictionary dict = new ManagedDictionary();
            dict.Add("key", "value");
            dict.KeyTypeName = "string";

            dict.ValueTypeName = "System.Collections.Generic.List<[string]>";
            IDictionary resolved = (IDictionary) dict.Resolve("somename", new RootObjectDefinition(typeof(object)), "prop",
                                                              delegate(string name, IObjectDefinition definition, string argumentName, object element)
                                                                  {
                                                                      if ("value".Equals(element))
                                                                      {
                                                                          return new List<string>();
                                                                      }
                                                                      return element;
                                                                  }
                                                     );
            Assert.AreEqual(1, resolved.Count);
            Assert.AreEqual(typeof(List<string>), resolved["key"].GetType());
        }
        private AbstractObjectDefinition ParseAttributeSource(XmlElement element, ParserContext parserContext)
        {
            XmlNodeList methods = element.SelectNodes("*[local-name()='method' and namespace-uri()='" + element.NamespaceURI + "']");
            ManagedDictionary transactionAttributeMap = new ManagedDictionary();
            foreach (XmlElement methodElement in methods)
            {
                string name = GetAttributeValue(methodElement, "name");
                TypedStringValue nameHolder = new TypedStringValue(name);
                
                RuleBasedTransactionAttribute attribute = new RuleBasedTransactionAttribute();
                string propagation = GetAttributeValue(methodElement, PROPAGATION);
                string isolation = GetAttributeValue(methodElement, ISOLATION);
                string timeout = GetAttributeValue(methodElement, TIMEOUT);
                string readOnly = GetAttributeValue(methodElement, READ_ONLY);
                if (StringUtils.HasText(propagation))
                {
                    attribute.PropagationBehavior = (TransactionPropagation) Enum.Parse(typeof (TransactionPropagation), propagation, true);
                }
                if (StringUtils.HasText(isolation))
                {
                    attribute.TransactionIsolationLevel =
                        (IsolationLevel) Enum.Parse(typeof (IsolationLevel), isolation, true);
                }
                if (StringUtils.HasText(timeout))
                {
                    try
                    {
                        attribute.TransactionTimeout = Int32.Parse(timeout);
                    }
                    catch (FormatException ex)
                    {
                        parserContext.ReaderContext.ReportException(methodElement,"tx advice","timeout must be an integer value: [" + timeout + "]", ex);
                    }
                }
                if (StringUtils.HasText(readOnly))
                {
                    attribute.ReadOnly = Boolean.Parse(GetAttributeValue(methodElement, READ_ONLY));
                }
                IList rollbackRules = new LinkedList();
                if (methodElement.HasAttribute(ROLLBACK_FOR))
                {
                    string rollbackForValue = GetAttributeValue(methodElement, ROLLBACK_FOR);
                    AddRollbackRuleAttributesTo(rollbackRules, rollbackForValue);
                }
                if (methodElement.HasAttribute(NO_ROLLBACK_FOR))
                {
                    string noRollbackForValue = GetAttributeValue(methodElement, NO_ROLLBACK_FOR);
                    AddNoRollbackRuleAttributesTo(rollbackRules, noRollbackForValue);
                }
                attribute.RollbackRules = rollbackRules;

                transactionAttributeMap[nameHolder] = attribute;
            }

            ObjectDefinitionBuilder builder = parserContext
                                                .ParserHelper
                                                .CreateRootObjectDefinitionBuilder(typeof (NameMatchTransactionAttributeSource));
            builder.AddPropertyValue(NAME_MAP, transactionAttributeMap);
            return builder.ObjectDefinition;

        }
        /// <summary>
        /// Visits the ManagedSet properties KeyTypeName and ValueTypeName and 
        /// calls <see cref="ResolveValue"/> for dictionary's value element.
        /// </summary>
        protected virtual void VisitManagedDictionary(ManagedDictionary dictVal)
        {
            string keyTypeName = dictVal.KeyTypeName;
            if (keyTypeName != null)
            {
                string resolvedName = ResolveStringValue(keyTypeName);
                if (!keyTypeName.Equals(resolvedName))
                {
                    dictVal.KeyTypeName = resolvedName;
                }
            }

            string valueTypeName = dictVal.ValueTypeName;
            if (valueTypeName != null)
            {
                string resolvedName = ResolveStringValue(valueTypeName);
                if (!valueTypeName.Equals(resolvedName))
                {
                    dictVal.ValueTypeName = resolvedName;
                }
            }

            Hashtable mods = new Hashtable();
            foreach (DictionaryEntry entry in dictVal)
            {
                object oldValue = entry.Value;
                object newValue = ResolveValue(oldValue);
                if (!ObjectUtils.NullSafeEquals(newValue, oldValue))
                {
                    mods[entry.Key] = newValue;
                }
            }
            foreach (DictionaryEntry entry in mods)
            {
                dictVal[entry.Key] = entry.Value;
            }
        }