void AddSingle(CorePlus.Json.JsonObject obj, string key, object value) { if (value is string) { obj.Add(key, (string)value); } else if (value is bool) { obj.Add(key, (bool)value); } else if (value is TypeSummary) { var t = new JsonObject(); var v = (TypeSummary)value; t.Add("type", v.Type); t.Add("summary", v.Summary); obj[key] = t; }else if(value is ArrayProxy<string>){ var t = new JsonArray(); foreach (string v in (ArrayProxy<string>)value) { t.Add(v); } obj[key] = t; } else if (value is ArrayProxy<TypeSummary>) { var ta = new JsonArray(); foreach (TypeSummary v in (ArrayProxy<TypeSummary>)value) { var t = new JsonObject(); t.Add("type", v.Type); t.Add("summary", v.Summary); ta.Add(t); } obj[key] = ta; } else if(value is ParamInfoCollection) { var ta = new JsonArray(); foreach(ParamInfo v in (ParamInfoCollection)value) { var t = new JsonObject(); t.Add("type", v.Type); t.Add("name", v.Name); if(v.DefaultValue != null) t.Add("defaultValue", v.DefaultValue); t.Add("summary", v.Summary); ta.Add(t); } obj["params"] = ta; } else { obj.Add(key, value.ToString()); } }
void SaveClassInfo(DocComment dc, CorePlus.Json.JsonObject obj) { string fullName = dc.FullName; obj.Add("fullName",fullName); obj.Add("source", dc.Source); if(dc.Source != null) { obj.Add("sourceFile", "data/source/" + dc.Source + ".html#" + fullName.Replace('.', '-')); } SortedList<string, DocComment> members = new SortedList<string,DocComment>(); SortedList<string, DocComment> statics = new SortedList<string, DocComment>(); if (dc.MemberType == "class" && dc.Variant.Members != null) { GetMembersAndCopyToTmpList(dc.Variant.Members, members, statics); } // 如果有成员。生成成员字段。 if(dc.Variant.Count > 0) { GetMembersAndCopyToTmpList(dc.Variant, members, statics); } if (_project.DefaultExtends != null && dc.MemberType == "class") { DocComment dc2 ; if (_data.DocComments.TryGetValue(_project.DefaultExtends, out dc2) && dc2.Variant != null) { GetMembersAndCopyToTmpList(dc2.Variant, members, statics); } } DocComment e; if(dc.Extends != null && _data.DocComments.TryGetValue(dc.Extends, out e)) { string extends = dc.Extends; if (e.Variant.Members != null) { GetMembersAndCopyToTmpList(e.Variant.Members, members, statics); } JsonArray baseClasses = new JsonArray(); obj["baseClasses"] = baseClasses; while (extends != null && _data.DocComments.TryGetValue(extends, out e)) { baseClasses.Insert(0, extends); extends = e.Extends; } } if(dc.Implements != null) { foreach(string im in dc.Implements) { if(_data.DocComments.TryGetValue(im, out e)) GetMembersAndCopyToTmpList(e.Variant, members, members); } } string memberOf = dc.FullName; SaveTmpList(members, obj, memberOf, false); SaveTmpList(statics, obj, memberOf, true); if(_extendsInfo.ContainsKey(fullName)) { JsonArray subClasses = new JsonArray(); obj["subClasses"] = subClasses; var list = _extendsInfo[fullName]; list.Sort(); subClasses.AddRange(list); } foreach(string key in dc){ AddSingle(obj, key, dc[key]); } }
void SaveSimpleComment(DocComment dc, CorePlus.Json.JsonObject obj) { obj.Add("type", dc.MemberType); obj.Add("icon", GetIcon(dc)); }
void GenerateAPISignle(CorePlus.Json.JsonObject dom, Variant value) { // 如果有子成员。 if(value.Count > 0){ CorePlus.Json.JsonObject parent = new JsonObject(); dom.Add(value.DocComment.Name, parent); foreach(var vk in value) { GenerateAPISignle(parent, vk.Value); } } else { dom.Add(value.DocComment.Name, 0); } }