/// <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); }
/// <summary> /// Enumerates the attributes in this collection as a sequence of KeyValuePairs. /// </summary> /// /// <returns> /// A sequence of KeyValuePair<string,string> 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)); } }
/// <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); }
/// <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); }
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; }
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); } }
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)); } } }
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)); } } }