예제 #1
0
        public PluginManager(string basePath)
        {
            try
            {
                var settings = PluginSettings.Default;
                if (settings.Enabled & settings.Plugins.Count > 0)
                {
                    var pluginSettings = settings.Plugins[0];

                    if (Log.IsInfoEnabled)
                    {
                        Log.InfoFormat("Plugin configured: name={0}", pluginSettings.Name);

                        if (pluginSettings.CustomAttributes.Count > 0)
                        {
                            foreach (var att in pluginSettings.CustomAttributes)
                            {
                                Log.InfoFormat("\tAttribute: {0}={1}", att.Key, att.Value);
                            }
                        }
                    }

                    var pluginInfo = new PluginInfo
                        {
                            Name = pluginSettings.Name,
                            Version = pluginSettings.Version,
                            AssemblyName = pluginSettings.AssemblyName,
                            Type = pluginSettings.Type,
                            ConfigParams = pluginSettings.CustomAttributes
                        };

                    this.UpdateConfiguration(pluginInfo, string.IsNullOrEmpty(basePath) ? Environment.CurrentDirectory : basePath);
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
예제 #2
0
        private void UpdatePluginTraits()
        {
            var settings = PluginSettings.Default;
            if (settings.Enabled & settings.Plugins.Count > 0)
            {
                var pluginSettings = settings.Plugins[0];

                if (log.IsInfoEnabled)
                {
                    log.InfoFormat("Plugin configured: name={0}", pluginSettings.Name);

                    if (pluginSettings.CustomAttributes.Count > 0)
                    {
                        foreach (var att in pluginSettings.CustomAttributes)
                        {
                            log.InfoFormat("\tAttribute: {0}={1}", att.Key, att.Value);
                        }
                    }
                }

                var pluginInfo = new PluginInfo
                {
                    Name = pluginSettings.Name,
                    Version = pluginSettings.Version,
                    AssemblyName = pluginSettings.AssemblyName,
                    Type = pluginSettings.Type,
                    ConfigParams = pluginSettings.CustomAttributes
                };

                this.PluginTraits = PluginTraits.Create(pluginInfo);
                return;
            }

            this.PluginTraits = PluginTraits.Create(new PluginInfo());
        }
예제 #3
0
        private static void ReadValue(PluginInfo pluginInfo, string name, ref bool result)
        {
            var value = FindValue(pluginInfo, name);
            if (string.IsNullOrEmpty(value))
            {
                return;
            }

            bool parseResult;
            if (bool.TryParse(value, out parseResult))
            {
                result = parseResult;
            }
        }
예제 #4
0
 public PluginManager(PluginInfo pluginInfo, string basePath)
 {
     this.UpdateConfiguration(pluginInfo, basePath);
 }
예제 #5
0
 private static string FindValue(PluginInfo pluginInfo, string name)
 {
     var result = string.Empty;
     if (pluginInfo.ConfigParams != null)
     {
         pluginInfo.ConfigParams.TryGetValue(name, out result);
     }
     return result;
 }
예제 #6
0
        public static PluginTraits Create(PluginInfo pluginInfo)
        {
            var result = new PluginTraits();

            ReadValue(pluginInfo, IsPersistentTag, ref result.isPersistent);
            ReadValue(pluginInfo, AsyncJoinTag, ref result.asyncJoin);

            return result;
        }
예제 #7
0
 private void UpdatePluginTraits(PluginInfo pluginInfo)
 {
     this.pluginTraits = PluginTraits.Create(pluginInfo);
 }
예제 #8
0
 public void UpdateConfiguration(PluginInfo pluginInfo, string basePath)
 {
     try
     {
         var path = Path.Combine(basePath, pluginInfo.Path);
         this.UpdatePluginTraits(pluginInfo);
         this.Initialized = this.SetupPluginManager(path, pluginInfo.Type, pluginInfo.ConfigParams);
     }
     catch (Exception e)
     {
         Log.Error(e);
     }
 }
예제 #9
0
 protected PluginManagerBase(PluginInfo pluginInfo, string basePath)
 {
     this.currentPluginsVersion = typeof(IPlugin).Assembly.GetName().Version;
     this.UpdateConfiguration(pluginInfo, basePath);
 }