Exemplo n.º 1
0
        private void LoadAssemblyDefAndExport()
        {
            List <DocumentedAssembly> assemblies         = new List <DocumentedAssembly>();
            DocumentedAssembly        documentedAssembly = new DocumentedAssembly(TestFile);

            assemblies.Add(documentedAssembly);

            ExportConfigFile config   = ExportConfigFile.Create(ConfigFile);
            ExportSettings   settings = new ExportSettings();

            settings.PublishDirectory           = string.Empty;
            settings.Settings                   = new DocumentSettings();
            settings.Settings.VisibilityFilters = new List <Visibility> {
                Visibility.Public,
                Visibility.Internal,
                Visibility.InternalProtected,
                Visibility.Protected,
                Visibility.Private
            };

            Document document = new Document(assemblies);

            document.Settings = settings.Settings;
            document.UpdateDocumentMap();

            WebsiteExporter exporter = new WebsiteExporter(document, settings, config);

            exporter.Export();
        }
Exemplo n.º 2
0
        public void GenerateMap_WhenAssemblyHasTypesWithoutNamespace_TypesAreContainedInNoneNamespaceContainer()
        {
            const string TypeName          = "Issue45_TypeWithNoNamespace";
            const string NoneNamespaceName = "NoneNamespaces";

            List <DocumentedAssembly> assemblies         = new List <DocumentedAssembly>();
            DocumentedAssembly        documentedAssembly = new DocumentedAssembly {
                FileName = DocumentationFile
            };
            EntryCreator creator = new EntryCreator();

            assemblies.Add(documentedAssembly);

            GroupedNamespaceDocumentMapper mapper = new GroupedNamespaceDocumentMapper(assemblies, false, creator);

            DocumentMap result = mapper.GenerateMap();

            AssemblyDef assembly = documentedAssembly.LoadedAssembly;

            TypeDef type  = assembly.FindType(string.Empty, TypeName);
            Entry   entry = result.FindById(type.GetGloballyUniqueId());

            Assert.AreSame(type, entry.Item);                               // the type has been mapped
            Assert.AreEqual(NoneNamespaceName, entry.Parent.Parent.SubKey); // is part of the nonenamespace container
        }
        /// <summary>
        /// Removes the assembly with the <paramref name="name"/>.
        /// </summary>
        /// <param name="name">The assembly to remove.</param>
        public void Remove(string name)
        {
            DocumentedAssembly assembly = this._project.GetAssemblies().Find(a => a.Name == name);

            if (assembly != null)
            {
                _project.RemovedAssemblies.Add(assembly.Name);
                HasChanged = true;
            }
        }
        /// <summary>
        /// Removes the assembly with the <paramref name="uniqueId"/>.
        /// </summary>
        /// <param name="uniqueId">The assembly to remove.</param>
        public void Remove(long uniqueId)
        {
            DocumentedAssembly assembly = _project.GetAssemblies().Find(a => a.UniqueId == uniqueId);

            if (assembly != null)
            {
                _project.RemovedAssemblies.Add(assembly.Name);
                HasChanged = true;
            }
        }
Exemplo n.º 5
0
        public IEncodedString AssemblyName(DocumentedAssembly assembly)
        {
            var identity = assembly.Identity;
            var index    = identity.IndexOf(',');

            if (index != -1)
            {
                identity = identity.Substring(0, index);
            }
            identity = string.Concat(identity, ".dll");
            return(new RawString(identity));
        }
        public void AssemblyFirstDocumentMapper_When_Should()
        {
            List <DocumentedAssembly> assemblies = new List <DocumentedAssembly>();
            EntryCreator entryCreator            = new EntryCreator();
            bool         useObservableCollection = false;

            DocumentedAssembly documented = new DocumentedAssembly();

            documented.FileName = "test.dll";
            assemblies.Add(documented);

            AssemblyFirstDocumentMapper mapper = new AssemblyFirstDocumentMapper(assemblies, useObservableCollection, entryCreator);
            DocumentMap map = mapper.GenerateMap();

            Assert.AreEqual(0, entryCreator.Created);
        }
Exemplo n.º 7
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 property.
                foreach (var property in documentedType.Properties)
                {
                    property.Type = documentedType;
                }

                // Add a reference to the type for every method.
                foreach (var method in documentedType.Methods)
                {
                    method.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, namespaceTypes, summary);
                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);

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

            // Return the documented assembly.
            return(documentedAssembly);
        }
Exemplo n.º 8
0
 public AssemblyViewModel(DocumentedAssembly assembly)
 {
     _metadata   = assembly.Metadata;
     _name       = assembly.Name;
     _namespaces = new List <DocumentedNamespace>(assembly.Namespaces.Where(ns => ns.HasContent));
 }
Exemplo n.º 9
0
 public static IHtmlString AssemblyName(this ApiServices context, DocumentedAssembly assembly)
 {
     return(MvcHtmlString.Create(assembly.Name));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Refreshes the specified assemblies documentation in the UI.
 /// </summary>
 /// <param name="documentedAssembly">The assembly whose documentation needs updating.</param>
 /// <remarks>
 /// <para>
 /// When an assembly is refreshed the <see cref="DocumentMapper"/> is used to regenerate the
 /// document map for that assembly.
 /// </para>
 /// <para>
 /// If the assembly was not compiled before the refresh, is has its document map generated
 /// and is then inserted in to the current <see cref="DocumentMap"/>.
 /// </para>
 /// </remarks>
 public void RefreshAssembly(DocumentedAssembly documentedAssembly)
 {
     this.Map = this.Mapper.GenerateMap();
 }