summaryrefslogtreecommitdiffstats
path: root/tools/Sandcastle/Source/BuildAssembler/BuildComponents/Targets.cs
blob: 656da1346629310dd12935caf8a4d3968f23c9f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Copyright © Microsoft Corporation.
// This source file is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

using System;
using System.Collections.Generic;
using System.Text;

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

namespace BuildComponents {

    public partial class Target {

        internal string id;

        public string Id {
            get {
                return (id);
            }
        }
    }

    // Namespace

    public partial class NamespaceTarget : Target {

        internal string name;

        public string Name {
            get {
                return (name);
            }
        }

    }

    // Type

    public partial class TypeTarget : Target {

        // apidata

        protected string subgroup;

        // containers

        protected NamespaceReference containingNamespace;

        protected SimpleTypeReference containingType;

        protected string containingAssembly;

        // other

        public NamespaceReference Namespace {
            get {
                return (containingNamespace);
            }
        }

        public SimpleTypeReference OuterType {
            get {
                return (containingType);
            }
        }

    }

    // Construction of targets from Xml

    public partial class Target {

        public static Target Create (XmlReader api) {

            string id = api.GetAttribute("id");

            Target target = null;
            api.ReadToFollowing("apidata");
            string group = api.GetAttribute("group");
            switch (group) {
                case "namespace":
                    target = NamespaceTarget.Create(api);
                break;
            }

            target.id = id;

            return (target);
        }

        protected static XPathExpression apiNameExpression = XPathExpression.Compile("string(apidata/@name)");


    }

    public partial class NamespaceTarget {

        public static new NamespaceTarget Create (XmlReader apidata) {
            NamespaceTarget target = new NamespaceTarget();
            string name = apidata.GetAttribute("name");

            // This is not locale-independent.
            if (String.IsNullOrEmpty(target.name)) name = "(Default Namespace)";

            target.name = name;

            return (target);
        }

        public static NamespaceTarget Create (XPathNavigator api) {

            NamespaceTarget target = new NamespaceTarget();
            target.name = (string)api.Evaluate(apiNameExpression);

            // This is not locale-independent.
            if (String.IsNullOrEmpty(target.name)) target.name = "(Default Namespace)";

            return (target);
        }

    }


    public partial class TypeTarget {

        public static new TypeTarget Create (XmlReader api) {

            api.ReadToFollowing("apidata");
            //string subgroup = api.GetAttribute("subgroup");

            api.ReadToFollowing("typedata");
            //string visibilityValue = api.GetAttribute("visibility");
            //string abstractValue = api.GetAttribute("abstract");
            //string sealedValue = api.GetAttribute("sealed");
            //string serializableValue = api.GetAttribute("serealizable");

            api.ReadToFollowing("library");
            string containingAssemblyValue = api.GetAttribute("assembly");

            api.ReadToFollowing("namespace");
            NamespaceReference containingNamespace = NamespaceReference.Create(api);

            TypeTarget target = new TypeTarget();
            target.containingAssembly = containingAssemblyValue;
            target.containingNamespace = containingNamespace;

            return (target);

        }
 
    }

}