private Plugin GetPlugin(StoreId pluginId)
        {
            Plugin p = null;
            manager.PluginDirectory = _options.PluginDirectory;

            while(p == null) {
                Plugin[] list = manager.GetPlugin(pluginId.name);

                if(list == null || list.Length == 0) {
                    if(loadedAssemblies == _assemblies.Count) {
                        return null;
                    }
                    else {
                        // load the assembly
                        manager.AddPlugins(_assemblies[loadedAssemblies]);
                        loadedAssemblies++;
                    }
                }
                else {
                    // verify if the versions match
                    for(int i = 0; i < list.Length; i++) {
                        if(list[i].Id != pluginId.id) {
                            continue;
                        }

                        bool majorMatch = (list[i].HasMajorVersion ? list[i].MajorVersion : int.MaxValue) == pluginId.majorVersion;
                        bool minorMatch = (list[i].HasMinorVersion ? list[i].MinorVersion : int.MaxValue) == pluginId.minorVersion;

                        if(majorMatch && minorMatch) {
                            return list[i];
                        }
                    }
                }
            }

            return p;
        }
Esempio n. 2
0
 public static StoreId CreateStoreId(Plugin plugin)
 {
     StoreId id = new StoreId();
     id.id = plugin.Id;
     id.name = plugin.Name;
     id.majorVersion = plugin.HasMajorVersion ? plugin.MajorVersion : int.MaxValue;
     id.minorVersion = plugin.HasMinorVersion ? plugin.MinorVersion : int.MaxValue;
     return id;
 }