private bool eatAttr(TextProcessor textProcessor) { // attr1="xxx yyy" attr2 = "yyy" // textProcessor.EatSpace(); if (textProcessor.End()) return false; // string attrValue = null; // string attrName = textProcessor.EatName(); if (string.IsNullOrEmpty(attrName)) return false; textProcessor.EatSpace(); // if (textProcessor.EatChar('=')) { textProcessor.EatSpace(); char valueStartChar = textProcessor.Current(); if ((valueStartChar == '\"') || (valueStartChar == '\'')) { attrValue = textProcessor.EatQuoted(valueStartChar); } else { attrValue = textProcessor.EatNonSpace(); } } // this.Attributes[attrName] = attrValue; // return true; }
private void processOpenTagBody(string text) { TextProcessor textProcessor = new TextProcessor(text); // while (!textProcessor.End()) { if (!this.eatAttr(textProcessor)) break; } }
private Parm eatParm(TextProcessor textProcessor) { // <@parm name = "xxx" type="xxx" description="xxxxxx" /> // textProcessor.EatSpace(); if (textProcessor.End()) return null; // if (!textProcessor.EatString("<@parm ", StringComparison.OrdinalIgnoreCase)) return null; textProcessor.EatSpace(); // Parm result = new Parm(); // while (!textProcessor.EatString("/>")) { NameValue attr = this.eatAttr(textProcessor); if (attr == null) break; // if (string.Equals(attr.Name, "name", StringComparison.OrdinalIgnoreCase)) result.Name = attr.Value; if (string.Equals(attr.Name, "type", StringComparison.OrdinalIgnoreCase)) result.Type = attr.Value; if (string.Equals(attr.Name, "description", StringComparison.OrdinalIgnoreCase)) result.Description = attr.Value; if (string.Equals(attr.Name, "default", StringComparison.OrdinalIgnoreCase)) result.Default = attr.Value; if (string.Equals(attr.Name, "optional", StringComparison.OrdinalIgnoreCase)) result.Optional = !string.Equals(attr.Value, "false", StringComparison.OrdinalIgnoreCase); // textProcessor.EatSpace(); } // return result; }
private NameValue eatAttr(TextProcessor textProcessor) { textProcessor.EatSpace(); if (textProcessor.End()) return null; // string attrValue = null; // string attrName = textProcessor.EatName(); textProcessor.EatSpace(); // if (textProcessor.EatChar('=')) { textProcessor.EatSpace(); char valueStartChar = textProcessor.Current(); if ((valueStartChar == '\"') || (valueStartChar == '\'')) { attrValue = textProcessor.EatQuoted(valueStartChar); } else { attrValue = textProcessor.EatNonSpace(); } } // return new NameValue() { Name = attrName, Value = attrValue }; }
//private string processContent(string content) //{ // if (string.IsNullOrEmpty(content)) return content; // // // StringBuilder sb = new StringBuilder(); // // // TextProcessor textProcessor = new TextProcessor(content); // while (!textProcessor.End()) // { // Parm parm = this.eatParm(textProcessor); // if (parm == null) break; // // // sb.AppendLine(" <tr>"); // sb.AppendLine(" <td class=\"name\"><code>" + parm.Name + "</code></td>"); // sb.AppendLine(" <td class=\"type\"><span class=\"param-type\">" + parm.Type + "</span></td>"); // sb.AppendLine(" <td class=\"description last\"><p>" + parm.Description + "</p></td>"); // sb.AppendLine(" </tr>"); // } // // // return sb.ToString(); //} private List<Parm> calcParmList(string content) { List<Parm> result = new List<Parm>(); // TextProcessor textProcessor = new TextProcessor(content); while (!textProcessor.End()) { Parm parm = this.eatParm(textProcessor); if (parm == null) break; // result.Add(parm); } // return result; }