FreeTrainの進化系を目指す
Refactoring around pluginManager.
Pluginのロード方法、一覧ダイアログなど修正.
| @@ -33,7 +33,7 @@ | ||
| 33 | 33 | public static readonly NftProperties resources = NftProperties.LoadFromFile(Directories.AppBaseDir + "nftfw.resource.xml", false); |
| 34 | 34 | |
| 35 | 35 | /// <summary> Plug-ins. </summary> |
| 36 | - public static readonly PluginManager plugins = new PluginManager(); | |
| 36 | + public static readonly PluginManager pluginManager = new PluginManager(); | |
| 37 | 37 | |
| 38 | 38 | #region sound and BGM |
| 39 | 39 | /* |
| @@ -89,7 +89,7 @@ | ||
| 89 | 89 | // load global modules; |
| 90 | 90 | GlobalModules.Initialize(); |
| 91 | 91 | // load plug-ins |
| 92 | - Main.plugins.init(new string[]{Directories.PluginDir}, monitor); | |
| 92 | + Main.pluginManager.init(new string[]{Directories.PluginDir}, monitor); | |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | //new PluginListDialog().ShowDialog(); |
| @@ -220,12 +220,18 @@ | ||
| 220 | 220 | /// </summary> |
| 221 | 221 | public virtual Assembly Assembly { get { return this.GetType().Assembly; } } |
| 222 | 222 | |
| 223 | + public bool IsPrimitive { | |
| 224 | + get { | |
| 225 | + return IsPrimitiveContribution(this.GetType()); | |
| 226 | + } | |
| 227 | + } | |
| 228 | + | |
| 223 | 229 | /// <summary> |
| 224 | 230 | /// return true if specified class has 'PrimitiveContribution' Attribute. |
| 225 | 231 | /// </summary> |
| 226 | 232 | /// <param name="type"></param> |
| 227 | 233 | /// <returns></returns> |
| 228 | - public static bool isPrimitiveContribution(Type type) { | |
| 234 | + public static bool IsPrimitiveContribution(Type type) { | |
| 229 | 235 | object[] o = type.GetCustomAttributes(typeof(PrimitiveContributionAttribute),true); |
| 230 | 236 | return (o != null && o.Length > 0); |
| 231 | 237 | } |
| @@ -267,7 +273,7 @@ | ||
| 267 | 273 | internal sealed class ReferenceImpl : IObjectReference { |
| 268 | 274 | private string id=null; |
| 269 | 275 | public object GetRealObject(StreamingContext context) { |
| 270 | - object o = Main.plugins.GetContribution(id); | |
| 276 | + object o = PluginManager.theInstance.GetContribution(id); | |
| 271 | 277 | if(o==null) |
| 272 | 278 | throw new SerializationException( |
| 273 | 279 | "コントリビューション\""+id+"\"を含むプラグインが見つかりません"); |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | using System; |
| 2 | 2 | using System.Collections; |
| 3 | +using System.Collections.Generic; | |
| 3 | 4 | using System.Diagnostics; |
| 4 | 5 | using System.IO; |
| 5 | 6 | using System.Reflection; |
| @@ -29,24 +30,19 @@ | ||
| 29 | 30 | public ParseEventHandler BeforeContributionParse; |
| 30 | 31 | |
| 31 | 32 | /// <summary> |
| 32 | - /// All loaded plug-ins. | |
| 33 | - /// </summary> | |
| 34 | - private Plugin[] plugins; | |
| 35 | - | |
| 36 | - /// <summary> | |
| 37 | 33 | /// Plugins keyed by their names. |
| 38 | 34 | /// </summary> |
| 39 | - private readonly Hashtable pluginMap = new Hashtable(); | |
| 35 | + private readonly Dictionary<string, Plugin> pluginMap = new Dictionary<string, Plugin>(); | |
| 40 | 36 | |
| 41 | 37 | /// <summary> |
| 42 | 38 | /// Contribution factories that are used to load contributions. |
| 43 | 39 | /// </summary> |
| 44 | - private readonly Hashtable contributionFactories = new Hashtable(); | |
| 40 | + private readonly Dictionary<string, IContributionFactory> contributionFactories = new Dictionary<string, IContributionFactory>(); | |
| 45 | 41 | |
| 46 | 42 | /// <summary> |
| 47 | 43 | /// Contributions keyed by their IDs. |
| 48 | 44 | /// </summary> |
| 49 | - private readonly Hashtable contributionMap = new Hashtable(); | |
| 45 | + private readonly Dictionary<string, Contribution> contributionMap = new Dictionary<string, Contribution>(); | |
| 50 | 46 | |
| 51 | 47 | /// <summary> |
| 52 | 48 | /// Contribution Types keyed by their CtbTypes (string specified a Type of Contribution). |
| @@ -71,12 +67,12 @@ | ||
| 71 | 67 | public void init( ICollection dirs, ProgressMonitor monitor ) |
| 72 | 68 | { |
| 73 | 69 | errCount=0; |
| 74 | - ArrayList pluginSet=SeekPluginDirectories(dirs,monitor); | |
| 70 | + IList<Plugin> pluginSet=SeekPluginDirectories(dirs,monitor); | |
| 75 | 71 | |
| 76 | - SolveDependency(pluginSet, monitor); | |
| 77 | - LoadContributions(monitor); | |
| 78 | - InitContributions(monitor); | |
| 79 | - | |
| 72 | + Plugin[] plugins = SolveDependency(pluginSet, monitor); | |
| 73 | + LoadContributions(plugins, monitor); | |
| 74 | + InitContributions(monitor); | |
| 75 | + DisposeReaders(); | |
| 80 | 76 | // if( errCount!=0 ) { |
| 81 | 77 | // // error during the initialization |
| 82 | 78 | // Environment.Exit(errCount); |
| @@ -91,8 +87,8 @@ | ||
| 91 | 87 | } |
| 92 | 88 | |
| 93 | 89 | #region initialization processes |
| 94 | - private ArrayList SeekPluginDirectories(ICollection directories, ProgressMonitor monitor) { | |
| 95 | - ArrayList pluginSet = new ArrayList(); | |
| 90 | + private IList<Plugin> SeekPluginDirectories(ICollection directories, ProgressMonitor monitor) { | |
| 91 | + List<Plugin> pluginSet = new List<Plugin>(); | |
| 96 | 92 | monitor.Progress(1, 1, "プラグインを検索中"); |
| 97 | 93 | string[][] subdirs = new string[directories.Count][]; |
| 98 | 94 | int n = 0; |
| @@ -110,7 +106,7 @@ | ||
| 110 | 106 | } |
| 111 | 107 | return pluginSet; |
| 112 | 108 | } |
| 113 | - private void ProcessSubDirectories(ArrayList pluginSet, string parent, string[] subdirs, ProgressMonitor monitor) | |
| 109 | + private void ProcessSubDirectories(IList<Plugin> pluginSet, string parent, string[] subdirs, ProgressMonitor monitor) | |
| 114 | 110 | { |
| 115 | 111 | foreach( string dir in subdirs ) |
| 116 | 112 | { |
| @@ -130,7 +126,7 @@ | ||
| 130 | 126 | ParamsReader reader = new ParamsReader(path, parser); |
| 131 | 127 | pluginSet.Add( p ); |
| 132 | 128 | p.LoadParams(reader["plug-in"]); |
| 133 | - if( pluginMap.Contains(p.ID) ) | |
| 129 | + if( pluginMap.ContainsKey(p.ID) ) | |
| 134 | 130 | { |
| 135 | 131 | p._state = InstallationState.FatalError; |
| 136 | 132 | // loaded more than once |
| @@ -137,7 +133,7 @@ | ||
| 137 | 133 | // maybe same subdir name in different plugin dirs. |
| 138 | 134 | throw new Exception( string.Format( |
| 139 | 135 | "プラグイン「{0}」は{1}と{2}の二箇所からロードされています", |
| 140 | - p.ID, p.Uri, ((Plugin)pluginMap[p.ID]).Uri) ); | |
| 136 | + p.ID, p.Uri, (pluginMap[p.ID]).Uri) ); | |
| 141 | 137 | } |
| 142 | 138 | pluginMap.Add( p.ID, p ); |
| 143 | 139 | } |
| @@ -154,31 +150,45 @@ | ||
| 154 | 150 | } |
| 155 | 151 | } |
| 156 | 152 | |
| 157 | - private void SolveDependency(ArrayList pluginSet, ProgressMonitor monitor) | |
| 153 | + private Plugin[] SolveDependency(IList<Plugin> pluginSet, ProgressMonitor monitor) | |
| 158 | 154 | {// convert it to an array by sorting them in the order of dependency |
| 159 | 155 | monitor.Progress(1,1,"依存関係を整理中"); |
| 160 | 156 | monitor.SetMaximum(2,pluginSet.Count); |
| 161 | 157 | |
| 162 | - this.plugins = new Plugin[pluginSet.Count]; | |
| 158 | + Plugin[] plugins = new Plugin[pluginSet.Count]; | |
| 163 | 159 | int ptr=0; |
| 164 | - | |
| 160 | + | |
| 161 | + // Add system default plugin to the order-list at first. | |
| 162 | + Plugin p = GetPlugin("system"); | |
| 163 | + monitor.Progress(2, 1, p.ID); | |
| 164 | + plugins[ptr++] = p; | |
| 165 | + pluginSet.Remove(p); | |
| 166 | + // Loop until pluginSet becomes empty. | |
| 165 | 167 | while( pluginSet.Count>0 ) |
| 166 | 168 | { |
| 167 | - Plugin p = (Plugin)pluginSet[0]; | |
| 169 | + p = pluginSet[0]; | |
| 168 | 170 | monitor.Progress(2,1,p.ID); |
| 169 | 171 | try |
| 170 | 172 | { |
| 171 | - while(true) | |
| 173 | + Plugin pr; | |
| 174 | + while(true) | |
| 172 | 175 | { |
| 173 | - Plugin[] deps = p.getDependencies(); | |
| 174 | - int i; | |
| 175 | - for( i=0; i<deps.Length; i++ ) | |
| 176 | - if( pluginSet.Contains(deps[i]) ) | |
| 177 | - break; | |
| 178 | - if(i==deps.Length) | |
| 179 | - break; | |
| 180 | - else | |
| 181 | - p = deps[i]; | |
| 176 | + List<Plugin> deps = GetDependencies(p, p._reader); | |
| 177 | + pr = null; | |
| 178 | + // Pick a dependent plugin from remaining-list (if exist). | |
| 179 | + foreach (Plugin p2 in deps) { | |
| 180 | + if (pluginSet.Contains(p2)) { | |
| 181 | + pr = p2; | |
| 182 | + break; | |
| 183 | + } | |
| 184 | + } | |
| 185 | + if (pr == null) { | |
| 186 | + // exit inner while loop to add current 'p' to the orde-list. | |
| 187 | + break; | |
| 188 | + } else { | |
| 189 | + // 'pr' is the one to load earlier, so check dependency of 'pr' next. | |
| 190 | + p = pr; | |
| 191 | + } | |
| 182 | 192 | } |
| 183 | 193 | } |
| 184 | 194 | catch( Exception e ) |
| @@ -185,13 +195,14 @@ | ||
| 185 | 195 | { |
| 186 | 196 | ReportError(e.Message,e); |
| 187 | 197 | } |
| 188 | - | |
| 198 | + // Add 'p' to order-list and remove from remaining-list | |
| 189 | 199 | pluginSet.Remove(p); |
| 190 | 200 | plugins[ptr++] = p; |
| 191 | 201 | } |
| 202 | + return plugins; | |
| 192 | 203 | } |
| 193 | 204 | |
| 194 | - private void LoadContributions(ProgressMonitor monitor) | |
| 205 | + private void LoadContributions(Plugin[] plugins, ProgressMonitor monitor) | |
| 195 | 206 | { |
| 196 | 207 | // load all the contributions |
| 197 | 208 | monitor.Progress(1,1,"コントリビューションをロード中"); |
| @@ -202,7 +213,7 @@ | ||
| 202 | 213 | monitor.Progress(2,1,p.ID); |
| 203 | 214 | try |
| 204 | 215 | { |
| 205 | - p.loadBinaries(); | |
| 216 | + LoadBinaries(p, p._reader); | |
| 206 | 217 | } |
| 207 | 218 | catch( Exception e ) |
| 208 | 219 | { |
| @@ -216,9 +227,8 @@ | ||
| 216 | 227 | try |
| 217 | 228 | { |
| 218 | 229 | // this will call AddContribution method |
| 219 | - p.loadContributions(); | |
| 220 | - p._state = InstallationState.Ready; | |
| 221 | - } | |
| 230 | + LoadContributions(p, p._reader); | |
| 231 | + } | |
| 222 | 232 | catch( Exception e ) |
| 223 | 233 | { |
| 224 | 234 | p._state = InstallationState.FatalError; |
| @@ -229,13 +239,16 @@ | ||
| 229 | 239 | |
| 230 | 240 | private void InitContributions(ProgressMonitor monitor) |
| 231 | 241 | { |
| 232 | - // initialize contributions | |
| 233 | 242 | monitor.Progress(1,1,"コントリビューションを初期化中"); |
| 234 | - Contribution[] arrprm = PrimitiveContributions; | |
| 235 | - Contribution[] arrctb = Contributions; | |
| 236 | - monitor.SetMaximum(2, arrctb.Length+arrprm.Length); | |
| 243 | + IList nonPrimitives = new List<Contribution>(contributionMap.Count); | |
| 244 | + monitor.SetMaximum(2, contributionMap.Count); | |
| 237 | 245 | Hashtable handlers = new Hashtable(); |
| 238 | - foreach (Contribution contrib in arrprm) { | |
| 246 | + // Initialize all primitive contirbutions before Non primitive contributions. | |
| 247 | + foreach (Contribution contrib in contributionMap.Values) { | |
| 248 | + if(!contrib.IsPrimitive){ | |
| 249 | + nonPrimitives.Add(contrib); | |
| 250 | + continue; | |
| 251 | + } | |
| 239 | 252 | try { |
| 240 | 253 | InitCompleteEventHandler h = contrib.Initialize(); |
| 241 | 254 | if (h != null) { |
| @@ -251,7 +264,7 @@ | ||
| 251 | 264 | ReportError(string.Format(templ, contrib.Parent.ID, "contrib.name", contrib.ID), e); |
| 252 | 265 | } |
| 253 | 266 | } |
| 254 | - foreach (Contribution contrib in arrctb) | |
| 267 | + foreach (Contribution contrib in nonPrimitives) | |
| 255 | 268 | { |
| 256 | 269 | try |
| 257 | 270 | { |
| @@ -286,6 +299,16 @@ | ||
| 286 | 299 | } |
| 287 | 300 | } |
| 288 | 301 | |
| 302 | + private void DisposeReaders() { | |
| 303 | + foreach (Plugin p in pluginMap.Values) { | |
| 304 | + IDisposable pr = p._reader as IDisposable; | |
| 305 | + p._reader = null; | |
| 306 | + if (pr!=null) { | |
| 307 | + pr.Dispose(); | |
| 308 | + } | |
| 309 | + } | |
| 310 | + } | |
| 311 | + | |
| 289 | 312 | internal void ReportError(string msg, Exception e) |
| 290 | 313 | { |
| 291 | 314 | errCount++; |
| @@ -311,7 +334,129 @@ | ||
| 311 | 334 | return Directories.PluginDir; |
| 312 | 335 | } |
| 313 | 336 | |
| 314 | - #region called from Plugin constructor | |
| 337 | + #region Loading contributions for eacn Plugins. | |
| 338 | + /// <summary> | |
| 339 | + /// Get all the dependent plug-ins. | |
| 340 | + /// called from PluginManager before initialize this plugin. | |
| 341 | + /// </summary> | |
| 342 | + public List<Plugin> GetDependencies(Plugin p, ParamsReader _reader) { | |
| 343 | + List<Plugin> a = new List<Plugin>(); | |
| 344 | + foreach (ParamsReader depend in _reader.EnumChildren("depend")) { | |
| 345 | + string name = depend["on"].InnerText; | |
| 346 | + Plugin p2 = GetPlugin(name); | |
| 347 | + if (p2 == null) { | |
| 348 | + string templ = Main.resources["plugin.dependency_not_found"].stringValue; | |
| 349 | + throw new Exception(String.Format(templ, p.ID, name)); | |
| 350 | + } | |
| 351 | + a.Add(p2); | |
| 352 | + } | |
| 353 | + return a; | |
| 354 | + } | |
| 355 | + | |
| 356 | + /// <summary> | |
| 357 | + /// Loads class type contributions from this plug-in | |
| 358 | + /// </summary> | |
| 359 | + internal void LoadBinaries(Plugin p, ParamsReader _reader) { | |
| 360 | + // locate contribution factories first, | |
| 361 | + // because we'll need them to load contributions. | |
| 362 | + foreach (ParamsReader ctb_reader in _reader.EnumChildren("contribution")) { | |
| 363 | + string type = ctb_reader["type"].InnerText; | |
| 364 | + try { | |
| 365 | + Contribution cb = null; | |
| 366 | + // load a contribution factory | |
| 367 | + if ("factory".Equals(type)) { | |
| 368 | + NotifyStartParse(p, ctb_reader); | |
| 369 | + ParamsReader nd = ctb_reader["declare"]; | |
| 370 | + string regtype; | |
| 371 | + if (!nd.IsNull) { | |
| 372 | + regtype = nd["type"].InnerText; | |
| 373 | + } else { | |
| 374 | + // use name property for alternative. | |
| 375 | + regtype = ctb_reader["name"].InnerText; | |
| 376 | + } | |
| 377 | + object[] args = new object[] { ctb_reader }; | |
| 378 | + // create and register contribution factory | |
| 379 | + IContributionFactory factory = | |
| 380 | + PluginUtil.createCtbFactory(p, ctb_reader); | |
| 381 | + AddContributionFactory(regtype, factory); | |
| 382 | + cb = factory as Contribution; | |
| 383 | + // Register dummy contribution (in order to list on Dialog). | |
| 384 | + if (cb == null) { | |
| 385 | + cb = new CtbContributionDefiner(p, ctb_reader); | |
| 386 | + } | |
| 387 | + } else if ("binary".Equals(type)) { | |
| 388 | + NotifyStartParse(p, ctb_reader); | |
| 389 | + cb = PluginUtil.createContributionObject(p, ctb_reader) as BinaryModule; | |
| 390 | + if (cb == null) { | |
| 391 | + // create dummy module for list Dialog | |
| 392 | + cb = new BinaryModule(p, ctb_reader); | |
| 393 | + } | |
| 394 | + } else { | |
| 395 | + continue; | |
| 396 | + } | |
| 397 | + cb.Attach(); | |
| 398 | + cb._state = InstallationState.Ready; | |
| 399 | + } catch (Exception e) { | |
| 400 | + p._state = InstallationState.FatalError; | |
| 401 | + string msg = MakeContribExceptionMessage(p, ctb_reader); | |
| 402 | + throw new Exception(msg, e); | |
| 403 | + } | |
| 404 | + } | |
| 405 | + } | |
| 406 | + | |
| 407 | + /// <summary> | |
| 408 | + /// Loads contributions from this plug-in | |
| 409 | + /// </summary> | |
| 410 | + internal void LoadContributions(Plugin p, ParamsReader _reader) { | |
| 411 | + Contribution c = null; | |
| 412 | + int count = 0; | |
| 413 | + int errors = 0; | |
| 414 | + // load contributions | |
| 415 | + foreach (ParamsReader ctb_reader in _reader.EnumChildren("contribution")) { | |
| 416 | + try { | |
| 417 | + count++; | |
| 418 | + string type = ctb_reader["type"].InnerText; | |
| 419 | + if ("factory".Equals(type) || "binary".Equals(type)) continue; // ignore | |
| 420 | + | |
| 421 | + NotifyStartParse(p, ctb_reader); | |
| 422 | + IContributionFactory factory = GetContributionFactory(type); | |
| 423 | + c = factory.load(p, ctb_reader); | |
| 424 | + c.Attach(); | |
| 425 | + if (c.IsDetachable) { | |
| 426 | + p.AssociateAddableContribution(c); | |
| 427 | + } | |
| 428 | + AddContribution(c); | |
| 429 | + c._state = InstallationState.Ready; | |
| 430 | + } catch (Exception e) { | |
| 431 | + errors++; | |
| 432 | + Debug.WriteLine(e.Message); | |
| 433 | + Debug.WriteLine(e.StackTrace); | |
| 434 | + if (e.InnerException != null) { | |
| 435 | + Debug.WriteLine(e.InnerException.Message); | |
| 436 | + Debug.WriteLine(e.InnerException.StackTrace); | |
| 437 | + } | |
| 438 | + if (c != null) | |
| 439 | + c._state = InstallationState.FatalError; | |
| 440 | + string msg = MakeContribExceptionMessage(p, ctb_reader); | |
| 441 | + if (p._state != InstallationState.FatalError) | |
| 442 | + p._state = InstallationState.PartialError; | |
| 443 | + ReportError(msg, e); | |
| 444 | + } | |
| 445 | + } | |
| 446 | + if (p._state != InstallationState.FatalError && errors == count) { | |
| 447 | + p._state = InstallationState.FatalError; | |
| 448 | + } else if (p._state == InstallationState.Uninitialized) { | |
| 449 | + p._state = InstallationState.Ready; | |
| 450 | + } | |
| 451 | + } | |
| 452 | + | |
| 453 | + private string MakeContribExceptionMessage(Plugin p, ParamsReader pr) { | |
| 454 | + string templ = Main.resources["plugin.contrib_load_error"].stringValue; | |
| 455 | + string _id = pr["id"].InnerTextOr("unknown"); | |
| 456 | + string _name = pr["name"].InnerTextOr("unknown"); | |
| 457 | + return string.Format(templ, p.Uri.AbsoluteUri, _name, _id); | |
| 458 | + } | |
| 459 | + | |
| 315 | 460 | /// <summary> |
| 316 | 461 | /// Registers a <c>ContributionFactory</c>. |
| 317 | 462 | /// This method has to be called before the initialization. |
| @@ -320,7 +465,7 @@ | ||
| 320 | 465 | /// </summary> |
| 321 | 466 | public void AddContributionFactory( string name, IContributionFactory factory ) |
| 322 | 467 | { |
| 323 | - if( contributionFactories.Contains(name) ) | |
| 468 | + if( contributionFactories.ContainsKey(name) ) | |
| 324 | 469 | throw new Exception(string.Format( |
| 325 | 470 | "contribution type \"{0}\" is already registered.",name)); |
| 326 | 471 |
| @@ -329,8 +474,7 @@ | ||
| 329 | 474 | |
| 330 | 475 | // |
| 331 | 476 | public IContributionFactory GetContributionFactory( string name ) { |
| 332 | - IContributionFactory factory = (IContributionFactory) | |
| 333 | - contributionFactories[name]; | |
| 477 | + IContributionFactory factory = contributionFactories[name]; | |
| 334 | 478 | if(factory==null) |
| 335 | 479 | throw new Exception(name+"は未知のコントリビューションです"); |
| 336 | 480 | else |
| @@ -341,43 +485,41 @@ | ||
| 341 | 485 | /// <summary> |
| 342 | 486 | /// Lists up contributions of the given type. |
| 343 | 487 | /// </summary> |
| 488 | + [Obsolete("Use EnumContributions")] | |
| 344 | 489 | public Array ListContributions( Type contributionType, bool hideDisabled ) |
| 345 | 490 | { |
| 346 | 491 | ArrayList list = new ArrayList(); |
| 347 | - foreach( Plugin p in plugins ) { | |
| 348 | - foreach( Contribution contrib in p.Contributions ) { | |
| 349 | - if( contributionType.IsInstanceOfType(contrib) ) | |
| 350 | - if( !hideDisabled || contrib.IsAttached ) | |
| 351 | - list.Add(contrib); | |
| 352 | - } | |
| 492 | + foreach( Contribution contrib in contributionMap.Values) { | |
| 493 | + if( contributionType.IsInstanceOfType(contrib) ) | |
| 494 | + if( !hideDisabled || contrib.IsAttached ) | |
| 495 | + list.Add(contrib); | |
| 353 | 496 | } |
| 354 | - | |
| 355 | 497 | return list.ToArray(contributionType); |
| 356 | 498 | } |
| 357 | 499 | |
| 500 | + public IEnumerable<Contribution> EnumContributions(Type contributionType, bool hideDisabled) { | |
| 501 | + return new ContributionEnumerator(contributionType, hideDisabled); | |
| 502 | + } | |
| 358 | 503 | |
| 504 | + | |
| 359 | 505 | /// <summary> |
| 360 | 506 | /// Gets all contributions. |
| 361 | 507 | /// </summary> |
| 362 | - public Contribution[] Contributions { | |
| 508 | + public IEnumerable<Contribution> Contributions { | |
| 363 | 509 | get { |
| 364 | - ArrayList list = new ArrayList(); | |
| 365 | - foreach( Plugin p in plugins ) | |
| 366 | - foreach( Contribution contrib in p.Contributions ) | |
| 367 | - list.Add(contrib); | |
| 368 | - | |
| 369 | - return (Contribution[])list.ToArray(typeof(Contribution)); | |
| 510 | + return new ContributionEnumerator(false); | |
| 370 | 511 | } |
| 371 | 512 | } |
| 372 | 513 | |
| 373 | - private Contribution[] PrimitiveContributions { | |
| 514 | + public IEnumerable<Plugin> Plugins { | |
| 374 | 515 | get { |
| 375 | - ArrayList list = new ArrayList(); | |
| 376 | - foreach (Plugin p in plugins) | |
| 377 | - foreach (Contribution contrib in p.Primitives) | |
| 378 | - list.Add(contrib); | |
| 516 | + return new PluginEnumerator(); | |
| 517 | + } | |
| 518 | + } | |
| 379 | 519 | |
| 380 | - return (Contribution[])list.ToArray(typeof(Contribution)); | |
| 520 | + public IEnumerable<IContributionFactory> Factories { | |
| 521 | + get { | |
| 522 | + return new FactoryEnumerator(); | |
| 381 | 523 | } |
| 382 | 524 | } |
| 383 | 525 |
| @@ -394,23 +536,15 @@ | ||
| 394 | 536 | /// Gets the contribution with a given ID, or null if not found. |
| 395 | 537 | /// </summary> |
| 396 | 538 | public Contribution GetContribution( string id ) { |
| 397 | - return (Contribution)contributionMap[id]; | |
| 539 | + return contributionMap[id]; | |
| 398 | 540 | } |
| 399 | 541 | |
| 400 | 542 | /// <summary> |
| 401 | - /// Enumerates all plug-in objects. | |
| 402 | - /// </summary> | |
| 403 | - public IEnumerator GetEnumerator() | |
| 404 | - { | |
| 405 | - return plugins.GetEnumerator(); | |
| 406 | - } | |
| 407 | - | |
| 408 | - /// <summary> | |
| 409 | 543 | /// Get the plug-in of the specified name, or null if not found. |
| 410 | 544 | /// </summary> |
| 411 | 545 | public Plugin GetPlugin( string name ) |
| 412 | 546 | { |
| 413 | - return (Plugin)pluginMap[name]; | |
| 547 | + return pluginMap[name]; | |
| 414 | 548 | } |
| 415 | 549 | |
| 416 | 550 | public Type GetDefinedType( string ctbType ) |
| @@ -424,10 +558,10 @@ | ||
| 424 | 558 | |
| 425 | 559 | public string GetInstallInfo() |
| 426 | 560 | { |
| 427 | - if(plugins == null ) | |
| 561 | + if (pluginMap.Count == 0) | |
| 428 | 562 | return ""; |
| 429 | 563 | string output = "Installed Plugins (except for system plugins)."; |
| 430 | - foreach(Plugin p in plugins) | |
| 564 | + foreach(Plugin p in pluginMap.Values) | |
| 431 | 565 | { |
| 432 | 566 | if(!p.ID.StartsWith("system")) |
| 433 | 567 | { |
| @@ -437,5 +571,71 @@ | ||
| 437 | 571 | } |
| 438 | 572 | return output; |
| 439 | 573 | } |
| 440 | - } | |
| 574 | + | |
| 575 | + | |
| 576 | + internal class FactoryEnumerator : IEnumerable<IContributionFactory> | |
| 577 | + { | |
| 578 | + public FactoryEnumerator() { | |
| 579 | + } | |
| 580 | + | |
| 581 | + public IEnumerator<IContributionFactory> GetEnumerator() { | |
| 582 | + foreach (IContributionFactory fct in PluginManager.theInstance.contributionFactories.Values) | |
| 583 | + yield return fct; | |
| 584 | + } | |
| 585 | + | |
| 586 | + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { | |
| 587 | + return GetEnumerator(); | |
| 588 | + } | |
| 589 | + } | |
| 590 | + | |
| 591 | + internal class PluginEnumerator : IEnumerable<Plugin> | |
| 592 | + { | |
| 593 | + public PluginEnumerator() { | |
| 594 | + } | |
| 595 | + | |
| 596 | + public IEnumerator<Plugin> GetEnumerator() { | |
| 597 | + foreach (Plugin p in PluginManager.theInstance.pluginMap.Values) | |
| 598 | + yield return p; | |
| 599 | + } | |
| 600 | + | |
| 601 | + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { | |
| 602 | + return GetEnumerator(); | |
| 603 | + } | |
| 604 | + } | |
| 605 | + | |
| 606 | + internal class ContributionEnumerator : IEnumerable<Contribution> | |
| 607 | + { | |
| 608 | + readonly Type type; | |
| 609 | + readonly bool hideDisabled; | |
| 610 | + public ContributionEnumerator(bool hideDisable) : this(null, hideDisable) { } | |
| 611 | + | |
| 612 | + public ContributionEnumerator(Type t) : this(t, true) { } | |
| 613 | + | |
| 614 | + public ContributionEnumerator(Type t, bool hideDisable) { | |
| 615 | + this.type = t; | |
| 616 | + this.hideDisabled = hideDisable; | |
| 617 | + } | |
| 618 | + | |
| 619 | + public IEnumerator<Contribution> GetEnumerator() { | |
| 620 | + if (type == null) { | |
| 621 | + foreach (Contribution c in PluginManager.theInstance.contributionMap.Values) | |
| 622 | + if (!hideDisabled || c.IsAttached) | |
| 623 | + yield return c; | |
| 624 | + } else { | |
| 625 | + foreach (Contribution c in PluginManager.theInstance.contributionMap.Values) { | |
| 626 | + if (type.IsInstanceOfType(c)) { | |
| 627 | + if (!hideDisabled || c.IsAttached) | |
| 628 | + yield return c; | |
| 629 | + } | |
| 630 | + } | |
| 631 | + } | |
| 632 | + } | |
| 633 | + | |
| 634 | + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { | |
| 635 | + return GetEnumerator(); | |
| 636 | + } | |
| 637 | + } | |
| 638 | + | |
| 639 | + } | |
| 640 | + | |
| 441 | 641 | } |
| @@ -49,16 +49,6 @@ | ||
| 49 | 49 | public readonly Uri Uri; |
| 50 | 50 | |
| 51 | 51 | /// <summary> |
| 52 | - /// All the contributions in this plug-in | |
| 53 | - /// </summary> | |
| 54 | - public readonly IList Contributions = new ArrayList(); | |
| 55 | - | |
| 56 | - /// <summary> | |
| 57 | - /// All the contribution definers and binary modules in this plug-in | |
| 58 | - /// </summary> | |
| 59 | - public readonly IList Primitives = new ArrayList(); | |
| 60 | - | |
| 61 | - /// <summary> | |
| 62 | 52 | /// ParamsReader is given from PluginManager and will set null after loading complete. |
| 63 | 53 | /// </summary> |
| 64 | 54 | internal protected ParamsReader _reader; |
| @@ -119,6 +109,15 @@ | ||
| 119 | 109 | onDetach(this); |
| 120 | 110 | } |
| 121 | 111 | } |
| 112 | + | |
| 113 | + internal void AssociateAddableContribution(Contribution c){ | |
| 114 | + if (c.IsDetachable) { | |
| 115 | + totalDetachables++; | |
| 116 | + detachable = true; | |
| 117 | + c.OnAttach += new AttachChangeEvent(this.AttachChangeEventHandler); | |
| 118 | + c.OnDetach += new AttachChangeEvent(this.AttachChangeEventHandler); | |
| 119 | + } | |
| 120 | + } | |
| 122 | 121 | #endregion |
| 123 | 122 | |
| 124 | 123 | /// <summary> |
| @@ -161,7 +160,33 @@ | ||
| 161 | 160 | } |
| 162 | 161 | } |
| 163 | 162 | |
| 163 | + | |
| 164 | 164 | /// <summary> |
| 165 | + /// All the contributions in this plug-in | |
| 166 | + /// </summary> | |
| 167 | + public IList Contributions { | |
| 168 | + get { | |
| 169 | + IList l = new ArrayList(); | |
| 170 | + foreach (Contribution c in PluginManager.theInstance.Contributions) { | |
| 171 | + if (c.Parent == this) | |
| 172 | + l.Add(c); | |
| 173 | + } | |
| 174 | + return l; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + /// <summary> | |
| 179 | + /// All the contribution definers and binary modules in this plug-in | |
| 180 | + /// </summary> | |
| 181 | + [Obsolete] | |
| 182 | + public IList Primitives { | |
| 183 | + get { | |
| 184 | + return new ArrayList(); | |
| 185 | + } | |
| 186 | + } | |
| 187 | + | |
| 188 | + /* | |
| 189 | + /// <summary> | |
| 165 | 190 | /// Get all the dependent plug-ins. |
| 166 | 191 | /// called from PluginManager before initialize this plugin. |
| 167 | 192 | /// </summary> |
| @@ -223,7 +248,7 @@ | ||
| 223 | 248 | } else { |
| 224 | 249 | continue; |
| 225 | 250 | } |
| 226 | - if (Contribution.isPrimitiveContribution(cb.GetType())) { | |
| 251 | + if (Contribution.IsPrimitiveContribution(cb.GetType())) { | |
| 227 | 252 | Primitives.Add(cb); |
| 228 | 253 | } else { |
| 229 | 254 | Contributions.Add(cb); |
| @@ -243,9 +268,12 @@ | ||
| 243 | 268 | /// </summary> |
| 244 | 269 | internal void loadContributions() { |
| 245 | 270 | Contribution c = null; |
| 271 | + int count = 0; | |
| 272 | + int errors = 0; | |
| 246 | 273 | // load contributions |
| 247 | 274 | foreach (ParamsReader contrib in _reader.EnumChildren("contribution")) { |
| 248 | 275 | try { |
| 276 | + count++; | |
| 249 | 277 | string type = contrib["type"].InnerText; |
| 250 | 278 | if ("factory".Equals(type) || "binary".Equals(type)) continue; // ignore |
| 251 | 279 |
| @@ -263,6 +291,7 @@ | ||
| 263 | 291 | PluginManager.theInstance.AddContribution(c); |
| 264 | 292 | c._state = InstallationState.Ready; |
| 265 | 293 | } catch (Exception e) { |
| 294 | + errors++; | |
| 266 | 295 | Debug.WriteLine(e.Message); |
| 267 | 296 | Debug.WriteLine(e.StackTrace); |
| 268 | 297 | if (e.InnerException != null) { |
| @@ -272,14 +301,16 @@ | ||
| 272 | 301 | if (c != null) |
| 273 | 302 | c._state = InstallationState.FatalError; |
| 274 | 303 | string msg = MakeContribExceptionMessage(contrib); |
| 275 | - | |
| 276 | - if(_state != InstallationState.FatalError) | |
| 277 | - _state = InstallationState.PartialError; | |
| 278 | - PluginManager.theInstance.ReportError(msg,e); | |
| 304 | + if (_state != InstallationState.FatalError) | |
| 305 | + _state = InstallationState.PartialError; | |
| 306 | + PluginManager.theInstance.ReportError(msg, e); | |
| 279 | 307 | } |
| 280 | 308 | } |
| 281 | - if (_state == InstallationState.Uninitialized) | |
| 309 | + if (_state != InstallationState.FatalError && errors == count) { | |
| 310 | + _state = InstallationState.FatalError; | |
| 311 | + } else if (_state == InstallationState.Uninitialized) { | |
| 282 | 312 | _state = InstallationState.Ready; |
| 313 | + } | |
| 283 | 314 | } |
| 284 | 315 | |
| 285 | 316 | private string MakeContribExceptionMessage(ParamsReader pr) { |
| @@ -288,5 +319,6 @@ | ||
| 288 | 319 | string _name = pr["name"].InnerTextOr("unknown"); |
| 289 | 320 | return string.Format(templ, Uri.AbsoluteUri, _name, _id); |
| 290 | 321 | } |
| 322 | + */ | |
| 291 | 323 | } |
| 292 | 324 | } |
| @@ -39,7 +39,7 @@ | ||
| 39 | 39 | if(plugin==null) |
| 40 | 40 | { |
| 41 | 41 | string pname = Path.GetFileName(Path.GetDirectoryName(node.SourceURI)+""); |
| 42 | - plugin = Main.plugins.GetPlugin(pname); | |
| 42 | + plugin = PluginManager.theInstance.GetPlugin(pname); | |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 |
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | using System.Windows.Forms; |
| 3 | 3 | using nft.framework; |
| 4 | 4 | using nft.framework.plugin; |
| 5 | +using System.Collections.Generic; | |
| 5 | 6 | |
| 6 | 7 | namespace nft.util |
| 7 | 8 | { |
| @@ -14,10 +15,10 @@ | ||
| 14 | 15 | |
| 15 | 16 | public static int Set( ComboBox combo, string ctbType, bool hideDisabled, IListContribFilter filter ) |
| 16 | 17 | { |
| 17 | - Array arr = GetArray( ctbType, hideDisabled ); | |
| 18 | - if( arr == null ) return -1; | |
| 18 | + IEnumerable<Contribution> en = GetArray( ctbType, hideDisabled ); | |
| 19 | + if( en == null ) return -1; | |
| 19 | 20 | int n = 0; |
| 20 | - foreach( Contribution c in arr ) | |
| 21 | + foreach( Contribution c in en ) | |
| 21 | 22 | if(filter.IsValid(c)) |
| 22 | 23 | { |
| 23 | 24 | combo.Items.Add( new AbstractItem(c) ); |
| @@ -65,12 +66,12 @@ | ||
| 65 | 66 | } |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | - private static Array GetArray( string ctbType, bool hideDisabled ) | |
| 69 | + private static IEnumerable<Contribution> GetArray( string ctbType, bool hideDisabled ) | |
| 69 | 70 | { |
| 70 | 71 | PluginManager pm = PluginManager.theInstance; |
| 71 | 72 | Type t = pm.GetDefinedType(ctbType); |
| 72 | 73 | if( t == null ) return null; |
| 73 | - return pm.ListContributions(t,hideDisabled); | |
| 74 | + return pm.EnumContributions(t,hideDisabled); | |
| 74 | 75 | } |
| 75 | 76 | |
| 76 | 77 | #region Default Filter |
| @@ -61,8 +61,8 @@ | ||
| 61 | 61 | sb.AppendLine("-----System Information-----"); |
| 62 | 62 | sb.AppendLine(ConfigureService.GetSystemInfo()); |
| 63 | 63 | sb.AppendLine("-----PlugIn Information-----"); |
| 64 | - if (Main.plugins != null) { | |
| 65 | - sb.AppendLine(Main.plugins.GetInstallInfo()); | |
| 64 | + if (Main.pluginManager != null) { | |
| 65 | + sb.AppendLine(Main.pluginManager.GetInstallInfo()); | |
| 66 | 66 | } else { |
| 67 | 67 | sb.AppendLine("Plugin manager not initialized."); |
| 68 | 68 | } |
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | using System; |
| 2 | 2 | using System.Drawing; |
| 3 | 3 | using System.Collections; |
| 4 | +using System.Collections.Generic; | |
| 4 | 5 | using System.ComponentModel; |
| 5 | 6 | using System.Windows.Forms; |
| 6 | 7 | using nft.framework; |
| @@ -9,6 +10,7 @@ | ||
| 9 | 10 | using nft.util; |
| 10 | 11 | using nft.win32util; |
| 11 | 12 | using nft.controls; |
| 13 | +using System.IO; | |
| 12 | 14 | |
| 13 | 15 | namespace nft.ui.system |
| 14 | 16 | { |
| @@ -293,13 +295,17 @@ | ||
| 293 | 295 | // populate the list |
| 294 | 296 | clist.Items.Clear(); |
| 295 | 297 | plist.Items.Clear(); |
| 296 | - foreach( Plugin p in Main.plugins ) | |
| 298 | + foreach( Plugin p in PluginManager.theInstance.Plugins ) | |
| 297 | 299 | plist.Items.Add( CreateListItem(p) ); |
| 298 | 300 | |
| 299 | 301 | // construct tree |
| 300 | 302 | tree.Nodes.Clear(); |
| 301 | - foreach( Plugin p in Main.plugins ) | |
| 302 | - tree.Nodes.Add( CreateTreeItem(p) ); | |
| 303 | + foreach (IContributionFactory f in PluginManager.theInstance.Factories) { | |
| 304 | + Type t = f.OutputType; | |
| 305 | + tree.Nodes.Add(CreateTreeItem(f)); | |
| 306 | + } | |
| 307 | + //foreach (Plugin p in PluginManager.theInstance.Plugins) | |
| 308 | + //tree.Nodes.Add( CreateTreeItem(p) ); | |
| 303 | 309 | } |
| 304 | 310 | |
| 305 | 311 | private void list_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e) |
| @@ -323,24 +329,52 @@ | ||
| 323 | 329 | { |
| 324 | 330 | Application.DoEvents(); |
| 325 | 331 | Plugin p = (Plugin)item.Tag; |
| 326 | - foreach (Contribution c in p.Primitives) | |
| 327 | - clist.Items.Add( CreateListItem(c) ); | |
| 328 | - foreach( Contribution c in p.Contributions ) | |
| 329 | - clist.Items.Add( CreateListItem(c) ); | |
| 330 | - } | |
| 332 | + foreach (Contribution c in p.Contributions) { | |
| 333 | + clist.Items.Add(CreateListItem(c)); | |
| 334 | + } | |
| 335 | + } | |
| 331 | 336 | } |
| 332 | 337 | |
| 333 | 338 | private void tree_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e) |
| 334 | 339 | { |
| 335 | - Plugin p = e.Node.Tag as Plugin; | |
| 340 | + IContributionFactory f = e.Node.Tag as IContributionFactory; | |
| 341 | + if (f != null) { | |
| 342 | + e.Node.Nodes.Clear(); | |
| 343 | + foreach (Contribution c in PluginManager.theInstance.EnumContributions(f.OutputType,false)) { | |
| 344 | + Plugin p = c.Parent; | |
| 345 | + TreeNode pnode = null; | |
| 346 | + foreach (TreeNode tn in e.Node.Nodes) { | |
| 347 | + if (tn.Tag == p) { | |
| 348 | + pnode = tn; | |
| 349 | + break; | |
| 350 | + } | |
| 351 | + } | |
| 352 | + if (pnode == null) { | |
| 353 | + pnode = CreateTreeItem(p); | |
| 354 | + e.Node.Nodes.Add(pnode); | |
| 355 | + } | |
| 356 | + pnode.Nodes.Add(CreateTreeItem(c)); | |
| 357 | + } | |
| 358 | + return; | |
| 359 | + } | |
| 360 | + /* | |
| 361 | + Plugin p = e.Node.Tag as Plugin; | |
| 336 | 362 | if(p!=null) |
| 337 | 363 | { |
| 338 | 364 | e.Node.Nodes.Clear(); |
| 339 | - foreach (Contribution c in p.Primitives) | |
| 340 | - e.Node.Nodes.Add( CreateTreeItem(c) ); | |
| 341 | - foreach( Contribution c in p.Contributions ) | |
| 342 | - e.Node.Nodes.Add( CreateTreeItem(c) ); | |
| 343 | - } | |
| 365 | + List<Contribution> prim = new List<Contribution>(); | |
| 366 | + foreach (Contribution c in p.Contributions) { | |
| 367 | + if (c.IsPrimitive) { | |
| 368 | + prim.Add(c); | |
| 369 | + } else { | |
| 370 | + e.Node.Nodes.Add(CreateTreeItem(c)); | |
| 371 | + } | |
| 372 | + } | |
| 373 | + int i = 0; | |
| 374 | + foreach (Contribution c in prim) | |
| 375 | + e.Node.Nodes.Insert(i++,CreateTreeItem(c)); | |
| 376 | + } | |
| 377 | + */ | |
| 344 | 378 | } |
| 345 | 379 | |
| 346 | 380 | private void tree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) |
| @@ -347,7 +381,16 @@ | ||
| 347 | 381 | { |
| 348 | 382 | ShowInfoMessage(); |
| 349 | 383 | string msg; |
| 350 | - Plugin p = e.Node.Tag as Plugin; | |
| 384 | + IContributionFactory f = e.Node.Tag as IContributionFactory; | |
| 385 | + if (f != null) { | |
| 386 | + string dllname = Path.GetFileName(new Uri(f.GetType().Assembly.CodeBase).LocalPath); | |
| 387 | + msg = string.Format("Type:{0}\nFactory:{1}\nCodeBase:{2}", f.OutputType.Name, f.GetType().FullName, dllname); | |
| 388 | + info.Text = msg; | |
| 389 | + info.LinkArea = new LinkArea(0, 0); | |
| 390 | + info.TargetUrl = ""; | |
| 391 | + return; | |
| 392 | + } | |
| 393 | + Plugin p = e.Node.Tag as Plugin; | |
| 351 | 394 | if(p!=null) |
| 352 | 395 | { |
| 353 | 396 | msg = string.Format("Title:{0}\nAuthor:{1}\nHomepage:{2}",p.Title,p.author,p.homepage); |
| @@ -368,7 +411,7 @@ | ||
| 368 | 411 | Contribution c = e.Node.Tag as Contribution; |
| 369 | 412 | if(c!=null) |
| 370 | 413 | { |
| 371 | - msg = string.Format("Name:{0}\nType:{1}",c.Name,c.CtbType); | |
| 414 | + msg = string.Format("ID:{0}\nName:{1}\nDescription:{2}", c.ID, c.Name, c.Description); | |
| 372 | 415 | info.Text = msg; |
| 373 | 416 | info.LinkArea = new LinkArea(0,0); |
| 374 | 417 | info.TargetUrl=""; |
| @@ -396,7 +439,7 @@ | ||
| 396 | 439 | switch(c.State) |
| 397 | 440 | { |
| 398 | 441 | case InstallationState.Ready: |
| 399 | - if (Contribution.isPrimitiveContribution(c.GetType())) | |
| 442 | + if (c.IsPrimitive) | |
| 400 | 443 | return 4; |
| 401 | 444 | else |
| 402 | 445 | return 1; |
| @@ -413,6 +456,8 @@ | ||
| 413 | 456 | return 0; |
| 414 | 457 | case InstallationState.PartialError: |
| 415 | 458 | return 3; |
| 459 | + case InstallationState.FatalError: | |
| 460 | + return 5; | |
| 416 | 461 | default: |
| 417 | 462 | return 2; |
| 418 | 463 | } |
| @@ -437,7 +482,7 @@ | ||
| 437 | 482 | private TreeNode CreateTreeItem(Contribution c) |
| 438 | 483 | { |
| 439 | 484 | int icon = GetIconIndex(c); |
| 440 | - TreeNode node = new TreeNode(c.ID, icon, icon ); | |
| 485 | + TreeNode node = new TreeNode(c.Name, icon, icon ); | |
| 441 | 486 | node.Tag = c; |
| 442 | 487 | node.Checked = c.IsAttached; |
| 443 | 488 | return node; |
| @@ -484,9 +529,9 @@ | ||
| 484 | 529 | private void tree_BeforeCheck(object sender, System.Windows.Forms.TreeViewCancelEventArgs e) |
| 485 | 530 | { |
| 486 | 531 | TreeNode node = e.Node; |
| 487 | - IAddable addable = node.Tag as IAddable; | |
| 532 | + Contribution addable = node.Tag as Contribution; | |
| 488 | 533 | if(e.Action != TreeViewAction.ByMouse && e.Action !=TreeViewAction.ByKeyboard ) return; |
| 489 | - if( addable.IsDetachable ) | |
| 534 | + if (addable!=null && addable.IsDetachable) | |
| 490 | 535 | { |
| 491 | 536 | if(node.Checked) |
| 492 | 537 | addable.Detach(); |
| @@ -538,15 +583,22 @@ | ||
| 538 | 583 | { |
| 539 | 584 | } |
| 540 | 585 | |
| 541 | - private TreeNode CreateTreeItem(Plugin p) | |
| 586 | + private TreeNode CreateTreeItem(IContributionFactory f) | |
| 542 | 587 | { |
| 543 | - int icon = GetIconIndex(p); | |
| 544 | - TreeNode node = new TreeNode(p.ID, icon, icon, new TreeNode[]{new TreeNode("")} ); | |
| 545 | - node.Tag = p; | |
| 546 | - node.Checked = p.IsAttached; | |
| 588 | + int icon = 6; | |
| 589 | + TreeNode node = new TreeNode(f.OutputType.Name, icon, icon, new TreeNode[]{new TreeNode("")} ); | |
| 590 | + node.Tag = f; | |
| 591 | + node.Checked = true; | |
| 547 | 592 | return node; |
| 548 | 593 | } |
| 549 | - #endregion | |
| 594 | + private TreeNode CreateTreeItem(Plugin p) { | |
| 595 | + int icon = GetIconIndex(p); | |
| 596 | + TreeNode node = new TreeNode(p.ID, icon, icon); | |
| 597 | + node.Tag = p; | |
| 598 | + node.Checked = p.IsAttached; | |
| 599 | + return node; | |
| 600 | + } | |
| 601 | + #endregion | |
| 550 | 602 | |
| 551 | 603 | internal class Sorter : IComparer |
| 552 | 604 | { |