/// <summary> Constructor. </summary> /// <param name="text"> The text. </param> /// <param name="type"> The type. </param> /// <param name="indent"> The indent. </param> public OutputItem(string text, OutputItemType type, int indent = 0) { Text = text; ItemType = type; DisplayColour = _brushes[type]; Margin = new Thickness(0 + (indent * 10), 0, 0, 0); }
/// <summary> /// Initializes a new instance of the <see cref="OutputItem"/> class. /// </summary> /// <param name="itemType">The type of item to output.</param> /// <param name="childType">The type of the child to output, if the <paramref name="itemType"/> is Child.</param> /// <param name="groupOrdinal">The ordinal value of the grouping of elements that this item should be /// serialized with.</param> public OutputItem(OutputItemType itemType, Type childType, int groupOrdinal) { if (itemType == OutputItemType.Child) { ArgValidator.Create(childType, "childType").IsNotNull(); } this.ItemType = itemType; this.ChildType = childType; this.GroupOrdinal = groupOrdinal; }
/// <summary> /// Gets the ordinal corresponding to an element or text being read from the XmlReader. /// </summary> /// <param name="itemType">The output type of the element to look up.</param> /// <param name="type">The type of the element to look up.</param> /// <returns>The ordinal index that indicates where the element resides relative to its siblings. If an /// index isn't found, then the ordinal is assumed to be after all other specified siblings.</returns> internal int GetOrdinal(OutputItemType itemType, Type type) { int temp; if (!this.inputOrderMap.TryGetValue(itemType + ":" + type.ToString(), out temp)) { // Assume any order is valid for the remaining elements. temp = this.inputOrderMap.Count; } return(temp); }
/// <summary> /// Makes a key used to work with the ordinal dictionary. /// </summary> /// <param name="itemType">The output type of the element.</param> /// <param name="type">The type of the element.</param> /// <returns>A value to use as a key in the ordinal dictionary.</returns> private static string MakeKey(OutputItemType itemType, Type type) { return string.Join(":", itemType, type); }
/// <summary> /// Gets the ordinal corresponding to an element or text being read from the XmlReader. /// </summary> /// <param name="itemType">The output type of the element to look up.</param> /// <param name="type">The type of the element to look up.</param> /// <returns>The ordinal index that indicates where the element resides relative to its siblings. If an /// index isn't found, then the ordinal is assumed to be after all other specified siblings.</returns> internal int GetOrdinal(OutputItemType itemType, Type type) { int temp; if (!this.inputOrderMap.TryGetValue(itemType + ":" + type.ToString(), out temp)) { // Assume any order is valid for the remaining elements. temp = this.inputOrderMap.Count; } return temp; }
/// <summary> /// Makes a key used to work with the ordinal dictionary. /// </summary> /// <param name="itemType">The output type of the element.</param> /// <param name="type">The type of the element.</param> /// <returns>A value to use as a key in the ordinal dictionary.</returns> private static string MakeKey(OutputItemType itemType, Type type) { return(string.Join(":", itemType, type)); }