public static void PropertyToXrefString(this MemberSDPModel memberSDPModel, PageModel pageModel) { if (memberSDPModel == null || memberSDPModel.Members == null) { return; } foreach (var member in memberSDPModel.Members) { member.Parameters = member.Parameters?.Select(p => { return(new Parameter() { Name = p.Name, Type = InterpretXref(pageModel, p.Type) ?? p.Type ?? null, Description = p.Description }); }); if (member.Returns != null) { member.Returns.Type = InterpretXref(pageModel, member.Returns.Type) ?? member.Returns.Type; } if (member.Exceptions != null) { foreach (var subMember in member.Exceptions) { subMember.Type = InterpretXref(pageModel, subMember.Type) ?? subMember.Type; } } } }
private MemberSDPModel AutoMapArticleItemYamlToMemberSDPModel(ArticleItemYaml articleItemYaml) { if (articleItemYaml == null) { return(null); } var memberSDPModel = new MemberSDPModel(); memberSDPModel.FullName = articleItemYaml.FullName.RemoveFromValue("("); memberSDPModel.Name = articleItemYaml.Name; memberSDPModel.NameWithType = articleItemYaml.NameWithType.RemoveFromValue("("); memberSDPModel.Uid = articleItemYaml.Uid; memberSDPModel.Type = articleItemYaml.Type.ToString().ToLower(); memberSDPModel.Package = articleItemYaml.PackageName; memberSDPModel.Members = new List <Member>(); var member = TransferMember(articleItemYaml); if (member != null) { memberSDPModel.Members.Add(member); } return(memberSDPModel); }
public override bool Interpret(PageModel pageModel, BuildContext context) { if (pageModel == null || pageModel.Items == null) { return(false); } var fields = pageModel.Items.Where(item => item.Type == MemberType.Field)?.ToList(); if (fields == null || fields.Count == 0) { return(true); } var tocTracker = context.GetSharedObject(Constants.Constants.ExtendedIdMappings) as ConcurrentDictionary <string, List <TocItemYaml> >; foreach (var field in fields) { string fileName = field.Uid; var memberSDPModel = new MemberSDPModel(); memberSDPModel.FullName = field.FullName; memberSDPModel.Name = field.Name; memberSDPModel.NameWithType = field.NameWithType; memberSDPModel.Uid = field.Uid + "*"; memberSDPModel.Type = field.Type.ToString().ToLower(); memberSDPModel.Package = field.PackageName; memberSDPModel.Members = new List <Member>(); var member = TransferMember(field); if (member != null) { memberSDPModel.Members.Add(member); } memberSDPModel.PropertyToXrefString(pageModel); base.Save(memberSDPModel, memberSDPModel.YamlMime, fileName, memberSDPModel.Type); var tocItem = new List <TocItemYaml>() { new TocItemYaml { Uid = member.Uid, Name = member.Name.RemoveFromValue("("), Type = MemberType.Field.ToString().ToLower() } }; tocTracker.AddOrUpdate(_parentUid, tocItem, (key, oldValue) => { oldValue.AddRange(tocItem); return(oldValue); }); } return(true); }
public override bool Interpret(PageModel pageModel, BuildContext context) { if (pageModel == null || pageModel.Items == null) { return(false); } var constructors = pageModel.Items.Where(item => item.Type == MemberType.Constructor)?.ToList(); if (constructors == null || constructors.Count == 0) { return(true); } var constructorsOverLoading = constructors.Where(item => item != null && item.Overload != null && item.Overload.EndsWith('*'))?.ToList(); if (constructorsOverLoading == null) { return(true); } var tocTracker = context.GetSharedObject(Constants.Constants.ExtendedIdMappings) as ConcurrentDictionary <string, List <TocItemYaml> >; var combinationSDPModel = new MemberSDPModel(); for (var i = 0; i < constructorsOverLoading.Count; i++) { var constructor = constructorsOverLoading[i]; if (i == 0) { combinationSDPModel = new MemberSDPModel(); combinationSDPModel.FullName = constructor.FullName.RemoveFromValue("("); combinationSDPModel.Name = constructor.Name.RemoveFromValue("("); combinationSDPModel.NameWithType = constructor.NameWithType.RemoveFromValue("("); combinationSDPModel.Uid = constructor.Overload; combinationSDPModel.Type = constructor.Type?.ToString().ToLower(); combinationSDPModel.Package = constructor.PackageName; combinationSDPModel.Members = new List <Member>(); } var member = TransferMember(constructor); if (member != null) { combinationSDPModel.Members.Add(member); } if (i == constructors.Count - 1) { combinationSDPModel.PropertyToXrefString(pageModel); var filename = constructor.Overload.Remove(constructor.Overload.Length - 1); base.Save(combinationSDPModel, combinationSDPModel.YamlMime, filename, combinationSDPModel.Type); var tocItem = new List <TocItemYaml>() { new TocItemYaml() { Uid = constructor.Overload, Name = combinationSDPModel.Name.RemoveFromValue("("), Type = MemberType.Constructor.ToString().ToLower() } }; tocTracker.AddOrUpdate(_parentUid, tocItem, (key, oldValue) => { oldValue.AddRange(tocItem); return(oldValue); }); } } var constructorsNoOverLoading = constructors.Where(item => item != null && item.Overload != null && !item.Overload.EndsWith('*'))?.ToList(); if (constructorsNoOverLoading != null) { return(true); } foreach (var constructor in constructorsNoOverLoading) { var memberSDPModel = new MemberSDPModel(); memberSDPModel.FullName = constructor.FullName.RemoveFromValue("("); memberSDPModel.Name = constructor.Name.RemoveFromValue("("); memberSDPModel.NameWithType = constructor.NameWithType.RemoveFromValue("("); memberSDPModel.Uid = constructor.Uid; memberSDPModel.Type = constructor.Type.ToString().ToLower(); memberSDPModel.Package = constructor.PackageName; memberSDPModel.Members = new List <Member>(); var member = TransferMember(constructor); if (member != null) { memberSDPModel.Members.Add(member); } memberSDPModel.PropertyToXrefString(pageModel); base.Save(memberSDPModel, memberSDPModel.YamlMime, memberSDPModel.Uid, memberSDPModel.Type); var tocItem = new List <TocItemYaml>() { new TocItemYaml() { Uid = memberSDPModel.Uid, Name = memberSDPModel.Name.RemoveFromValue("("), Type = MemberType.Constructor.ToString().ToLower() } }; tocTracker.AddOrUpdate(_parentUid, tocItem, (key, oldValue) => { oldValue.AddRange(tocItem); return(oldValue); }); } return(true); }