Exemplo n.º 1
0
		/// <summary>
		/// Adds the attribute at end.
		///
		/// (except for a special, compatability feature:
		///	Adds the attribute before the last one if the last attribute is empty, ""
		///	 (unless the new attribute is empty as well
		/// </summary>
		/// <param name="newAttribute"></param>
		public void AddAttribute(IcuDataAttribute newAttribute)
		{
			// Add the value at the end
			AddAttribute(newAttribute, -1);
		}
Exemplo n.º 2
0
		/// <summary>
		/// Fix the naming/parameters of these AddAttribute methods
		/// Add a new attribute, overwriting any existing attributes
		/// </summary>
		/// <param name="singleLine">Currently ignored</param>
		public void AddAttributeSmart(IcuDataAttribute newAttribute)
		{
			// Read the current value of the newAttribute
			// This is used becuase you cannot pass an attribute by referencce
			string attributePostSpace = newAttribute.PostSpace;

			// If there are no attributes,
			if( attributes.Count == 0 )
			{
				// This is the first attribute, it must go on a new line.
				// NOTE: Brace space will usuaally be an empty string when the node has children
				// and a newline when the node has several attributes.
				this.BraceSpace = Environment.NewLine;
				AddAttribute(newAttribute);
				return;
			}
			for(int index=0; index < attributes.Count; index++)
			{
				// Compare with and without the quotes
				if( ((IcuDataAttribute)attributes[index]).Value == newAttribute.StringValue ||
					((IcuDataAttribute)attributes[index]).Value == newAttribute.Value )
				{
					// overwrite the existing attribute
					AddAttribute(newAttribute, index);
					return;
				}
			}
			// Add the attribute
			AddAttribute(newAttribute);
		}
Exemplo n.º 3
0
		/// <summary>
		/// The base addition of an attribute, all additions of attributes should come through here.
		/// Unless an index is given to replace an attribute,
		/// adds the attribute at end.
		///
		/// (except for a special, compatability feature:
		///	Adds the attribute before the last one if the last attribute is empty, ""
		///	 (unless the new attribute is empty as well)
		/// </summary>
		/// <param name="newAttribute">The attribute to add to this node</param>
		/// <param name="index">The index of the attribute to replace.  Add at the end if the value is -1</param>
		public void AddAttribute(IcuDataAttribute newAttribute, int index)
		{
			newAttribute.ContainingNode = this;
			if( index == -1 )
			{
				if( attributes.Count > 0 && newAttribute.Value != "\"\"" &&
					((IcuDataAttribute)attributes[attributes.Count-1]).Value == "\"\"")
					attributes.Insert(attributes.Count-1,newAttribute);
				else
					attributes.Add(newAttribute);
			}
			else
				attributes[index] = newAttribute;
		}