BloombergFLP.CollectdWin.PluginRegistry.CreatePlugins C# (CSharp) Method

CreatePlugins() public method

public CreatePlugins ( ) : IList
return IList
        public IList<ICollectdPlugin> CreatePlugins()
        {
            IList<ICollectdPlugin> plugins = new List<ICollectdPlugin>();
            foreach (var entry in _registry)
            {
                Type classType = Type.GetType(entry.Value);
                if (classType == null)
                {
                    LogEventInfo logEvent = new LogEventInfo(LogLevel.Error, Logger.Name, String.Format("Cannot create plugin:{0}, class:{1}", entry.Key, entry.Value));
                    logEvent.Properties.Add("EventID", ErrorCodes.ERROR_CONFIGURATION_EXCEPTION);
                    Logger.Log(logEvent);
                    continue;
                }
                var plugin = (ICollectdPlugin) Activator.CreateInstance(classType);
                plugins.Add(plugin);
            }
            return (plugins);
        }

Usage Example

        public MetricsCollector()
        {
            var config = ConfigurationManager.GetSection("CollectdWinConfig") as CollectdWinConfig;
            if (config == null)
            {
                LogEventInfo logEvent = new LogEventInfo(LogLevel.Error, Logger.Name, "Cannot get configuration section");
                logEvent.Properties.Add("EventID", ErrorCodes.ERROR_CONFIGURATION_EXCEPTION);
                Logger.Log(logEvent);
                return;
            }

            _runReadThread = false;
            _runWriteThread = false;

            var registry = new PluginRegistry();
            _plugins = registry.CreatePlugins();

            _interval = config.GeneralSettings.Interval;
            if (_interval <= 10)
                _interval = 10;

            _timeout = config.GeneralSettings.Timeout;
            if (_timeout <= _interval)
                _timeout = _interval*3;

            bool storeRates = config.GeneralSettings.StoreRates;

            _aggregator = new Aggregator(_timeout, storeRates);

            _collectedValueQueue = new Queue<CollectableValue>();
            _queueLock = new Object();
        }
All Usage Examples Of BloombergFLP.CollectdWin.PluginRegistry::CreatePlugins