Beispiel #1
0
 public AssemblyViewModel(DocumentedAssembly assembly)
 {
     _name = assembly.Name;
     _namespaces = new List<DocumentedNamespace>(assembly.Namespaces.Where(ns => ns.HasContent));
 }
Beispiel #2
0
        private static DocumentedAssembly MapAssembly(IAssemblyInfo assembly, XmlDocumentationModel model)
        {
            var types = new List <DocumentedType>();

            // Iterate all types in assembly.
            foreach (var type in assembly.Types)
            {
                var documentedType = MapType(type, model);
                types.Add(documentedType);

                // Add a reference to the type for every constructor.
                foreach (var constructor in documentedType.Constructors)
                {
                    constructor.Type = documentedType;
                }

                // Add a reference to the type for every method.
                foreach (var method in documentedType.Methods)
                {
                    method.Type = documentedType;
                }

                // Add a reference to the type for every method.
                foreach (var @operator in documentedType.Operators)
                {
                    @operator.Type = documentedType;
                }

                // Add a reference to the type for every property.
                foreach (var property in documentedType.Properties)
                {
                    property.Type = documentedType;
                }

                // Add a reference to the type for every method.
                foreach (var field in documentedType.Fields)
                {
                    field.Type = documentedType;
                }
            }

            // Now group all the types in this assembly by their namespace.
            var namespaces      = new List <DocumentedNamespace>();
            var namespaceGroups = types.GroupBy(x => x.Definition.Namespace);

            foreach (var namespaceGroup in namespaceGroups)
            {
                var namespaceTypes = namespaceGroup.ToList();

                // Do we have a documentation for this namespace?
                var documentation = namespaceGroup.FirstOrDefault(x => x.Definition.Name.EndsWith("NamespaceDoc"));
                var summary       = documentation?.Summary;
                if (documentation != null)
                {
                    namespaceTypes.Remove(documentation);
                }

                // Create a namespace for each grouping.
                var @namespace = new DocumentedNamespace(namespaceGroup.Key, namespaceGroup.Key, namespaceTypes, summary, assembly.Metadata);
                namespaces.Add(@namespace);

                // Connect the types in this namespace to the namespace.
                foreach (var documentedType in namespaceGroup)
                {
                    documentedType.Namespace = @namespace;
                }
            }

            // Create an documented assembly out of it.
            var documentedAssembly = new DocumentedAssembly(assembly, namespaces, assembly.Metadata);

            // Add the documented assembly as a parent of all namespaces.
            foreach (var @namespace in namespaces)
            {
                @namespace.Assembly = documentedAssembly;
            }

            // Return the documented assembly.
            return(documentedAssembly);
        }
        private static DocumentedAssembly MapAssembly(IAssemblyInfo assembly, XmlDocumentationModel model)
        {
            var types = new List<DocumentedType>();

            // Iterate all types in assembly.
            foreach (var type in assembly.Types)
            {
                var documentedType = MapType(type, model);
                types.Add(documentedType);

                // Add a reference to the type for every constructor.
                foreach (var constructor in documentedType.Constructors)
                {
                    constructor.Type = documentedType;
                }

                // Add a reference to the type for every method.
                foreach (var method in documentedType.Methods)
                {
                    method.Type = documentedType;
                }

                // Add a reference to the type for every method.
                foreach (var @operator in documentedType.Operators)
                {
                    @operator.Type = documentedType;
                }

                // Add a reference to the type for every property.
                foreach (var property in documentedType.Properties)
                {
                    property.Type = documentedType;
                }

                // Add a reference to the type for every method.
                foreach (var field in documentedType.Fields)
                {
                    field.Type = documentedType;
                }
            }

            // Now group all the types in this assembly by their namespace.
            var namespaces = new List<DocumentedNamespace>();
            var namespaceGroups = types.GroupBy(x => x.Definition.Namespace);
            foreach (var namespaceGroup in namespaceGroups)
            {
                var namespaceTypes = namespaceGroup.ToList();

                // Do we have a documentation for this namespace?
                var documentation = namespaceGroup.FirstOrDefault(x => x.Definition.Name.EndsWith("NamespaceDoc"));
                var summary = documentation != null ? documentation.Summary : null;
                if (documentation != null)
                {
                    namespaceTypes.Remove(documentation);
                }

                // Create a namespace for each grouping.
                var @namespace = new DocumentedNamespace(namespaceGroup.Key, namespaceGroup.Key, namespaceTypes, summary, assembly.Metadata);
                namespaces.Add(@namespace);

                // Connect the types in this namespace to the namespace.
                foreach (var documentedType in namespaceGroup)
                {
                    documentedType.Namespace = @namespace;
                }
            }

            // Create an documented assembly out of it.
            var documentedAssembly = new DocumentedAssembly(assembly, namespaces, assembly.Metadata);

            // Add the documented assembly as a parent of all namespaces.
            foreach (var @namespace in namespaces)
            {
                @namespace.Assembly = documentedAssembly;
            }

            // Return the documented assembly.
            return documentedAssembly;
        }
Beispiel #4
0
 public static IHtmlString AssemblyName(this ApiServices context, DocumentedAssembly assembly)
 {
     return MvcHtmlString.Create(assembly.Name);
 }