Esempio n. 1
0
        private static AttributeExtension ParseAttribute(XmlNode attributeNode)
        {
            AttributeExtension ext = new AttributeExtension();

            ext.Name = attributeNode.LocalName;

            if (attributeNode.Attributes != null)
            {
                ext.Values.Add(ValueName.Value, attributeNode.InnerText);

                foreach (XmlAttribute attr in attributeNode.Attributes)
                {
                    if (attr.LocalName == ValueName.Type)
                    {
                        ext.Values.Add(ValueName.ValueType, attr.Value);
                    }
                    else
                    {
                        ext.Values.Add(attr.LocalName, attr.Value);
                    }
                }
            }

            foreach (XmlNode node in attributeNode.ChildNodes)
            {
                ext.Attributes.Add(ParseAttribute(node));
            }

            return(ext);
        }
Esempio n. 2
0
        private static AttributeExtension ParseAttribute(XElement attributeNode)
        {
            var ext = new AttributeExtension
            {
                Name = attributeNode.Name.LocalName
            };

            ext.Values.Add(ValueName.Value, attributeNode.Value);

            foreach (var attr in attributeNode.Attributes())
            {
                if (attr.Name.LocalName == ValueName.Type)
                {
                    ext.Values.Add(ValueName.ValueType, attr.Value);
                }
                else
                {
                    ext.Values.Add(attr.Name.LocalName, attr.Value);
                }
            }

            foreach (var node in attributeNode.Elements())
            {
                ext.Attributes.Add(ParseAttribute(node));
            }

            return(ext);
        }
 internal void Add(AttributeExtension attributeExtension)
 {
     if (this != _null)
     {
         _attributes.Add(attributeExtension);
     }
 }
        public void Add(AttributeExtension attributeExtension)
        {
            if (this != _null)
            {
                // Add attribute.
                //
                AttributeExtensionCollection attr =
                    (AttributeExtensionCollection)_attributes[attributeExtension.Name];

                if (attr == null)
                {
                    _attributes[attributeExtension.Name] = attr = new AttributeExtensionCollection();
                }

                attr.Add(attributeExtension);

                /*
                 * // Convert value type.
                 * //
                 * bool isType = attributeExtension.Name.EndsWith(TypeExtension.AttrName.TypePostfix);
                 *
                 * if (isType)
                 * {
                 *      string attrName = attributeExtension.Name.Substring(
                 *              0, attributeExtension.Name.Length - 5);
                 *
                 *      AttributeExtensionCollection ext =
                 *              (AttributeExtensionCollection)_attributes[attrName];
                 *
                 *      if (ext != null && ext.Count == 1)
                 *              ext[0].Values.ChangeValueType(attributeExtension.Value.ToString());
                 * }
                 * else
                 * {
                 *      string attrName = attributeExtension.Name + TypeExtension.AttrName.TypePostfix;
                 *
                 *      AttributeExtensionCollection ext =
                 *              (AttributeExtensionCollection)_attributes[attrName];
                 *
                 *      if (ext != null && ext.Count == 1)
                 *              attributeExtension.Values.ChangeValueType(ext.Value.ToString());
                 * }
                 */
            }
        }
		public void Add(AttributeExtension attributeExtension)
		{
			if (this != _null)
			{
				// Add attribute.
				//
				AttributeExtensionCollection attr =
					(AttributeExtensionCollection)_attributes[attributeExtension.Name];

				if (attr == null)
					_attributes[attributeExtension.Name] = attr = new AttributeExtensionCollection();

				attr.Add(attributeExtension);

				/*
				// Convert value type.
				//
				bool isType = attributeExtension.Name.EndsWith(TypeExtension.AttrName.TypePostfix);

				if (isType)
				{
					string attrName = attributeExtension.Name.Substring(
						0, attributeExtension.Name.Length - 5);

					AttributeExtensionCollection ext =
						(AttributeExtensionCollection)_attributes[attrName];

					if (ext != null && ext.Count == 1)
						ext[0].Values.ChangeValueType(attributeExtension.Value.ToString());
				}
				else
				{
					string attrName = attributeExtension.Name + TypeExtension.AttrName.TypePostfix;

					AttributeExtensionCollection ext =
						(AttributeExtensionCollection)_attributes[attrName];

					if (ext != null && ext.Count == 1)
						attributeExtension.Values.ChangeValueType(ext.Value.ToString());
				}
				*/
			}
		}
        public void Add(string name, string value)
        {
            if (this != _null)
            {
                string attrName  = name;
                string valueName = string.Empty;

                int idx = name.IndexOf(TypeExtension.ValueName.Delimiter);

                if (idx > 0)
                {
                    valueName = name.Substring(idx + 1).TrimStart(TypeExtension.ValueName.Delimiter);
                    attrName  = name.Substring(0, idx);
                }

                if (valueName.Length == 0)
                {
                    valueName = TypeExtension.ValueName.Value;
                }
                else if (valueName == TypeExtension.ValueName.Type)
                {
                    valueName = TypeExtension.ValueName.ValueType;
                }

                AttributeExtensionCollection ext =
                    (AttributeExtensionCollection)_attributes[attrName];

                if (ext != null)
                {
                    ext[0].Values.Add(valueName, value);
                }
                else
                {
                    AttributeExtension attributeExtension = new AttributeExtension();

                    attributeExtension.Name = name;
                    attributeExtension.Values.Add(valueName, value);

                    Add(attributeExtension);
                }
            }
        }
        public void Add(string name, string value)
        {
            if (this != _null)
            {
                var attrName  = name;
                var valueName = string.Empty;
                var idx       = name.IndexOf(TypeExtension.ValueName.Delimiter);

                if (idx > 0)
                {
                    valueName = name.Substring(idx + 1).TrimStart(TypeExtension.ValueName.Delimiter);
                    attrName  = name.Substring(0, idx);
                }

                if (valueName.Length == 0)
                {
                    valueName = TypeExtension.ValueName.Value;
                }
                else if (valueName == TypeExtension.ValueName.Type)
                {
                    valueName = TypeExtension.ValueName.ValueType;
                }

                AttributeExtensionCollection ext;

                if (TryGetValue(attrName, out ext))
                {
                    ext[0].Values.Add(valueName, value);
                }
                else
                {
                    var attributeExtension = new AttributeExtension {
                        Name = name
                    };

                    attributeExtension.Values.Add(valueName, value);

                    Add(attributeExtension);
                }
            }
        }
Esempio n. 8
0
		private static AttributeExtension ParseAttribute(XElement attributeNode)
		{
			var ext = new AttributeExtension
			{
				Name = attributeNode.Name.LocalName
			};

			ext.Values.Add(ValueName.Value, attributeNode.Value);

			foreach (var attr in attributeNode.Attributes())
			{
				if (attr.Name.LocalName == ValueName.Type)
					ext.Values.Add(ValueName.ValueType, attr.Value);
				else
					ext.Values.Add(attr.Name.LocalName, attr.Value);
			}

			foreach (var node in attributeNode.Elements())
				ext.Attributes.Add(ParseAttribute(node));

			return ext;
		}
		public void Add(string name, string value)
		{
			if (this != _null)
			{
				string attrName  = name;
				string valueName = string.Empty;

				int idx = name.IndexOf(TypeExtension.ValueName.Delimiter);

				if (idx > 0)
				{
					valueName = name.Substring(idx + 1).TrimStart(TypeExtension.ValueName.Delimiter);
					attrName  = name.Substring(0, idx);
				}

				if (valueName.Length == 0)
					valueName = TypeExtension.ValueName.Value;
				else if (valueName == TypeExtension.ValueName.Type)
					valueName = TypeExtension.ValueName.ValueType;

				AttributeExtensionCollection ext =
					(AttributeExtensionCollection)_attributes[attrName];

				if (ext != null)
				{
					ext[0].Values.Add(valueName, value);
				}
				else
				{
					AttributeExtension attributeExtension = new AttributeExtension();

					attributeExtension.Name = name;
					attributeExtension.Values.Add(valueName, value);

					Add(attributeExtension);
				}
			}
		}
Esempio n. 10
0
		private static AttributeExtension ParseAttribute(XmlNode attributeNode)
		{
			AttributeExtension ext = new AttributeExtension();

			ext.Name = attributeNode.LocalName;

			if (attributeNode.Attributes != null)
			{
				ext.Values.Add(ValueName.Value, attributeNode.InnerText);

				foreach (XmlAttribute attr in attributeNode.Attributes)
				{
					if (attr.LocalName == ValueName.Type)
						ext.Values.Add(ValueName.ValueType, attr.Value);
					else
						ext.Values.Add(attr.LocalName, attr.Value);
				}
			}

			foreach (XmlNode node in attributeNode.ChildNodes)
				ext.Attributes.Add(ParseAttribute(node));

			return ext;
		}
		internal void Add(AttributeExtension attributeExtension)
		{
			if (this != _null)
				_attributes.Add(attributeExtension);
		}