~ubuntu-branches/ubuntu/trusty/mono-addins/trusty-proposed

« back to all changes in this revision

Viewing changes to Mono.Addins/Mono.Addins/AddinInfo.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-04-25 11:11:33 UTC
  • mfrom: (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110425111133-t05u5p7o5fxx70fu
Tags: 0.6-2
Upload to Unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
                bool isroot;
52
52
                DependencyCollection dependencies;
53
53
                DependencyCollection optionalDependencies;
 
54
                AddinPropertyCollection properties;
54
55
                
55
 
                public AddinInfo ()
 
56
                private AddinInfo ()
56
57
                {
57
58
                        dependencies = new DependencyCollection ();
58
59
                        optionalDependencies = new DependencyCollection ();
62
63
                        get { return Addin.GetFullId (namspace, id, version); }
63
64
                }
64
65
                
65
 
                [XmlElement ("Id")]
66
66
                public string LocalId {
67
67
                        get { return id; }
68
68
                        set { id = value; }
80
80
                
81
81
                public string Name {
82
82
                        get {
 
83
                                string s = Properties.GetPropertyValue ("Name");
 
84
                                if (s.Length > 0)
 
85
                                        return s;
83
86
                                if (name != null && name.Length > 0)
84
87
                                        return name;
85
88
                                string sid = id;
101
104
                }
102
105
                
103
106
                public string Author {
104
 
                        get { return author; }
 
107
                        get {
 
108
                                string s = Properties.GetPropertyValue ("Author");
 
109
                                if (s.Length > 0)
 
110
                                        return s;
 
111
                                return author;
 
112
                        }
105
113
                        set { author = value; }
106
114
                }
107
115
                
108
116
                public string Copyright {
109
 
                        get { return copyright; }
 
117
                        get {
 
118
                                string s = Properties.GetPropertyValue ("Copyright");
 
119
                                if (s.Length > 0)
 
120
                                        return s;
 
121
                                return copyright;
 
122
                        }
110
123
                        set { copyright = value; }
111
124
                }
112
125
                
113
126
                public string Url {
114
 
                        get { return url; }
 
127
                        get {
 
128
                                string s = Properties.GetPropertyValue ("Url");
 
129
                                if (s.Length > 0)
 
130
                                        return s;
 
131
                                return url;
 
132
                        }
115
133
                        set { url = value; }
116
134
                }
117
135
                
118
136
                public string Description {
119
 
                        get { return description; }
 
137
                        get {
 
138
                                string s = Properties.GetPropertyValue ("Description");
 
139
                                if (s.Length > 0)
 
140
                                        return s;
 
141
                                return description;
 
142
                        }
120
143
                        set { description = value; }
121
144
                }
122
145
                
123
146
                public string Category {
124
 
                        get { return category; }
 
147
                        get {
 
148
                                string s = Properties.GetPropertyValue ("Category");
 
149
                                if (s.Length > 0)
 
150
                                        return s;
 
151
                                return category;
 
152
                        }
125
153
                        set { category = value; }
126
154
                }
127
155
                
130
158
                        set { defaultEnabled = value; }
131
159
                }
132
160
                
133
 
                [XmlArrayItem ("AddinDependency", typeof(AddinDependency))]
134
 
                [XmlArrayItem ("AssemblyDependency", typeof(AssemblyDependency))]
135
161
                public DependencyCollection Dependencies {
136
162
                        get { return dependencies; }
137
163
                }
138
164
                
139
 
                [XmlArrayItem ("AddinDependency", typeof(AddinDependency))]
140
 
                [XmlArrayItem ("AssemblyDependency", typeof(AssemblyDependency))]
141
165
                public DependencyCollection OptionalDependencies {
142
166
                        get { return optionalDependencies; }
143
167
                }
144
168
                
145
 
                public static AddinInfo ReadFromAddinFile (StreamReader r)
146
 
                {
147
 
                        XmlDocument doc = new XmlDocument ();
148
 
                        doc.Load (r);
149
 
                        r.Close ();
150
 
                        
151
 
                        AddinInfo info = new AddinInfo ();
152
 
                        info.id = doc.DocumentElement.GetAttribute ("id");
153
 
                        info.namspace = doc.DocumentElement.GetAttribute ("namespace");
154
 
                        info.name = doc.DocumentElement.GetAttribute ("name");
155
 
                        if (info.id == "") info.id = info.name;
156
 
                        info.version = doc.DocumentElement.GetAttribute ("version");
157
 
                        info.author = doc.DocumentElement.GetAttribute ("author");
158
 
                        info.copyright = doc.DocumentElement.GetAttribute ("copyright");
159
 
                        info.url = doc.DocumentElement.GetAttribute ("url");
160
 
                        info.description = doc.DocumentElement.GetAttribute ("description");
161
 
                        info.category = doc.DocumentElement.GetAttribute ("category");
162
 
                        info.baseVersion = doc.DocumentElement.GetAttribute ("compatVersion");
163
 
                        
164
 
                        string s = doc.DocumentElement.GetAttribute ("defaultEnabled");
165
 
                        info.defaultEnabled = s.Length == 0 || s == "true" || s == "yes";
166
 
 
167
 
                        s = doc.DocumentElement.GetAttribute ("isRoot");
168
 
                        if (s.Length == 0) s = doc.DocumentElement.GetAttribute ("isroot");
169
 
                        info.isroot = s == "true" || s == "yes";
170
 
                        
171
 
                        ReadDependencies (info.Dependencies, info.OptionalDependencies, doc.DocumentElement);
172
 
                
173
 
                        return info;
174
 
                }
175
 
                
176
 
                static void ReadDependencies (DependencyCollection deps, DependencyCollection opDeps, XmlElement elem)
177
 
                {
178
 
                        foreach (XmlElement dep in elem.SelectNodes ("Dependencies/Addin")) {
179
 
                                AddinDependency adep = new AddinDependency ();
180
 
                                adep.AddinId = dep.GetAttribute ("id");
181
 
                                string v = dep.GetAttribute ("version");
182
 
                                if (v.Length != 0)
183
 
                                        adep.Version = v;
184
 
                                deps.Add (adep);
185
 
                        }
186
 
                        
187
 
                        foreach (XmlElement dep in elem.SelectNodes ("Dependencies/Assembly")) {
188
 
                                AssemblyDependency adep = new AssemblyDependency ();
189
 
                                adep.FullName = dep.GetAttribute ("name");
190
 
                                adep.Package = dep.GetAttribute ("package");
191
 
                                deps.Add (adep);
192
 
                        }
193
 
                        
194
 
                        foreach (XmlElement mod in elem.SelectNodes ("Module"))
195
 
                                ReadDependencies (opDeps, opDeps, mod);
 
169
                public AddinPropertyCollection Properties {
 
170
                        get { return properties; }
196
171
                }
197
172
                
198
173
                internal static AddinInfo ReadFromDescription (AddinDescription description)
218
193
                                foreach (Dependency dep in mod.Dependencies)
219
194
                                        info.OptionalDependencies.Add (dep);
220
195
                        }
 
196
                        info.properties = description.Properties;
 
197
                        
221
198
                        return info;
222
199
                }
223
200