Inheritance: AbstractTypeProvider
        void WriteNamespace(FrameworkVersion version, string namespaceName)
        {
            var writer = new NamespaceWriter(this, version, namespaceName);

            writer.Write();

            foreach (var type in AssemblyWrapper.GetTypesForNamespace(namespaceName))
            {
                WriteType(version, type);
            }
        }
        /// <summary>
        /// Generates the documentation for the artifacts represented by this
        /// manifest, starting at the namespace(s) in the assembly and working
        /// down through the type hierarchy.
        /// </summary>
        public void Generate()
        {
            Trace.WriteLine(String.Format("\tgenerating from {0}/{1}", Options.Platform, Path.GetFileName(AssemblyPath)));

            var namespaceNames = AssemblyWrapper.GetNamespaces();

            var frameworkVersion = FrameworkVersion.FromPlatformFolder(Options.Platform);
            var processed        = 0;

            foreach (var namespaceName in namespaceNames)
            {
                WriteNamespace(frameworkVersion, namespaceName);
                Trace.WriteLine(String.Format("\t\t{0} processed ({1} of {2})", namespaceName, ++processed, namespaceNames.Count()));
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="useAppDomain"></param>
 /// <returns></returns>
 private AssemblyWrapper CreateAssemblyWrapper(string filePath, bool useAppDomain)
 {
     if (useAppDomain)
     {
         var domain  = AppDomain.CreateDomain(filePath);
         var inst    = domain.CreateInstance(this.GetType().Assembly.FullName, typeof(AssemblyWrapper).FullName);
         var wrapper = (AssemblyWrapper)inst.Unwrap();
         wrapper.LoadAssembly(filePath);
         return(wrapper);
     }
     else
     {
         var wrapper = new AssemblyWrapper();
         wrapper.LoadAssembly(filePath);
         return(wrapper);
     }
 }
            public ManifestAssemblyWrapper(string serviceName, string platform, string assemblyPath, bool useNewAppDomain)
            {
                var docId = NDocUtilities.GenerateDocId(serviceName, platform);

                if (useNewAppDomain)
                {
                    Domain = AppDomain.CreateDomain(assemblyPath);
                    var inst = Domain.CreateInstance(this.GetType().Assembly.FullName,
                                                     typeof(AssemblyWrapper).FullName,
                                                     true,
                                                     BindingFlags.CreateInstance | BindingFlags.Public | BindingFlags.Instance,
                                                     null,
                                                     new object[] { docId }, null, null);
                    SdkAssembly = (AssemblyWrapper)inst.Unwrap();
                    SdkAssembly.LoadAssembly(assemblyPath);
                }
                else
                {
                    SdkAssembly = new AssemblyWrapper(docId);
                    SdkAssembly.LoadAssembly(assemblyPath);
                }
            }
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="useAppDomain"></param>
        /// <returns></returns>
        private AssemblyWrapper CreateAssemblyWrapper(string filePath, bool useAppDomain)
        {
            var docId = NDocUtilities.GenerateDocId(ServiceName, Options.Platform);

            if (useAppDomain)
            {
                var domain = AppDomain.CreateDomain(filePath);
                var inst   = domain.CreateInstance(this.GetType().Assembly.FullName,
                                                   typeof(AssemblyWrapper).FullName,
                                                   true,
                                                   BindingFlags.CreateInstance | BindingFlags.Public | BindingFlags.Instance,
                                                   null,
                                                   new object[] { docId }, null, null);
                var wrapper = (AssemblyWrapper)inst.Unwrap();
                wrapper.LoadAssembly(filePath);
                return(wrapper);
            }
            else
            {
                var wrapper = new AssemblyWrapper(docId);
                wrapper.LoadAssembly(filePath);
                return(wrapper);
            }
        }
        public static string TransformDocumentationToHTML(XElement element, string rootNodeName, AssemblyWrapper assemblyWrapper, FrameworkVersion version)
        {
            if (element == null)
                return string.Empty;

            var rootNode = element.XPathSelectElement(rootNodeName);
            if (rootNode == null)
                return string.Empty;

            //var crossRefTags = new[] { "see", "seealso" };
            //foreach (var crossRefTag in crossRefTags)
            //{
            //    var crossRefs = rootNode.Descendants(crossRefTag);
            //    if (crossRefs.Any())
            //    {
            //        foreach (var crossRef in crossRefs)
            //        {
            //            var typeName = BaseWriter.GetCrossReferenceTypeName(crossRef);

            //            string target;
            //            var url = BaseWriter.CrossReferenceTypeToUrl(assemblyWrapper, typeName, version, out target);

            //            var href = url != null ? string.Format("<a href=\"{0}\" {2}>{1}</a>", url, typeName, target) : typeName;
            //            crossRef.ReplaceWith(href);
            //        }
            //    }
            //}

            var reader = rootNode.CreateReader();
            reader.MoveToContent();
            var innerXml = reader.ReadInnerXml();

            var innerText = innerXml;
            innerText = innerText.Replace("<summary>", "<p>");
            innerText = innerText.Replace("</summary>", "</p>");
            innerText = innerText.Replace("<para>", "<p>");
            innerText = innerText.Replace("</para>", "</p>");
            //innerText = innerText.Replace("<code", "<pre class=\"code-sample\">");
            //innerText = innerText.Replace("</code>", "</pre>");

            // scan for <see> and <seealso> cross-reference tags and replace with <a> links with the
            // content - which // can be a cref indication to a typename, or a href.
            var scanIndex = innerText.IndexOf(crossReferenceOpeningTagText, StringComparison.Ordinal);
            while (scanIndex >= 0)
            {
                var attrStart = innerText.IndexOf(innerCrefAttributeText, scanIndex, StringComparison.Ordinal);
                if (attrStart >= 0)
                {
                    int crossRefTagEndIndex;
                    var cref = ExtractCrefAttributeContent(innerText, attrStart, out crossRefTagEndIndex);
                    var replacement = BaseWriter.CreateCrossReferenceTagReplacement(assemblyWrapper, cref, version);

                    var oldCrossRefTag = innerText.Substring(scanIndex, crossRefTagEndIndex - scanIndex);
                    innerText = innerText.Replace(oldCrossRefTag, replacement);

                    scanIndex += replacement.Length;
                }
                else
                {
                    attrStart = innerText.IndexOf(innerHrefAttributeText, scanIndex, StringComparison.Ordinal);
                    if (attrStart >= 0)
                    {
                        int crossRefTagEndIndex;
                        var url = ExtractHrefAttributeContent(innerText, attrStart, out crossRefTagEndIndex);
                        var replacement = string.Format("<a href=\"{0}\">{0}</a>", url);

                        var oldCrossRefTag = innerText.Substring(scanIndex, crossRefTagEndIndex - scanIndex);
                        innerText = innerText.Replace(oldCrossRefTag, replacement);

                        scanIndex += replacement.Length;
                    }
                    else
                        scanIndex++;
                }

                scanIndex = innerText.IndexOf(crossReferenceOpeningTagText, scanIndex, StringComparison.Ordinal);                
            }

            return innerText;
        }
Beispiel #7
0
        public static string TransformDocumentationToHTML(XElement element, string rootNodeName, AssemblyWrapper assemblyWrapper, FrameworkVersion version)
        {
            if (element == null)
            {
                return(string.Empty);
            }

            var rootNode = element.XPathSelectElement(rootNodeName);

            if (rootNode == null)
            {
                return(string.Empty);
            }

            //var crossRefTags = new[] { "see", "seealso" };
            //foreach (var crossRefTag in crossRefTags)
            //{
            //    var crossRefs = rootNode.Descendants(crossRefTag);
            //    if (crossRefs.Any())
            //    {
            //        foreach (var crossRef in crossRefs)
            //        {
            //            var typeName = BaseWriter.GetCrossReferenceTypeName(crossRef);

            //            string target;
            //            var url = BaseWriter.CrossReferenceTypeToUrl(assemblyWrapper, typeName, version, out target);

            //            var href = url != null ? string.Format("<a href=\"{0}\" {2}>{1}</a>", url, typeName, target) : typeName;
            //            crossRef.ReplaceWith(href);
            //        }
            //    }
            //}

            var reader = rootNode.CreateReader();

            reader.MoveToContent();
            var innerXml = reader.ReadInnerXml();

            var innerText = innerXml;

            innerText = innerText.Replace("<summary>", "<p>");
            innerText = innerText.Replace("</summary>", "</p>");
            innerText = innerText.Replace("<para>", "<p>");
            innerText = innerText.Replace("</para>", "</p>");
            //innerText = innerText.Replace("<code", "<pre class=\"code-sample\">");
            //innerText = innerText.Replace("</code>", "</pre>");

            // scan for <see> and <seealso> cross-reference tags and replace with <a> links with the
            // content - which // can be a cref indication to a typename, or a href.
            var scanIndex = innerText.IndexOf(crossReferenceOpeningTagText, StringComparison.Ordinal);

            while (scanIndex >= 0)
            {
                var attrStart = innerText.IndexOf(innerCrefAttributeText, scanIndex, StringComparison.Ordinal);
                if (attrStart >= 0)
                {
                    int crossRefTagEndIndex;
                    var cref        = ExtractCrefAttributeContent(innerText, attrStart, out crossRefTagEndIndex);
                    var replacement = BaseWriter.CreateCrossReferenceTagReplacement(assemblyWrapper, cref, version);

                    var oldCrossRefTag = innerText.Substring(scanIndex, crossRefTagEndIndex - scanIndex);
                    innerText = innerText.Replace(oldCrossRefTag, replacement);

                    scanIndex += replacement.Length;
                }
                else
                {
                    attrStart = innerText.IndexOf(innerHrefAttributeText, scanIndex, StringComparison.Ordinal);
                    if (attrStart >= 0)
                    {
                        int crossRefTagEndIndex;
                        var url         = ExtractHrefAttributeContent(innerText, attrStart, out crossRefTagEndIndex);
                        var replacement = string.Format("<a href=\"{0}\">{0}</a>", url);

                        var oldCrossRefTag = innerText.Substring(scanIndex, crossRefTagEndIndex - scanIndex);
                        innerText = innerText.Replace(oldCrossRefTag, replacement);

                        scanIndex += replacement.Length;
                    }
                    else
                    {
                        scanIndex++;
                    }
                }

                scanIndex = innerText.IndexOf(crossReferenceOpeningTagText, scanIndex, StringComparison.Ordinal);
            }

            return(innerText);
        }
Beispiel #8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="useAppDomain"></param>
 /// <returns></returns>
 private AssemblyWrapper CreateAssemblyWrapper(string filePath, bool useAppDomain)
 {
     var docId = NDocUtilities.GenerateDocId(ServiceName, Options.Platform);
     if (useAppDomain)
     {
         var domain = AppDomain.CreateDomain(filePath);
         var inst = domain.CreateInstance(   this.GetType().Assembly.FullName,
                                             typeof(AssemblyWrapper).FullName, 
                                             true,
                                             BindingFlags.CreateInstance | BindingFlags.Public | BindingFlags.Instance,
                                             null,
                                             new object[] {docId}, null, null);
         var wrapper = (AssemblyWrapper)inst.Unwrap();
         wrapper.LoadAssembly(filePath);
         return wrapper;
     }
     else
     {
         var wrapper = new AssemblyWrapper(docId);
         wrapper.LoadAssembly(filePath);
         return wrapper;
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="useAppDomain"></param>
 /// <returns></returns>
 private AssemblyWrapper CreateAssemblyWrapper(string filePath, bool useAppDomain)
 {
     if (useAppDomain)
     {
         var domain = AppDomain.CreateDomain(filePath);
         var inst = domain.CreateInstance(this.GetType().Assembly.FullName, typeof(AssemblyWrapper).FullName);
         var wrapper = (AssemblyWrapper)inst.Unwrap();
         wrapper.LoadAssembly(filePath);
         return wrapper;
     }
     else
     {
         var wrapper = new AssemblyWrapper();
         wrapper.LoadAssembly(filePath);
         return wrapper;
     }
 }