private static void InternalSetAttribute(this IAttributeItem item, DataService.Attribute value)
        {
            int index;
            var att = GetAttribute(item, value.Key, out index);

            if (att == null)
            {
                // Add attribute
                if (item.Attributes != null && item.Attributes.Length > 0)
                {
                    var atts = new DataService.Attribute[item.Attributes.Length + 1];
                    Array.Copy(item.Attributes, atts, item.Attributes.Length);
                    atts[atts.Length - 1] = value;
                    item.Attributes       = atts;
                }
                else
                {
                    item.Attributes = new[] { value };
                }
            }
            else
            {
                // Replace attribute
                item.Attributes[index] = value;
            }
        }
 /// <summary>
 /// Sets the <code>value</code> for the attribute with the key <code>key</code>.
 /// </summary>
 public static void SetAttribute(this IAttributeItem item, DataService.Attribute value)
 {
     if (value != null)
     {
         if (string.IsNullOrEmpty(value.Value))
         {
             RemoveAttribute(item, value.Key);
         }
         else
         {
             InternalSetAttribute(item, value);
         }
     }
 }
        /// <summary>
        /// Removes the attribute with the key <code>key</code>
        /// </summary>
        public static void RemoveAttribute(this IAttributeItem item, ushort key)
        {
            int index;
            var att = GetAttribute(item, key, out index);

            if (att != null)
            {
                // Remove attribute
                var atts = new DataService.Attribute[item.Attributes.Length - 1];
                Array.Copy(item.Attributes, 0, atts, 0, index);
                Array.Copy(item.Attributes, index + 1, atts, index, item.Attributes.Length - index - 1);

                item.Attributes = atts;
            }
        }
 private static void InternalSetAttribute( this IAttributeItem item, DataService.Attribute value )
 {
     int index;
     var att = GetAttribute( item, value.Key, out index );
     if( att == null )
     {
         // Add attribute
         if( item.Attributes != null && item.Attributes.Length > 0 )
         {
             var atts = new DataService.Attribute[ item.Attributes.Length + 1 ];
             Array.Copy( item.Attributes, atts, item.Attributes.Length );
             atts[ atts.Length - 1 ] = value;
             item.Attributes = atts;
         }
         else
         {
             item.Attributes = new[] { value };
         }
     }
     else
     {
         // Replace attribute
         item.Attributes[ index ] = value;
     }
 }
        /// <summary>
        /// Removes the attribute with the key <code>key</code>
        /// </summary>
        public static void RemoveAttribute( this IAttributeItem item, ushort key )
        {
            int index;
            var att = GetAttribute( item, key, out index );
            if( att != null )
            {
                // Remove attribute
                var atts = new DataService.Attribute[ item.Attributes.Length - 1 ];
                Array.Copy( item.Attributes, 0, atts, 0, index );
                Array.Copy( item.Attributes, index + 1, atts, index, item.Attributes.Length - index - 1 );

                item.Attributes = atts;
            }
        }