private void ToString( String indent, Object obj, ToStringHelperFunc func ) { // First add the indent // func( obj, indent ); // Add in the opening bracket and the tag. func( obj, "<" ); switch (m_type) { case SecurityElementType.Format: func( obj, "?" ); break; case SecurityElementType.Comment: func( obj, "!" ); break; default: break; } func( obj, m_strTag ); // If there are any attributes, plop those in. if (m_lAttributes != null && m_lAttributes.Count > 0) { func( obj, " " ); int iMax = m_lAttributes.Count; Debug.Assert( iMax % 2 == 0, "Odd number of strings means the attr/value pairs were not added correctly" ); for (int i = 0; i < iMax; i += 2) { String strAttrName = (String)m_lAttributes[i]; String strAttrValue = (String)m_lAttributes[i+1]; func( obj, strAttrName ); func( obj, "=\"" ); func( obj, strAttrValue ); func( obj, "\"" ); if (i != m_lAttributes.Count - 2) { if (m_type == SecurityElementType.Regular) { func( obj, Environment.NewLine ); } else { func( obj, " " ); } } } } if (m_strText == null && (m_lChildren == null || m_lChildren.Count == 0)) { // If we are a single tag with no children, just add the end of tag text. switch (m_type) { case SecurityElementType.Comment: func( obj, ">" ); break; case SecurityElementType.Format: func( obj, " ?>" ); break; default: func( obj, "/>" ); break; } func( obj, Environment.NewLine ); } else { // Close the current tag. func( obj, ">" ); // Output the text func( obj, m_strText ); // Output any children. if (m_lChildren != null) { this.ConvertSecurityElementFactories(); func( obj, Environment.NewLine ); // String childIndent = indent + s_strIndent; for (int i = 0; i < m_lChildren.Count; ++i) { ((SecurityElement)m_lChildren[i]).ToString( "", obj, func ); } // In the case where we have children, the close tag will not be on the same line as the // opening tag, so we need to indent. // func( obj, indent ); } // Output the closing tag func( obj, "</" ); func( obj, m_strTag ); func( obj, ">" ); func( obj, Environment.NewLine ); } }
private void ToString(string indent, object obj, ToStringHelperFunc func) { func(obj, "<"); switch (this.m_type) { case SecurityElementType.Format: func(obj, "?"); break; case SecurityElementType.Comment: func(obj, "!"); break; } func(obj, this.m_strTag); if ((this.m_lAttributes != null) && (this.m_lAttributes.Count > 0)) { func(obj, " "); int count = this.m_lAttributes.Count; for (int i = 0; i < count; i += 2) { string str = (string)this.m_lAttributes[i]; string str2 = (string)this.m_lAttributes[i + 1]; func(obj, str); func(obj, "=\""); func(obj, str2); func(obj, "\""); if (i != (this.m_lAttributes.Count - 2)) { if (this.m_type == SecurityElementType.Regular) { func(obj, Environment.NewLine); } else { func(obj, " "); } } } } if ((this.m_strText != null) || ((this.m_lChildren != null) && (this.m_lChildren.Count != 0))) { func(obj, ">"); func(obj, this.m_strText); if (this.m_lChildren != null) { this.ConvertSecurityElementFactories(); func(obj, Environment.NewLine); for (int j = 0; j < this.m_lChildren.Count; j++) { ((SecurityElement)this.m_lChildren[j]).ToString("", obj, func); } } func(obj, "</"); func(obj, this.m_strTag); func(obj, ">"); func(obj, Environment.NewLine); } else { switch (this.m_type) { case SecurityElementType.Format: func(obj, " ?>"); break; case SecurityElementType.Comment: func(obj, ">"); break; default: func(obj, "/>"); break; } func(obj, Environment.NewLine); } }
private void ToString(String indent, Object obj, ToStringHelperFunc func) { // First add the indent // func( obj, indent ); // Add in the opening bracket and the tag. func(obj, "<"); switch (m_type) { case SecurityElementType.Format: func(obj, "?"); break; case SecurityElementType.Comment: func(obj, "!"); break; default: break; } func(obj, m_strTag); // If there are any attributes, plop those in. if (m_lAttributes != null && m_lAttributes.Count > 0) { func(obj, " "); int iMax = m_lAttributes.Count; BCLDebug.Assert(iMax % 2 == 0, "Odd number of strings means the attr/value pairs were not added correctly"); for (int i = 0; i < iMax; i += 2) { String strAttrName = (String)m_lAttributes[i]; String strAttrValue = (String)m_lAttributes[i + 1]; func(obj, strAttrName); func(obj, "=\""); func(obj, strAttrValue); func(obj, "\""); if (i != m_lAttributes.Count - 2) { if (m_type == SecurityElementType.Regular) { func(obj, Environment.NewLine); } else { func(obj, " "); } } } } if (m_strText == null && (m_lChildren == null || m_lChildren.Count == 0)) { // If we are a single tag with no children, just add the end of tag text. switch (m_type) { case SecurityElementType.Comment: func(obj, ">"); break; case SecurityElementType.Format: func(obj, " ?>"); break; default: func(obj, "/>"); break; } func(obj, Environment.NewLine); } else { // Close the current tag. func(obj, ">"); // Output the text func(obj, m_strText); // Output any children. if (m_lChildren != null) { this.ConvertSecurityElementFactories(); func(obj, Environment.NewLine); // String childIndent = indent + s_strIndent; for (int i = 0; i < m_lChildren.Count; ++i) { ((SecurityElement)m_lChildren[i]).ToString("", obj, func); } // In the case where we have children, the close tag will not be on the same line as the // opening tag, so we need to indent. // func( obj, indent ); } // Output the closing tag func(obj, "</"); func(obj, m_strTag); func(obj, ">"); func(obj, Environment.NewLine); } }
private void ToString(string indent, object obj, ToStringHelperFunc func) { func(obj, "<"); switch (this.m_type) { case SecurityElementType.Format: func(obj, "?"); break; case SecurityElementType.Comment: func(obj, "!"); break; } func(obj, this.m_strTag); if ((this.m_lAttributes != null) && (this.m_lAttributes.Count > 0)) { func(obj, " "); int count = this.m_lAttributes.Count; for (int i = 0; i < count; i += 2) { string str = (string) this.m_lAttributes[i]; string str2 = (string) this.m_lAttributes[i + 1]; func(obj, str); func(obj, "=\""); func(obj, str2); func(obj, "\""); if (i != (this.m_lAttributes.Count - 2)) { if (this.m_type == SecurityElementType.Regular) { func(obj, Environment.NewLine); } else { func(obj, " "); } } } } if ((this.m_strText != null) || ((this.m_lChildren != null) && (this.m_lChildren.Count != 0))) { func(obj, ">"); func(obj, this.m_strText); if (this.m_lChildren != null) { this.ConvertSecurityElementFactories(); func(obj, Environment.NewLine); for (int j = 0; j < this.m_lChildren.Count; j++) { ((SecurityElement) this.m_lChildren[j]).ToString("", obj, func); } } func(obj, "</"); func(obj, this.m_strTag); func(obj, ">"); func(obj, Environment.NewLine); } else { switch (this.m_type) { case SecurityElementType.Format: func(obj, " ?>"); break; case SecurityElementType.Comment: func(obj, ">"); break; default: func(obj, "/>"); break; } func(obj, Environment.NewLine); } }