ExternalDocumentedFilter.cs :  » Development » Sandcastle » Microsoft » Ddue » Tools » Reflection » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » Sandcastle 
Sandcastle » Microsoft » Ddue » Tools » Reflection » ExternalDocumentedFilter.cs
// Copyright (c) Microsoft Corporation.  All rights reserved.
//

using System;
using System.Xml.XPath;
using System.Compiler;

namespace Microsoft.Ddue.Tools.Reflection{

    // exposes all apis for which documentation is written

    // this includes all visible members except for property and event accessors (e.g. get_ methods) and delegate members (e.g. Invoke).

    // enumeration members are included

    public class ExternalDocumentedFilter : ApiFilter {

        public ExternalDocumentedFilter() : base() { }

        public ExternalDocumentedFilter(XPathNavigator configuration) : base(configuration) { }

        public override bool IsExposedMember(Member member) {
            if (member == null) throw new ArgumentNullException("member");
            // if the member isn't visible, we certainly won't expose it...
            if (!member.IsVisibleOutsideAssembly) return (false);
            // ...but there are also some visible members we won't expose.
            TypeNode type = member.DeclaringType;
            // member of delegates are not exposed
            if (type.NodeType == NodeType.DelegateNode) return (false);
            // accessor methods for properties and events are not exposed
            if (member.IsSpecialName && (member.NodeType == NodeType.Method)) {
                string name = member.Name.Name;
                if (NameContains(name, "get_")) return (false);
                if (NameContains(name, "set_")) return (false);
                if (NameContains(name, "add_")) return (false);
                if (NameContains(name, "remove_")) return (false);
                if (NameContains(name, "raise_")) return (false);
            }

            // the value field of enumerations is not exposed
            if (member.IsSpecialName && (type.NodeType == NodeType.EnumNode) && (member.NodeType == NodeType.Field)) {
                string name = member.Name.Name;
                if (name == "value__") return (false);
            }

            // protected members of sealed types are not exposed
            // change of plan -- yes they are
            // if (type.IsSealed && (member.IsFamily || member.IsFamilyOrAssembly)) return(false);

            // One more test to deal with a case: a private method is an explicit implementation for
            // a property accessor, but is not marked with the special name flag. To find these, test for
            // the accessibility of the methods they implement
            if (member.IsPrivate && member.NodeType == NodeType.Method) {
                Method method = (Method)member;
                MethodList implements = method.ImplementedInterfaceMethods;
                if ((implements.Count > 0) && (!IsExposedMember(implements[0]))) return (false);
            }

            // okay, passed all tests, the member is exposed as long as the filters allow it
            return (base.IsExposedMember(member));
        }

        // we are satistied with the default namespace expose test, so don't override it

        public override bool IsExposedType(TypeNode type) {
            if (type == null) throw new ArgumentNullException("type");
            // expose any visible types allowed by the base filter
            if (type.IsVisibleOutsideAssembly) {
                return (base.IsExposedType(type));
            } else {
                return (false);
            }
            // return(type.IsVisibleOutsideAssembly);
        }

        private static bool NameContains(string name, string substring) {
            return (name.Contains(substring));
        }

    }

}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.