private static ConstInfo GetInfo(string name, MemberAccess access, Expression value, bool isSealed, XMLBlock xml, ParsingInfo parsingInfo, ConstDef constDef) { string summary = string.Empty; if (xml != null) { string str = xml.GetStringContent(); if (str.Length > 0 && str[0] != '<') { summary = str; } else { str = "<root>" + str + "</root>"; XmlDocument doc = new XmlDocument(); try { doc.LoadXml(str); foreach (XmlNode n in doc.ChildNodes[0].ChildNodes) { if (n.Name == "summary") { summary = n.InnerText; } } } catch { summary = "Could not parse XML."; } } } return(new ConstInfo(parsingInfo.SF, name, value.ToString().Replace("\r", "").Replace("\n", ""), value, access, summary, isSealed, constDef)); }
private static FuncInfo GetInfo(string name, MemberAccess access, List <FuncDefParam> defParams, XMLBlock xml, ParsingInfo parsingInfo, FuncDef funcDef) { string summary = string.Empty; string returns = string.Empty; string self = string.Empty; string example = string.Empty; List <FuncParamInfo> xmlParams = new List <FuncParamInfo>(); if (xml != null) { string str = xml.GetStringContent(); if (str.Length > 0 && str[0] != '<') { summary = str; } else { str = "<root>" + str + "</root>"; XmlDocument doc = new XmlDocument(); try { doc.LoadXml(str); foreach (XmlNode n in doc.ChildNodes[0].ChildNodes) { XmlElement e = (XmlElement)n; if (e.Name == "summary") { summary = e.InnerText.Trim(); } else if (e.Name == "returns") { returns = e.InnerText.Trim(); } else if (e.Name == "self") { self = e.InnerText.Trim(); } else if (e.Name == "example") { example = e.InnerText.Trim(); } else if (e.Name == "param") { string paramName = e.GetAttribute("name"); if (!String.IsNullOrEmpty(paramName)) { FuncDefParam defParam = defParams.Find(a => a.Name.EqualCode(paramName)); xmlParams.Add(new FuncParamInfo(paramName, e.InnerText.Trim(), false, defParam.Optional)); } } } } catch { summary = "Could not parse XML."; } } } FuncInfo funcInfo = new FuncInfo(parsingInfo.SF, name, access, summary, returns, self, example, funcDef); bool anyOptional = false; foreach (FuncDefParam param in defParams) { if (param.Optional) { anyOptional = true; } FuncParamInfo paramInfo = xmlParams.Find(a => a.Name.EqualCode(param.Name)); if (paramInfo == null) { paramInfo = new FuncParamInfo(param.Name, "", false, anyOptional); } else { paramInfo.IsOpt = anyOptional; // update in FuncParamInfos from XML } funcInfo.AddParam(paramInfo); } return(funcInfo); }