Пример #1
0
        /// <summary>
        /// Convert an index key to human readable form.
        /// </summary>
        ///
        /// <param name="indexKeyArray">
        /// Array of index keys.
        /// </param>
        /// <param name="indexSeparator">
        /// The index separator.
        /// </param>
        ///
        /// <returns>
        /// The human readable key.
        /// </returns>

        public static string HumanReadableKey(object indexKeyArray, object indexSeparator)
        {
            string humanReadableKey = "";
            int    startIndex       = 1;

            ushort[] indexKey = (ushort[])indexKeyArray;

            if (!indexKey[0].Equals(indexSeparator))
            {
                ushort keyPart = (ushort)Convert.ChangeType(indexKey[1], typeof(ushort));
                humanReadableKey = Convert.ChangeType(indexKey[0], typeof(char)) + HtmlData.TokenName(keyPart) + '/';
                startIndex       = 3;
            }

            for (int i = startIndex; i < indexKey.Length; i++)
            {
                ushort c = (ushort)Convert.ChangeType(indexKey[i], typeof(ushort));
                humanReadableKey += ((ushort)c).ToString().PadLeft(3, '0');
                if (i < indexKey.Length - 1)
                {
                    humanReadableKey += '/';
                }
            }
            return(humanReadableKey);
        }
Пример #2
0
        /// <summary>
        /// Enumerates the attributes in this collection as a sequence of KeyValuePairs.
        /// </summary>
        ///
        /// <returns>
        /// A sequence of KeyValuePair&lt;string,string&gt; objects.
        /// </returns>

        protected IEnumerable <KeyValuePair <string, string> > GetAttributes()
        {
            foreach (var kvp in Attributes)
            {
                yield return(new KeyValuePair <string, string>(HtmlData.TokenName(kvp.Key).ToLower(), kvp.Value));
            }
        }
Пример #3
0
        /// <summary>
        /// Return the formatted string representation of this style, as HTML, or null if there is no
        /// style attribute.
        /// </summary>
        ///
        /// <returns>
        /// A string.
        /// </returns>

        public override string ToString()
        {
            string style = HasStyleAttribute ? "" : null;

            if (HasStyleAttribute)
            {
                if (QuickSetValue != null)
                {
                    return(QuickSetValue);
                }
                else
                {
                    bool first = true;
                    foreach (var kvp in Styles)
                    {
                        if (!first)
                        {
                            style += " ";
                        }
                        else
                        {
                            first = false;
                        }

                        style += HtmlData.TokenName(kvp.Key) + ": " + kvp.Value + ";";
                    }
                }
            }

            return(style);
        }
Пример #4
0
        /// <summary>
        /// Return the formatted string representation of this style, as HTML.
        /// </summary>
        ///
        /// <returns>
        /// A string.
        /// </returns>

        public override string ToString()
        {
            string style = String.Empty;

            if (HasStyles)
            {
                string delim = Styles.Count > 1 ? ";":"";
                bool   first = true;
                foreach (var kvp in Styles)
                {
                    if (!first)
                    {
                        style += " ";
                    }
                    else
                    {
                        first = false;
                    }

                    style += HtmlData.TokenName(kvp.Key) + ": " + kvp.Value + delim;
                }
            }

            return(style);
        }
Пример #5
0
 protected IEnumerable <KeyValuePair <string, string> > stylesEnumerable()
 {
     foreach (var kvp in Styles)
     {
         yield return(new KeyValuePair <string, string>(HtmlData.TokenName(kvp.Key).ToLower(), kvp.Value));
     }
     yield break;
 }
Пример #6
0
        void ICollection <KeyValuePair <string, string> > .CopyTo(KeyValuePair <string, string>[] array, int arrayIndex)
        {
            array = new KeyValuePair <string, string> [Attributes.Count];
            int index = 0;

            foreach (var kvp in Attributes)
            {
                array[index++] = new KeyValuePair <string, string>(HtmlData.TokenName(kvp.Key), kvp.Value);
            }
        }
Пример #7
0
 private IEnumerable <KeyValuePair <string, string> > stylesEnumerable()
 {
     if (HasStyleAttribute)
     {
         foreach (var kvp in Styles)
         {
             yield return(new KeyValuePair <string, string>(HtmlData.TokenName(kvp.Key).ToLower(), kvp.Value));
         }
     }
 }
Пример #8
0
 protected IEnumerable <KeyValuePair <string, string> > GetAttributes()
 {
     if (!UseDict)
     {
         for (int i = 0; i < Count; i++)
         {
             yield return(new KeyValuePair <string, string>(HtmlData.TokenName(InnerKeys[i]), InnerValues[i]));
         }
     }
     else
     {
         foreach (var kvp in InnerDictionary)
         {
             yield return(new KeyValuePair <string, string>(HtmlData.TokenName(kvp.Key).ToLower(), kvp.Value));
         }
     }
 }