public bool TryGetReference(string uid, out ReferenceViewModel vm)
 {
     vm = null;
     var entries = GetInternal(uid);
     if (entries == null)
     {
         return false;
     }
     vm = (from entry in entries
           from item in entry.Content
           where item.Uid == uid
           select item).FirstOrDefault();
     return vm != null;
 }
Пример #2
0
        public static ReferenceViewModel FromModel(KeyValuePair <string, ReferenceItem> model)
        {
            Debug.Assert(model.Value != null, "Unexpected reference.");
            var result = new ReferenceViewModel
            {
                Uid        = model.Key,
                Parent     = model.Value.Parent,
                Definition = model.Value.Definition,
                Type       = model.Value.Type,
                Summary    = model.Value.Summary,
            };

            if (model.Value.Parts != null && model.Value.Parts.Count > 0)
            {
                result.Name = GetName(model.Value, SyntaxLanguage.Default, l => l.DisplayName);
                var nameForCSharp = GetName(model.Value, SyntaxLanguage.CSharp, l => l.DisplayName);
                if (result.Name != nameForCSharp)
                {
                    result.NameForCSharp = nameForCSharp;
                }
                var nameForVB = GetName(model.Value, SyntaxLanguage.VB, l => l.DisplayName);
                if (result.Name != nameForVB)
                {
                    result.NameForVB = nameForVB;
                }

                result.FullName = GetName(model.Value, SyntaxLanguage.Default, l => l.DisplayQualifiedNames);
                var fullnameForCSharp = GetName(model.Value, SyntaxLanguage.CSharp, l => l.DisplayQualifiedNames);
                if (result.FullName != fullnameForCSharp)
                {
                    result.FullNameForCSharp = fullnameForCSharp;
                }
                var fullnameForVB = GetName(model.Value, SyntaxLanguage.VB, l => l.DisplayQualifiedNames);
                if (result.FullName != fullnameForVB)
                {
                    result.FullNameForVB = fullnameForVB;
                }

                result.SpecForCSharp = GetSpec(model.Value, SyntaxLanguage.CSharp);
                result.SpecForVB     = GetSpec(model.Value, SyntaxLanguage.VB);
                result.IsExternal    = GetIsExternal(model.Value);
                result.Href          = GetHref(model.Value);
            }
            return(result);
        }
Пример #3
0
        public static ReferenceViewModel FromModel(KeyValuePair<string, ReferenceItem> model)
        {
            Debug.Assert(model.Value != null, "Unexpected reference.");
            var result = new ReferenceViewModel
            {
                Uid = model.Key,
                Parent = model.Value.Parent,
                Definition = model.Value.Definition,
                Type = model.Value.Type,
                Summary = model.Value.Summary,
            };
            if (model.Value.Parts != null && model.Value.Parts.Count > 0)
            {
                result.Name = GetName(model.Value, SyntaxLanguage.Default, l => l.DisplayName);
                var nameForCSharp = GetName(model.Value, SyntaxLanguage.CSharp, l => l.DisplayName);
                if (result.Name != nameForCSharp)
                {
                    result.NameForCSharp = nameForCSharp;
                }
                var nameForVB = GetName(model.Value, SyntaxLanguage.VB, l => l.DisplayName);
                if (result.Name != nameForVB)
                {
                    result.NameForVB = nameForVB;
                }

                result.FullName = GetName(model.Value, SyntaxLanguage.Default, l => l.DisplayQualifiedNames);
                var fullnameForCSharp = GetName(model.Value, SyntaxLanguage.CSharp, l => l.DisplayQualifiedNames);
                if (result.FullName != fullnameForCSharp)
                {
                    result.FullNameForCSharp = fullnameForCSharp;
                }
                var fullnameForVB = GetName(model.Value, SyntaxLanguage.VB, l => l.DisplayQualifiedNames);
                if (result.FullName != fullnameForVB)
                {
                    result.FullNameForVB = fullnameForVB;
                }

                result.SpecForCSharp = GetSpec(model.Value, SyntaxLanguage.CSharp);
                result.SpecForVB = GetSpec(model.Value, SyntaxLanguage.VB);
                result.IsExternal = GetIsExternal(model.Value);
                result.Href = GetHref(model.Value);
            }
            return result;
        }
Пример #4
0
        public static PageViewModel FromModel(MetadataItem model)
        {
            if (model == null)
            {
                return(null);
            }
            var result = new PageViewModel();

            result.Items.Add(ItemViewModel.FromModel(model));
            if (model.Type.AllowMultipleItems())
            {
                AddChildren(model, result);
            }
            foreach (var item in model.References)
            {
                result.References.Add(ReferenceViewModel.FromModel(item));
            }
            return(result);
        }
 private void BuildReference(IHostService host, ReferenceViewModel reference, FileModel model)
 {
     reference.Summary = Markup(host, reference.Summary, model);
 }
Пример #6
0
        private void RebuildReference()
        {
            var references = GetReferences();
            foreach (var model in GetViewModels())
            {
                bool dirty = false;
                // Add references for exceptions
                var types = from i in model.Item2.Items
                            where i.Exceptions != null
                            from e in i.Exceptions
                            select e.Type;
                HashSet<string> set = new HashSet<string>(model.Item2.References.Select(r => r.Uid));
                foreach (var type in types)
                {
                    if (set.Add(type))
                    {
                        ReferenceViewModel reference;
                        if (!references.TryGetValue(type, out reference))
                        {
                            reference = references[type] = new ReferenceViewModel() { Uid = type };
                        }

                        model.Item2.References.Add(reference);
                        dirty = true;
                    }
                }

                if (dirty)
                {
                    Console.WriteLine($"Rebuilding references: {model.Item1}");
                    YamlUtility.Serialize(model.Item1, model.Item2);
                }
            }
        }
Пример #7
0
        private void RebuildReference()
        {
            var references = GetReferences();
            foreach (var model in GetViewModels())
            {
                bool dirty = false;
                // Add references for exceptions
                var types = from i in model.Item2.Items
                            where i.Exceptions != null
                            from e in i.Exceptions
                            select e.Type;
                HashSet<string> set = new HashSet<string>(model.Item2.References.Select(r => r.Uid));
                foreach (var type in types)
                {
                    if (set.Add(type))
                    {
                        ReferenceViewModel reference;
                        if (!references.TryGetValue(type, out reference))
                        {
                            reference = references[type] = new ReferenceViewModel() { Uid = type };
                        }

                        model.Item2.References.Add(reference);
                        dirty = true;
                    }
                }

                // Add summary for classes in namespace
                if (model.Item2.Items[0].Type == MemberType.Namespace)
                {
                    foreach (var reference in model.Item2.References)
                    {
                        if (reference.Type == MemberType.Class || reference.Type == MemberType.Delegate || reference.Type == MemberType.Enum || reference.Type == MemberType.Interface || reference.Type == MemberType.Struct)
                        {
                            ReferenceViewModel refWithSummary;
                            if (references.TryGetValue(reference.Uid, out refWithSummary))
                            {
                                reference.Summary = refWithSummary.Summary;
                                dirty = true;
                            }
                        }
                    }
                }

                if (dirty)
                {
                    Console.WriteLine($"Rebuilding references: {model.Item1}");
                    YamlUtility.Serialize(model.Item1, model.Item2);
                }
            }
        }