Inheritance: BaseDocModel
示例#1
0
        // The user has passed us a type ("System.String"),
        // show the documentation of the type
        // ex: http://localhost/mscorlib.dll/System.String
        private ActionResult Type(TypeModel type)
        {
            // Build the breadcrumb menu
            BreadCrumb bc = new BreadCrumb ();

            bc.Crumbs.Add (new Crumb ("Home", "~", "home"));
            bc.Crumbs.Add (new Crumb (type.Assembly, type.AssemblyUrl, "reference"));
            bc.Crumbs.Add (new Crumb (type.Namespace, type.NamespaceUrl, "namespace"));
            bc.Crumbs.Add (new Crumb (type.Name, null, type.TypeIcon));

            ViewData["BreadCrumb"] = bc;
            ViewData["Title"] = string.Format ("{0} - {1} Type", title, type.Name);

            return View ("Type", type);
        }
示例#2
0
        private void PopulateTypesInNamespace(string assembly, NamespaceModel model)
        {
            string ns_file = Path.Combine (Path.Combine (doc_dir, assembly), "index.xml");

            XmlDocument doc = new XmlDocument ();
            doc.Load (ns_file);

            model.Types.Clear ();

            XmlElement name_space = (XmlElement)doc.SelectSingleNode (string.Format ("Overview/Types/Namespace[@Name='{0}']", model.Name));

            if (name_space == null)
                return;

            foreach (XmlElement xe in name_space.ChildNodes) {
                TypeModel t = new TypeModel ();

                t.Assembly = assembly;
                t.Namespace = model.Name;
                t.Name = xe.GetAttribute ("Name");
                t.Kind = xe.GetAttribute ("Kind");
                t.Summary = GetChildXml (xe, "summary", string.Empty);

                model.Types.Add (t);
            }
        }
示例#3
0
        private void CreateIndex()
        {
            index = new List<AssemblyModel> ();

            foreach (string dir in Directory.GetDirectories (doc_dir)) {
                string index_file = Path.Combine (dir, "index.xml");

                if (!File.Exists (index_file))
                    continue;

                XmlDocument doc = new XmlDocument ();
                doc.Load (index_file);

                AssemblyModel am = new AssemblyModel ();

                am.Name = GetChildText (doc.DocumentElement, "Title", "index.xml does not have <Title>") + ".dll";
                am.Remarks = GetChildText (doc.DocumentElement, "Remarks", "");

                foreach (XmlElement xe in doc.DocumentElement.SelectNodes ("Types/Namespace")) {
                    NamespaceModel ns = new NamespaceModel ();

                    ns.Assembly = am.Name;
                    ns.Name = xe.GetAttribute ("Name");

                    foreach (XmlElement t in xe.SelectNodes ("Type")) {
                        TypeModel tm = new TypeModel ();
                        tm.Assembly = am.Name;
                        tm.Name = t.GetAttribute ("Name");

                        ns.Types.Add (tm);
                    }

                    am.Namespaces.Add (ns);
                }

                index.Add (am);
            }
        }
示例#4
0
        private void PopulateMembersInType(TypeModel model, XmlElement xe)
        {
            model.Members.Clear ();

            string type_name = xe.GetAttribute ("Name");

            foreach (XmlElement x in xe["Members"].ChildNodes) {
                MemberModel m = new MemberModel ();

                m.Assembly = model.Assembly;
                m.Namespace = model.Namespace;
                m.Name = x.GetAttribute ("MemberName");
                m.Type = GetChildXml (x, "MemberType", string.Empty);
                m.ParentType = model.Name;
                m.ReturnType = GetChildText (x, "ReturnValue", string.Empty);
                m.ReturnSummary = GetChildXml (x, "returns", string.Empty);

                // Populate the member signature
                XmlElement sig = (XmlElement)x.SelectSingleNode ("MemberSignature[@Language='C#']");

                if (sig != null) {
                    m.Signature = new Signature (sig);
                    m.Visibility = m.Signature.Visibility;
                }

                // Populate the member parameters
                XmlElement parameters = x["Parameters"];
                XmlElement docs = x["Docs"];

                if (parameters != null)
                    foreach (XmlElement p in parameters.ChildNodes)
                        m.Parameters.Add (new Parameter (p, docs));

                // Populate the documentation
                if (docs != null) {
                    m.Summary = GetChildXml (docs, "summary", string.Empty);
                    m.Remarks = GetChildXml (docs, "remarks", string.Empty);
                }

                // Populate the AssemblyInfo
                XmlElement assem = x["AssemblyInfo"];

                if (assem != null)
                    m.AssemblyInfo = new AssemblyInfo (assem);

                model.Members.Add (m);
            }
        }
示例#5
0
        // Read the information need for TypeModel
        // If !shallow, read in information for all Members
        public override TypeModel ReadType(string assembly, string ns, string type, bool shallow)
        {
            string path = Path.Combine (Path.Combine (doc_dir, assembly), ns);
            string filename = string.Format ("{0}.xml", type);
            string file = Path.Combine (path, filename);

            XmlDocument doc = new XmlDocument ();
            doc.Load (file);

            XmlElement xe = doc.DocumentElement;
            TypeModel model = new TypeModel ();

            model.Assembly = assembly;
            model.Namespace = ns;
            model.Name = xe.GetAttribute ("Name");
            model.BaseType = GetChildXml (xe, "Base", string.Empty);

            // Populate the type signature
            XmlElement sig = (XmlElement)xe.SelectSingleNode ("TypeSignature[@Language='C#']");

            if (sig != null) {
                model.Signature = new Signature (sig);
                model.Kind = model.Signature.TypeKind;
                model.Visibility = model.Signature.Visibility;
            }

            // Populate any interfaces the type implements
            XmlElement interfaces = xe["Interfaces"];

            if (interfaces != null)
                foreach (XmlElement p in interfaces.ChildNodes)
                    model.Interfaces.Add (p.InnerText);

            // Populate the documentation
            XmlElement docs = xe["Docs"];

            if (docs != null) {
                model.Summary = GetChildXml (docs, "summary", string.Empty);
                model.Remarks = GetChildXml (docs, "remarks", string.Empty);
            }

            // Populate the AssemblyInfo
            XmlElement assem = xe["AssemblyInfo"];

            if (assem != null)
                model.AssemblyInfo = new AssemblyInfo (assem);

            if (!shallow)
                PopulateMembersInType (model, xe);

            return model;
        }