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));
        }
예제 #2
0
 protected override void DoParse(XmlElement element, ObjectDefinitionBuilder builder)
 {
     foreach (XmlAttribute attribute in element.Attributes)
     {
         if (IsEligibleAttribute(attribute.Name))
         {
             string propertyName = Conventions.AttributeNameToPropertyName(attribute.LocalName);
             AssertUtils.State(StringUtils.HasText(propertyName), "Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty.");
             builder.AddPropertyValue(propertyName, attribute.Value);
         }
     }
     PostProcess(builder, element);
 }
 /// <summary>
 /// Populates the object definition property corresponding to the specified
 /// attributeName with the value of that attribute if it is defined in the
 /// given element.
 ///
 /// <p>The property name will be the camel-case equivalent of the lower
 /// case hyphen separated attribute (e.g. the "foo-bar" attribute would
 /// match the "fooBar" property).
 /// <see cref="Conventions.AttributeNameToPropertyName"/>
 /// </summary>
 /// <param name="builder">the builder</param>
 /// <param name="element">the XML element where the attribute should be defined</param>
 /// <param name="attributeName">the name of the attribute whose value will be set</param>
 public static void SetValueIfAttributeDefined(ObjectDefinitionBuilder builder, XmlElement element, string attributeName)
 {
     SetValueIfAttributeDefined(builder, element, attributeName, Conventions.AttributeNameToPropertyName(attributeName));
 }
예제 #4
0
 /// <summary>Sets the reference if attribute defined.</summary>
 /// <param name="builder">The builder.</param>
 /// <param name="element">The element.</param>
 /// <param name="attributeName">Name of the attribute.</param>
 /// <returns><c>true</c> if [is attribute defined] [the specified element]; otherwise, <c>false</c>.</returns>
 public static bool SetReferenceIfAttributeDefined(ObjectDefinitionBuilder builder, XmlElement element, string attributeName)
 {
     return(SetReferenceIfAttributeDefined(builder, element, attributeName, Conventions.AttributeNameToPropertyName(attributeName)));
 }