Example #1
0
        public void Write(DoxDocument dox, DoxFormattingContext outputContext)
        {
            var output = outputContext.Output;

            using (var hw = new HtmlTextWriter(output))
            {
                var html = new HtmlBuilder(hw);
                html.div().attCls("dox").att("dox:format", "sql");

                if (dox.DbElement != null)
                {
                    var context = new DatabaseContext
                    {
                        BookName = outputContext.BookName,
                        DbName = dox.DbElement.DbName
                    };

                    if (dox.DbElement.Database != null)
                        WriteDatabaseDocument(dox.DbElement.Database, html, context);

                    else if (dox.DbElement.Table != null)
                        WriteTableDocument(dox.DbElement.Table, html, context);

                    else if (dox.DbElement.View != null)
                        WriteViewDocument(dox.DbElement.View, html, context);

                    else if (dox.DbElement.StoredProcedure != null)
                        WriteStoredProcedureDocument(dox.DbElement.StoredProcedure, html, context);
                }

                html.c(); // dox div
            }
        }
Example #2
0
        public String GetDoxDocumentHtml(String url)
        {
            try
            {
                var index = url.IndexOf('.');
                if (index == -1)
                    throw new InvalidOperationException("Invalid url format!");

                var book = Application.Library.GetBook(url.Substring(0, index));
                var cachedFileName = DextopUtil.MapPath("~/cache/" + url + ".htm");
                foreach (var c in Path.GetInvalidPathChars())
                    cachedFileName = cachedFileName.Replace(c, '-');
                var cacheFileInfo = new FileInfo(cachedFileName);

            #if !DEBUG
                if (cacheFileInfo.Exists && cacheFileInfo.LastWriteTime > book.LastChangeTime)
                    return File.ReadAllText(cacheFileInfo.FullName);
            #endif

                var doxDocument = book.GetDoxDocument(url.Substring(index + 1));

                var formatter = Application.Formatters.CreateDoxFormatter(doxDocument.FormatCode);

                using (var sw = new StringWriter())
                {
                    var outputContext = new DoxFormattingContext
                    {
                        Output = sw,
                        BookName = book.Name
                    };
                    formatter.Write(doxDocument, outputContext);
                    var content = sw.ToString();
                    ThreadPool.QueueUserWorkItem(CacheFile, new CachedFile { FileName = cachedFileName, Content = content });
                    return content;
                }
            }
            catch (DoxDocumentNotFoundException)
            {
                throw new DextopErrorMessageException("Requested document not found on the server!");
            }
            catch (DoxBookNotFoundException)
            {
                throw new DextopErrorMessageException("Requested book not found on the server!");
            }
            catch (DoxFormatterNotFoundException fex)
            {
                throw new DextopErrorMessageException(fex.Message);
            }
            catch (Exception ex)
            {
                throw new DextopErrorMessageException("Exception: {0}", ex.ToString());
            }
        }
Example #3
0
        public void Write(DoxDocument dox, DoxFormattingContext outputContext)
        {
            var output = outputContext.Output;
            using (var hw = new HtmlTextWriter(output))
            {
                var html = new HtmlBuilder(hw);
                html.div().attCls("dox").att("dox:format", "class");

                if (dox.Type != null)
                {
                    html.e("h1");
                    switch (dox.Type.TypeKind)
                    {
                        case TypeKind.CLASS:
                            html.text("class ");
                            break;
                        case TypeKind.ENUM:
                            html.text("enum ");
                            break;
                        case TypeKind.INTERFACE:
                            html.text("interface ");
                            break;
                        case TypeKind.STRUCT:
                            html.text("struct ");
                            break;
                        case TypeKind.DELEGATE:
                            html.text("delegate ");
                            break;
                    }

                    html.text(dox.Type.Name);
                    html.c();//h1;
                    var referenceContext = new ReferenceContext
                    {
                        BookName = outputContext.BookName,
                        Namespace = dox.Type.Namespace
                    };

                    html.e("table");
                    html.tr().td().attCls("label").text("Namespace:").c().td().text(dox.Type.Namespace).c().c();
                    html.tr().td().attCls("label").text("Base:").c().td();
                    if (dox.Type.BaseTypes != null)
                    {
                        bool first = true;
                        foreach (var bt in dox.Type.BaseTypes)
                        {
                            if (first)
                                first = false;
                            else html.text(", ");
                            html.typeName(bt, referenceContext);
                        }
                    }
                    html.c().c();
                    html.c(); //table

                    RenderExtendedSummary(dox.Type, html, referenceContext);

                    #region Fields

                    html.anchor("fields");
                    html.h2("Fields");
                    if (dox.Type.Fields == null || dox.Type.Fields.Count == 0)
                        html.text("This class has no fields.");
                    else
                    {
                        html.table(0, 0).att("width", "100%").attCls("members");
                        html.tableHeader();
                        foreach (var m in dox.Type.Fields.OrderBy(a => a.Name))
                        {
                            html.tr();//.attCls("expandable");
                            //html.td().attCls("micon").e("a").attCls("exi").att("href", "#expand").nbsp().c().c();
                            html.td().attCls("micon").nbsp().c();

                            html.td().member(m, referenceContext);
                            if (m.InitLiteral != null)
                                html.text(" = ").text(m.InitLiteral);
                            //html.div().attCls("details");
                            RenderExtendedSummary(m, html, referenceContext);
                            //html.c(); // details;
                            html.c(); //td
                            html.td().att("width", "10%").typeName(m.DeclaringType, m.DeclaringType + "-" + m.Name, referenceContext).c();
                            html.c(); //tr
                        }
                        html.c(); //table
                    }

                    #endregion Fields

                    #region Properties

                    html.e("a").attCls("properties").c();
                    html.h2("Properties");
                    if (dox.Type.Properties == null || dox.Type.Properties.Count == 0)
                        html.text("This class has no properties.");
                    else
                    {
                        html.table(0, 0).att("width", "100%").attCls("members");
                        html.tableHeader();
                        foreach (var m in dox.Type.Properties.OrderBy(a => a.Name))
                        {
                            html.tr();

                            if (m.Parameters != null) //indexers
                            {
                                html.attCls("expandable");
                                html.td().attCls("micon").e("a").attCls("exi").att("href", "#expand").nbsp().c().c();
                            }
                            else
                                html.td().attCls("micon").nbsp().c();

                            html.td().member(m, referenceContext);
                            if (m.Parameters != null)
                            {
                                html.text("[");
                                RenderParameters(html, m.Parameters, referenceContext);
                                html.text("]");
                            }
                            html.text(" { ");
                            if (m.CanRead) html.text("get; ");
                            if (m.CanWrite) html.text("set; ");
                            html.text("}");
                            RenderExtendedSummary(m, html, referenceContext);

                            if (m.Parameters != null)
                            {
                                html.div().attCls("details");
                                RenderMethodParametersAndReturnsSummary(html, m, referenceContext);
                                html.c(); // details
                            }

                            html.c(); //td
                            html.td().att("width", "10%").typeName(m.DeclaringType, m.DeclaringType + "-" + m.Name, referenceContext).c();
                            html.c(); //tr
                        }
                        html.c();
                    }

                    #endregion Properties

                    #region Methods

                    html.anchor("methods");
                    html.h2("Methods");
                    if (dox.Type.Methods == null || dox.Type.Methods.Count == 0)
                        html.text("This class has no methods.");
                    else
                    {
                        html.table(0, 0).att("width", "100%").attCls("members");
                        html.tableHeader();
                        foreach (var m in dox.Type.Methods.OrderByDescending(a => a.MemberFlag & MemberFlag.CONSTRUCTOR).ThenBy(a => a.Name))
                        {
                            html.tr();
                            if (m.Parameters != null || (m.TypeName != null && m.TypeName != "System.Void" && m.TypeName != "void"))
                            {
                                html.attCls("expandable");
                                html.td().attCls("micon").e("a").attCls("exi").att("href", "#expand").nbsp().c().c();
                            }
                            else
                                html.td().attCls("micon").nbsp().c();

                            html.td().member(m, referenceContext);
                            html.text("(");
                            RenderParameters(html, m.Parameters, referenceContext);
                            html.text(")");
                            RenderExtendedSummary(m, html, referenceContext);
                            html.div().attCls("details");
                            RenderMethodParametersAndReturnsSummary(html, m, referenceContext);
                            html.c(); // details
                            html.c(); //td
                            html.td().att("width", "10%").typeName(m.DeclaringType, m.DeclaringType + "-" + m.Name, referenceContext).c();
                            html.c(); //tr
                        }
                        html.c();
                    }

                    #endregion Methods

                    #region Events

                    html.anchor("events");
                    html.h2("Events");
                    if (dox.Type.Events == null || dox.Type.Events.Count == 0)
                        html.text("This class has no events.");
                    else
                    {
                        html.table(0, 0).att("width", "100%").attCls("members");
                        html.tableHeader();
                        foreach (var m in dox.Type.Events.OrderBy(a => a.Name))
                        {
                            html.tr();//.attCls("expandable");
                            //html.td().attCls("micon").e("a").attCls("exi").att("href", "#expand").nbsp().c().c();
                            html.td().attCls("micon").nbsp().c();

                            html.td().member(m, "event ", referenceContext);

                            //html.div().attCls("details");
                            RenderExtendedSummary(m, html, referenceContext);
                            //html.c(); // details;
                            html.c(); //td
                            html.td().att("width", "10%").typeName(m.DeclaringType, m.DeclaringType + "-" + m.Name, referenceContext).c();
                            html.c(); //tr
                        }
                        html.c(); //table
                    }

                    #endregion Events
                }
                else
                    html.h1(dox.Title);

                //html.div().attCls("footer").text(dox.Title).c();
                html.c(); // dox div
            }
        }
Example #4
0
 public void Write(DoxDocument dox, DoxFormattingContext outputContext)
 {
     outputContext.Output.Write(Text);
 }