Esempio n. 1
0
        private string BlockToString(System.Windows.Documents.Block block)
        {
            if (block == null)
            {
                return(string.Empty);
            }

            switch (block)
            {
            case System.Windows.Documents.List list: {
                var result = string.Empty;

                foreach (var item in list.ListItems)
                {
                    foreach (var itemBlock in item.Blocks)
                    {
                        result += BlockToString(itemBlock);
                    }
                    result += Environment.NewLine;
                }

                return(result);
            }

            case System.Windows.Documents.Paragraph pg: {
                var result = string.Empty;

                foreach (var inline in pg.Inlines)
                {
                    result += RunToString(inline);
                }

                return(result);
            }

            case System.Windows.Documents.Section sec: {
                var result = string.Empty;

                foreach (var secBlock in sec.Blocks)
                {
                    result += BlockToString(secBlock);
                }
                result += Environment.NewLine;

                return(result);
            }

            default: {
                throw new InvalidOperationException($"Block {block.GetType().Name} not implemented.");
            }
            }
        }
Esempio n. 2
0
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                TypeDef definingType = null;
                if (this.typesEvents != null && this.typesEvents.Count > 0)
                {
                    definingType = (TypeDef)this.typesEvents[0].Type;
                }
                if (!this.xmlComments.Exists())
                {
                    this.Blocks.Add(new NoXmlComments(definingType));
                }

                this.Blocks.Add(new Header1(definingType.GetDisplayName(false) + " Events"));

                if (this.typesEvents != null && this.typesEvents.Count > 0)
                {
                    SummaryTable methods = new SummaryTable();

                    var sortedMethods = from method in this.typesEvents
                                        orderby method.Name
                                        where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                        select method;
                    foreach (EventDef currentMethod in sortedMethods)
                    {
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(currentMethod.Name));
                        link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        CRefPath path = new CRefPath(currentMethod);

                        System.Windows.Documents.Block description = this.GetSummaryFor(
                            xmlComments,
                            currentMethod.Type.Assembly,
                            path
                            );

                        methods.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                    }
                    this.Blocks.Add(methods);
                }

                this.IsGenerated = true;
            }
        }
Esempio n. 3
0
        public override void Generate()
        {
            if (!IsGenerated)
            {
                TypeDef definingType = null;
                if (_typesMethods != null && _typesMethods.Count > 0)
                {
                    definingType = _typesMethods[0].Type as TypeDef;
                }

                if (!_xmlComments.Exists())
                {
                    Blocks.Add(new NoXmlComments(definingType));
                }

                Blocks.Add(new Header1(definingType.GetDisplayName(false) + " Methods"));

                if (_typesMethods != null && _typesMethods.Count > 0)
                {
                    SummaryTable methods = new SummaryTable();

                    var sortedMethods = from method in this._typesMethods
                                        where !method.IsConstructor
                                        orderby method.Name
                                        where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                        select method;

                    foreach (MethodDef currentMethod in sortedMethods)
                    {
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(currentMethod.GetDisplayName(false)));
                        link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        CRefPath path = new CRefPath(currentMethod);

                        System.Windows.Documents.Block description = this.GetSummaryFor(_xmlComments,
                                                                                        currentMethod.Assembly,
                                                                                        path
                                                                                        );

                        methods.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                    }
                    Blocks.Add(methods);
                }

                if (definingType != null && definingType.ExtensionMethods.Count > 0)
                {
                    SummaryTable methods = new SummaryTable();

                    var sortedMethods = from method in definingType.ExtensionMethods
                                        where !method.IsConstructor
                                        orderby method.Name
                                        where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                        select method;

                    foreach (MethodDef currentMethod in sortedMethods)
                    {
                        DisplayNameSignitureConvertor      displayNameSig = new DisplayNameSignitureConvertor(currentMethod, false, true, true);
                        System.Windows.Documents.Hyperlink link           = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(displayNameSig.Convert()));
                        link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        CRefPath path = new CRefPath(currentMethod);

                        System.Windows.Documents.Block description = this.GetSummaryFor(_xmlComments,
                                                                                        currentMethod.Assembly,
                                                                                        path
                                                                                        );

                        methods.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                    }
                    Blocks.Add(new Header2("Extension Methods"));
                    Blocks.Add(methods);
                }

                IsGenerated = true;
                // we also no longer need to store a reference to the XML file I think so we can remove it
                _xmlComments  = null;
                _typesMethods = null;
            }
        }