public static string GenerateMiddleBlockStart(XmlTag middleBlock) { StringBuilder sb = new StringBuilder(); sb.Append(middleBlock.LSTChildNodes.Count == 0 ? GetMiddleWrapperBegin("100%") + GetMiddleDefaultBlock("100%") + GetMiddleWrapperEnd() : GetMiddleCustomMarkup(middleBlock)); return(sb.ToString()); }
public static string GetBottomBlocks(XmlTag BottomBlock) { StringBuilder sb = new StringBuilder(); sb.Append(BottomBlock.LSTChildNodes.Count == 0 ? GetBottomBlockMarkupDefault() : GetBottomBlockMarkupCustom(BottomBlock)); return(sb.ToString()); }
static string ParseSpotlight(XmlTag placeholder) { StringBuilder sb = new StringBuilder(); string positions = placeholder.InnerHtml; string[] positionsAr = positions.Split(','); double spotWidth = 100 / positionsAr.Length; string width = spotWidth.ToString() + "%"; string minheight = GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT, "200px"); sb.Append("<div id='sfSpotLight' class='sfOuterwrapper sfCurve'><div class='sfContainer sfCurve clearfix'>"); for (int i = 0; i < positionsAr.Length; i++) { string adjustedWidth = width; string style = GetAttributeValueByName(placeholder, XmlAttributeTypes.CSSCLASS); if (i == 0) { style += " sfFirst"; } if (i == positionsAr.Length - 1) { style += " sfLast"; } sb.Append("<div class='sfSpotLight" + style + "' style='width:" + adjustedWidth + ";'><div class='sfWrapper sfCurve'>"); //sb.Append(positionsAr[i]); sb.Append(AppendDroppableArea(positionsAr[i])); sb.Append("</div></div>"); } sb.Append("</div></div>"); return(sb.ToString()); }
public void Load(CustomSpriteBatch spriteBatch, XmlTag xmlSheet, string strTextureFilename) { Debug.Assert(ans_pTexture == null); ans_pSpriteBatch = spriteBatch; ans_strTextureFilename = strTextureFilename; ans_pTexture = ContentRegister.Texture(strTextureFilename); if (xmlSheet.Attributes.ContainsKey("name")) { ans_strName = xmlSheet.Attributes["name"]; } XmlTag[] xmlAnimations; xmlAnimations = xmlSheet.FindTagsByName("anim"); for (int i = 0; i < xmlAnimations.Length; i++) { XmlTag tag = xmlAnimations[i]; Animation anim = new Animation(); anim.ani_pSheet = this; anim.Load(tag); ans_saAnimations.Add(anim); } }
public string GetBottomMarkup(XmlTag section, List <CustomWrapper> lstWrappers, int Mode) { StringBuilder sb = new StringBuilder(); sb.Append(BlockBuilder.GetBottomBlocks(section, lstWrappers, Mode)); return(sb.ToString()); }
public static string GetBottomBlockMarkupCustom(XmlTag section) { StringBuilder sb = new StringBuilder(); foreach (XmlTag placeholder in section.LSTChildNodes) { if (IsCustomBlockDefined(placeholder)) { sb.Append(ParseCustomBlocks(placeholder)); } else { if (IsSpotLight(placeholder)) { sb.Append(ParseSpotlight(placeholder)); } else { string id = "sf" + UppercaseFirst(GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME)); sb.Append("<div id='" + id + "' class='sfOuterwrapper sfCurve'>"); sb.Append(GetCommonWrapper(placeholder.InnerHtml)); sb.Append("</div>"); } } } return(sb.ToString()); }
public string GetSectionMarkup(string name, XmlTag section, List <CustomWrapper> lstWrapper, int Mode) { string html = ""; if (Enum.IsDefined(typeof(SectionTypes), name.ToUpper())) { SectionTypes _type = (SectionTypes)Enum.Parse(typeof(SectionTypes), name.ToUpper()); try { switch (_type) { case SectionTypes.TOP: html = GetTopMarkup(section, lstWrapper, Mode); break; case SectionTypes.MIDDLE: html = GetMiddleWrapper(section, lstWrapper, Mode); break; case SectionTypes.BOTTOM: html = GetBottomMarkup(section, lstWrapper, Mode); break; } } catch (Exception ex) { throw ex; } } return(html); }
private void UnitConnectionsDynamic(XmlTag tag, WorldScript ws, string name) { if (tag == null) { return; } var ids = tag.Value.Split(' '); if (ids == null) { return; } var arr = new OldUnitID[ids.Length / 2]; for (int i = 0; i * 2 < ids.Length; i++) { int n = i * 2; arr[i] = new OldUnitID(int.Parse(ids[n])); m_oldIDs.Add(arr[i]); //NOTE: We don't need to store [n+1], since it's always 0! Debug.Assert(ids[n + 1] == "0"); } ws.m_params.Add("#" + name, arr); }
public string GetSectionMarkup(string name, XmlTag section) { string html = ""; if (Enum.IsDefined(typeof(SectionTypes), name.ToUpper())) { SectionTypes _type = (SectionTypes)Enum.Parse(typeof(SectionTypes), name.ToUpper()); switch (_type) { case SectionTypes.SFHEADER: html = GetTopMarkup(section); break; case SectionTypes.SFCONTENT: html = GetMiddleWrapper(section); break; case SectionTypes.SFFOOTER: html = GetBottomMarkup(section); break; } } return(html); }
public string GeneratePlaceHolderMarkup(XmlTag Section) { foreach (XmlTag tag in Section.LSTChildNodes) { } return(""); }
public string GetBottomMarkup(XmlTag section) { StringBuilder sb = new StringBuilder(); sb.Append(LayoutControlBuilder.GetBottomBlocks(section)); return(sb.ToString()); }
public void LoadActors(XmlTag actorsDict) { foreach (var item in actorsDict.Children) { if (item.Name != "array") { continue; } var type = item.Attributes["name"]; foreach (var actor in item.Children) { if (actor.Name != "array") { continue; } var id = int.Parse(actor.Children[0].Value); var pos = actor.Children[1].Value.Split(' '); PrepareUnitType(type); var newActor = new Unit(); newActor.id = m_unitIDCounter++; newActor.id_old = id; float.TryParse(pos[0], out newActor.x); float.TryParse(pos[1], out newActor.y); m_unitTypes[type].m_units.Add(newActor); } } }
/// <summary> ///Obtain starting placeholder. ///1.Check for classes like no-wrap and no-main. ///2.Check for wrap-inner and main-inner classes. ///3.If Wrap-inner is not defined simply create a wrap class and a id from the key. ///4.Check for main inner and other wrappers. ///5.If we are using special markup tags this is the place to begin the markups. ///6.Generate main-inner wrappers if present. /// </summary> /// <param name="placeholder">Object of XmlTag class.</param> /// <returns>String format of placeholder markup.</returns> public static string GeneratePlaceholderStart(XmlTag placeholder) { StringBuilder sb = new StringBuilder(); sb.Append(String.Format("<div id=\"id-{0}\" class=\"sf{1}\">", Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME), Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME))); return(sb.ToString()); }
public string GetMiddleWrapper(XmlTag section, List <CustomWrapper> lstWrappers, int Mode) { StringBuilder sb = new StringBuilder(); string test = HtmlBuilder.GenerateMiddleBlockStart(section, lstWrappers, Mode); sb.Append(test); return(sb.ToString());; }
public string GetMiddleWrapper(XmlTag section) { StringBuilder sb = new StringBuilder(); string test = LayoutControlBuilder.GenerateMiddleBlockStart(section); sb.Append(test); return(sb.ToString());; }
private static void Analyze <TNode>( SyntaxNodeAnalysisContext context, SyntaxList <XmlNodeSyntax> xmlNodes, SeparatedSyntaxList <TNode> nodes, XmlTag tag, Func <SeparatedSyntaxList <TNode>, string, int> indexOf) where TNode : SyntaxNode { XmlNodeSyntax firstElement = null; int firstIndex = -1; for (int i = 0; i < xmlNodes.Count; i++) { XmlElementInfo elementInfo = SyntaxInfo.XmlElementInfo(xmlNodes[i]); if (!elementInfo.Success) { continue; } if (!elementInfo.HasTag(tag)) { firstIndex = -1; continue; } XmlNodeSyntax element = elementInfo.Element; string name = (element.IsKind(SyntaxKind.XmlElement)) ? ((XmlElementSyntax)element).GetAttributeValue("name") : ((XmlEmptyElementSyntax)element).GetAttributeValue("name"); if (name == null) { firstIndex = -1; continue; } int index = indexOf(nodes, name); if (index == -1) { ReportUnusedElement(context, element, i, xmlNodes); } else if (index < firstIndex) { ReportDiagnosticIfNotSuppressed(context, DiagnosticRules.OrderElementsInDocumentationComment, firstElement); return; } else { firstElement = element; } firstIndex = index; } }
private void UnitConnections(XmlTag param, WorldScript ws, string name) { if (param.Children.Count == 0) { return; } UnitConnectionsStatic(param["int-arr[name=static]"], ws, name); UnitConnectionsDynamic(param["int-arr[name=dynamic]"], ws, name); }
/// <summary> /// Build XML tag. /// </summary> /// <param name="tagName">Tag name.</param> /// <param name="type">XML tag types.<see cref="T:SageFrame.Templating.xmlparser.XmlTagTypes"/></param> /// <param name="attType">XML attribute type.<see cref="T:SageFrame.Templating.xmlparser.XmlAttributeTypes"/></param> /// <param name="attName">Attribute name.</param> /// <param name="attValue">Attribute value.</param> /// <param name="innerHTML">Inner HTML.</param> /// <returns>Object of XmlTag class.</returns> public static XmlTag TagBuilder(string tagName, XmlTagTypes type, XmlAttributeTypes attType, string attName, string attValue, string innerHTML) { XmlTag tag = new XmlTag(); tag.TagType = type; tag.TagName = tagName; tag.LSTAttributes = AddAttributes(attName, attValue, attType); tag.InnerHtml = innerHTML; return(tag); }
public void ParseTransportsFromXml(XmlTag transportsTag) { transports = ( from transport in transportsTag.Elements() .Where(tag => tag.Name != "clear") select CreateTransport(transport.Name) ).ToList<IMessageTransport>(); }
public void LoadTileData(XmlTag tileDict) { int pos_x = int.Parse(tileDict["int[name=x]"].Value); int pos_y = int.Parse(tileDict["int[name=y]"].Value); var sets = tileDict["array[name=datasets]"]; foreach (var set in sets.Children) { if (set.Name != "dictionary") { continue; } var tagFilename = set["string[name=tileset]"]; string filename = Path.ChangeExtension(tagFilename.Value, "tileset"); int tileSize = 16; // reasons TileSet ts = null; if (m_tilesets.ContainsKey(filename)) { ts = m_tilesets[filename]; } else { ts = new TileSet() { m_set = filename, m_size = tileSize }; m_tilesets[filename] = ts; } var data = set["int-arr[name=data-t]"]; string[] parse = data.Value.Split(' '); int side = (int)Math.Sqrt(parse.Length); Debug.Assert(side == 20); // should always be 20x20 for (int y = 0; y < side; y++) { for (int x = 0; x < side; x++) { ts.m_tiles.Add(new Tile() { m_set = ts, m_originX = pos_x, m_originY = pos_y, m_x = x - side / 2, m_y = y - side / 2, m_i = byte.Parse(parse[y * side + x]) }); } } } }
/// <summary> /// Mode for templating right block. /// </summary> /// <param name="middleBlock">XmlTag class containing xml details.</param> /// <returns>Mode</returns> public static int RightBlockMode(XmlTag middleBlock) { int status = 0; if (Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 1; } else if (Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 2; } else if (Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 3; } else if (Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 4; } else if (Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 5; } else if (!Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 6; } else if (!Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 7; } else if (!Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 8; } else if (!Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 10; } else if (!Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 9; } else if (Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && !Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 11; } else if (!Decide.HasBlock(Placeholders.RIGHTTOP, middleBlock) && Decide.HasBlock(Placeholders.RIGHTBOTTOM, middleBlock) && Decide.HasBlock(Placeholders.RIGHTA, middleBlock) && Decide.HasBlock(Placeholders.RIGHTB, middleBlock)) { status = 12; } return(status); }
/// <summary> /// Obtain block wrapper. /// </summary> /// <param name="pch">Object of XmlTag class.</param> /// <param name="wrapperdepth">List of wrapper depth.</param> /// <returns>String format of block wrapper.</returns> public static string GenerateBlockWrappers(XmlTag pch, ref List <int> wrapperdepth) { StringBuilder sb = new StringBuilder(); int wrapinner = int.Parse(Utils.GetAttributeValueByName(pch, XmlAttributeTypes.WRAPINNER, "1")); int wrapouter = int.Parse(Utils.GetAttributeValueByName(pch, XmlAttributeTypes.WRAPOUTER, "1")); string customclass = Utils.GetAttributeValueByName(pch, XmlAttributeTypes.CLASS); wrapperdepth.Add(wrapouter); wrapperdepth.Add(wrapinner); if (wrapouter != 0) { for (int i = 1; i <= wrapouter; i++) { if (i == 1) { string wrapperclass = wrapouter > 1 ? "sfOuterwrapper" : "sfOuterwrapper clearfix"; wrapperclass = customclass != "" ? string.Format("{0} {1}", wrapperclass, customclass) : wrapperclass; sb.Append(string.Format("<div id='sf{0}' class='{1}'>", Utils.UppercaseFirst(Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME)), wrapperclass)); } else { string wrapperclass = wrapouter == i?string.Format("sfOuterwrapper{0} clearfix", i - 1) : string.Format("sfOuterwrapper{0}", i - 1); wrapperclass = customclass != "" ? string.Format("{0} {1}", wrapperclass, customclass) : wrapperclass; sb.Append(string.Format("<div class='{0}'>", wrapperclass)); } } } else if (wrapouter == 0) { sb.Append(string.Format("<div id='sf{0}'>", Utils.UppercaseFirst(Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME)))); } if (wrapinner != 0) { for (int i = 1; i <= wrapinner; i++) { if (i == 1) { string wrapperclass = wrapinner > 1 ? "sfInnerwrapper" : "sfInnerwrapper clearfix"; sb.Append(string.Format("<div class='{0}'>", wrapperclass)); } else { string wrapperclass = wrapinner == i?string.Format("sfInnerwrapper{0} clearfix", i - 1) : string.Format("sfInnerwrapper{0}", i - 1); sb.Append(string.Format("<div class='{0}'>", wrapperclass)); } } } return(sb.ToString()); }
public static bool IsSpotLight(XmlTag placeholder) { string pchName = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME); bool status = false; if (Utils.CompareStrings(pchName, "spotlight")) { status = true; } return(status); }
public static bool HasBlock(Placeholders pch, XmlTag middleBlock) { bool status = false; status = middleBlock.LSTChildNodes.Exists( delegate(XmlTag tag) { return(Utils.CompareStrings(Utils.GetAttributeValueByName(tag, XmlAttributeTypes.NAME), pch)); } ); return(status); }
/// <summary> /// Obtain inner HTML tag. /// </summary> /// <param name="pch">Placeholders.<see cref="T:SageFrame.Templating.Placeholders"/></param> /// <param name="middleBlock"></param> /// <returns></returns> public static string GetTagInnerHtml(Placeholders pch, XmlTag middleBlock) { XmlTag currentTag = new XmlTag(); currentTag = middleBlock.LSTChildNodes.Find( delegate(XmlTag tag) { return(Utils.CompareStrings(Utils.GetAttributeValueByName(tag, XmlAttributeTypes.NAME), pch)); } ); return(currentTag.InnerHtml); }
public static string GetOrigin(string unitName, XmlTag tag) { if (tag == null) return "0 0"; int offset = UnitYOffset(unitName); if (offset != 0) { var pts = tag.Value.Split(' '); return pts[0] + ' ' + (int.Parse(pts[1]) + offset); } return tag.Value; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Compute a hash code for this object. /// </summary> /// <returns></returns> /// ------------------------------------------------------------------------------------ public override int GetHashCode() { return((StyleName == null ? 0 : StyleName.GetHashCode()) + Context.GetHashCode() + (XmlTag == null ? 0 : XmlTag.GetHashCode()) + (AttrName == null ? 0 : AttrName.GetHashCode()) + (AttrValue == null ? 0 : AttrValue.GetHashCode()) + (AttrName2 == null ? 0 : AttrName2.GetHashCode()) + (AttrValue2 == null ? 0 : AttrValue2.GetHashCode()) + m_fIsCharStyle.GetHashCode() + IsHeading.GetHashCode() + CanEmbed.GetHashCode()); }
public static string GetBottomBlocks(XmlTag BottomBlock, List <CustomWrapper> lstWrappers, int Mode) { StringBuilder sb = new StringBuilder(); try { sb.Append(BottomBlock.LSTChildNodes.Count == 0 ? HtmlBuilder.GetBottomBlockMarkupDefault() : BlockParser.ProcessPlaceholder(BottomBlock, lstWrappers, Mode)); return(sb.ToString()); } catch (Exception ex) { throw ex; } }
public static string GetAttributeValueByName(XmlTag tag, XmlAttributeTypes _type, string defaultValue) { string value = string.Empty; string name = _type.ToString(); LayoutAttribute attr = new LayoutAttribute(); attr = tag.LSTAttributes.Find( delegate(LayoutAttribute attObj) { return(Utils.CompareStrings(attObj.Name, name)); } ); return(attr == null ? defaultValue : attr.Value); }
public static string GeneratePlaceholderStart(XmlTag placeholder) { //1.Check for classes like no-wrap and no-main //2.Check for wrap-inner and main-inner classes //3.If Wrap-inner is not defined simply create a wrap class and a id from the key //4.Check for main inner and other wrappers //5.If we are using special markup tags this is the place to begin the markups //6.Generate main-inner wrappers if present StringBuilder sb = new StringBuilder(); sb.Append(String.Format("<div id=\"id-{0}\" class=\"sf{1}\">", Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME), Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME))); return(sb.ToString()); }
public static string GenerateMiddleBlockStart(XmlTag middleBlock, List <CustomWrapper> lstWrappers, int Mode) { StringBuilder sb = new StringBuilder(); try { sb.Append(middleBlock.LSTChildNodes.Count == 0 ? HtmlBuilder.GetMiddleWrapperBegin("100%") + HtmlBuilder.GetMiddleDefaultBlock("100%", Mode) + HtmlBuilder.GetMiddleWrapperEnd() : BlockBuilder.GetMiddleCustomMarkup(middleBlock, lstWrappers, Mode)); return(sb.ToString()); } catch (Exception ex) { throw ex; } }
/// <summary> /// A simple state machine that goes through the XML (or HTML) code, and builds a list of its Tags. The returned Tag objects /// contain all the informations necessary to calculate the indenting. /// </summary> /// <param name="text">The source code to be parsed</param> /// <returns>The list of the tags that the input source code contains</returns> private List<XmlTag> CreateListOfTags(string text) { List<XmlTag> tags = new List<XmlTag>(); StringBuilder name = new StringBuilder(); int first_line_of_tag = -1; int line_cntr = 0; XmlStates state = XmlStates.text; for (int i = 0; i < text.Length; i++) { switch (state) { case XmlStates.text: if (text[i] == '<') { if (i < text.Length - 1) { if (text[i + 1] == '?' || text[i + 1] == '!') { state = XmlStates.special_tag; } else if (text[i + 1] == '/') { state = XmlStates.end_tag; name.Clear(); first_line_of_tag = line_cntr; } else { state = XmlStates.normal_tag_name; name.Clear(); first_line_of_tag = line_cntr; } } } break; case XmlStates.special_tag: if (text[i] == '>') { state = XmlStates.text; } break; case XmlStates.end_tag: if (text[i] == '>') { state = XmlStates.text; /* when the parsing of an end tag is finished, we have to find the latest starting tag with this name, that is not closed, and not an empty element */ string name_ = name.Remove(0, 1).ToString(); // removing '/' from the beginning of the name bool has_beginning = false; for (int i_list = tags.Count - 1; i_list >= 0; i_list--) { if (tags[i_list].name == name_ && tags[i_list].end_tag_first_line == -1 && !tags[i_list].empty_element) { tags[i_list].end_tag_first_line = first_line_of_tag; tags[i_list].end_tag_last_line = line_cntr; has_beginning = true; break; } /* If I've just closed an opening element with this, then it can't be correctly closed later, and thus I have to mark it as invalid. (for example tipically: "<p> ... <br> </p> - <br>", or "<p>...<p>...") */ if (!tags[i_list].empty_element && tags[i_list].start_tag_first_line != -1 && tags[i_list].end_tag_first_line == -1) { tags[i_list].invalid = true; } } if (!has_beginning) // an end tag doesn't necessarily has a starting tag, it might be for example, that the second half of an XML file is parsed { XmlTag tag = new XmlTag(); tag.end_tag_first_line = first_line_of_tag; tag.end_tag_last_line = line_cntr; tag.name = name_; tags.Add(tag); } name.Clear(); } else if (!Char.IsWhiteSpace(text[i])) // e.g.: </name > - it can still contain whitspaces at the end, but nothing else { name.Append(text[i]); } break; case XmlStates.normal_tag_name: if (text[i] == '>') { state = XmlStates.text; XmlTag tag = new XmlTag(); if (text[i - 1] == '/') { tag.empty_element = true; name = name.Remove(name.Length - 1, 1); // removing '/' from the end } else { tag.empty_element = false; } tag.start_tag_first_line = first_line_of_tag; tag.start_tag_last_line = line_cntr; tag.name = name.ToString(); name.Clear(); tags.Add(tag); } else if (Char.IsWhiteSpace(text[i])) { state = XmlStates.normal_tag_rest; } else { name.Append(text[i]); } break; case XmlStates.normal_tag_rest: if (text[i] == '>') { state = XmlStates.text; XmlTag tag = new XmlTag(); if (text[i - 1] == '/') { tag.empty_element = true; } else { tag.empty_element = false; } tag.start_tag_first_line = first_line_of_tag; tag.start_tag_last_line = line_cntr; tag.name = name.ToString(); name.Clear(); tags.Add(tag); } break; } // this part runs regardless of which state it is in if (text[i] == '\r') { line_cntr++; } } return tags; }