~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/Tools/Help/source/ItemClasses/NamespaceItemClass.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Help 2.0 Registration Utility
 
3
// Copyright (c) 2005 Mathias Simmack. All rights reserved.
 
4
//
 
5
namespace HtmlHelp2Registration.ItemClasses
 
6
{
 
7
        using System;
 
8
        using System.Collections.Generic;
 
9
        using System.Collections.ObjectModel;
 
10
        using System.Globalization;
 
11
        using System.IO;
 
12
        using System.Xml;
 
13
        using System.Xml.XPath;
 
14
        using System.Xml.Serialization;
 
15
        using HtmlHelp2Registration.HelperClasses;
 
16
 
 
17
        public class NamespaceItemClass
 
18
        {
 
19
                private string name;
 
20
                private string description;
 
21
                private string collection;
 
22
                private bool update;
 
23
                private bool merge = true;
 
24
                private bool noremove = true;
 
25
                private List<DocumentItemClass> documents = new List<DocumentItemClass>();
 
26
                private List<FilterItemClass> filters = new List<FilterItemClass>();
 
27
                private List<PluginChildItem> plugins = new List<PluginChildItem>();
 
28
                private ReadOnlyCollection<string> connections = null;
 
29
 
 
30
                public NamespaceItemClass(XPathNavigator rootNode)
 
31
                {
 
32
                        if (rootNode == null)
 
33
                        {
 
34
                                throw new ArgumentNullException("rootNode");
 
35
                        }
 
36
                        
 
37
                        this.name        = XmlHelperClass.GetXmlStringValue(rootNode, "@name");
 
38
                        this.description = XmlHelperClass.GetXmlStringValue(rootNode, "@description");
 
39
                        this.collection  = XmlHelperClass.GetXmlStringValue(rootNode, "@file");
 
40
                        this.update      = XmlHelperClass.GetXmlBoolValue(rootNode, "@update");
 
41
                        this.merge       = XmlHelperClass.GetXmlBoolValue(rootNode, "@merge", true);
 
42
                        this.noremove    = XmlHelperClass.GetXmlBoolValue(rootNode, "@noremove");
 
43
                        this.connections = PluginSearch.FindPluginAsGenericList(this.name);
 
44
 
 
45
                        this.Initialize(rootNode);
 
46
                }
 
47
 
 
48
                void Initialize(XPathNavigator rootNode)
 
49
                {
 
50
                        // get all related documents
 
51
                        XPathNodeIterator files =
 
52
                                rootNode.SelectChildren("file", ApplicationHelpers.Help2NamespaceUri);
 
53
                        while (files.MoveNext())
 
54
                        {
 
55
                                this.documents.Add(new DocumentItemClass(files.Current));
 
56
                        }
 
57
 
 
58
                        // get all related filters
 
59
                        XPathNodeIterator filters =
 
60
                                rootNode.SelectChildren("filter", ApplicationHelpers.Help2NamespaceUri);
 
61
                        while (filters.MoveNext())
 
62
                        {
 
63
                                this.filters.Add(new FilterItemClass(filters.Current));
 
64
                        }
 
65
 
 
66
                        // get all related plugins
 
67
                        XPathNodeIterator p =
 
68
                                rootNode.SelectChildren("plugin", ApplicationHelpers.Help2NamespaceUri);
 
69
                        while (p.MoveNext())
 
70
                        {
 
71
                                XPathNodeIterator child =
 
72
                                        p.Current.SelectChildren("child", ApplicationHelpers.Help2NamespaceUri);
 
73
                                while (child.MoveNext())
 
74
                                {
 
75
                                        this.plugins.Add(new PluginChildItem(child.Current));
 
76
                                }
 
77
                        }
 
78
                }
 
79
 
 
80
                #region Properties
 
81
                public string Name
 
82
                {
 
83
                        get { return this.name; }
 
84
                }
 
85
 
 
86
                public string Description
 
87
                {
 
88
                        get { return this.description; }
 
89
                }
 
90
 
 
91
                public string CollectionLevelFile
 
92
                {
 
93
                        get { return this.collection; }
 
94
                }
 
95
 
 
96
                public bool ForceCreation
 
97
                {
 
98
                        get { return !this.update; }
 
99
                }
 
100
 
 
101
                public bool Merge
 
102
                {
 
103
                        get { return this.merge; }
 
104
                }
 
105
 
 
106
                public bool Remove
 
107
                {
 
108
                        get { return !this.noremove; }
 
109
                }
 
110
 
 
111
                public ReadOnlyCollection<DocumentItemClass> Documents
 
112
                {
 
113
                        get
 
114
                        {
 
115
                                ReadOnlyCollection<DocumentItemClass> roDocuments =
 
116
                                        new ReadOnlyCollection<DocumentItemClass>(this.documents);
 
117
                                return roDocuments;
 
118
                        }
 
119
                }
 
120
 
 
121
                public ReadOnlyCollection<FilterItemClass> Filters
 
122
                {
 
123
                        get
 
124
                        {
 
125
                                ReadOnlyCollection<FilterItemClass> roFilters =
 
126
                                        new ReadOnlyCollection<FilterItemClass>(this.filters);
 
127
                                return roFilters;
 
128
                        }
 
129
                }
 
130
 
 
131
                public ReadOnlyCollection<PluginChildItem> Plugins
 
132
                {
 
133
                        get
 
134
                        {
 
135
                                ReadOnlyCollection<PluginChildItem> roPlugins =
 
136
                                        new ReadOnlyCollection<PluginChildItem>(this.plugins);
 
137
                                return roPlugins;
 
138
                        }
 
139
                }
 
140
 
 
141
                public ReadOnlyCollection<string> ConnectedNamespaces
 
142
                {
 
143
                        get { return this.connections; }
 
144
                }
 
145
                #endregion
 
146
 
 
147
                public override string ToString()
 
148
                {
 
149
                        return string.Format(CultureInfo.InvariantCulture, "[Help 2.0 Namespace; {0}, {1}]", this.name, this.description);
 
150
                }
 
151
        }
 
152
}