Exemple #1
0
        /// <summary>
        /// Loads the Traffic Viewer extensions
        /// </summary>
        public void LoadExtensions()
        {
            SdkSettings.Instance.ExtensionInfoList = TrafficViewerOptions.Instance.GetExtensionInfo();

            //load modules
            TrafficParserFactory parserFactory = new TrafficParserFactory();

            _trafficParsers = parserFactory.GetExtensions();
            ExporterFactory exporterFactory = new ExporterFactory();

            _trafficExporters = exporterFactory.GetExtensions();
            AnalysisModulesFactory analysisModulesFactory = new AnalysisModulesFactory();

            _analysisModules = analysisModulesFactory.GetExtensions();
            ExploiterFactory exploitersFactory = new ExploiterFactory();

            _exploiters = exploitersFactory.GetExtensions();

            SenderFactory senderFactory = new SenderFactory();

            _senders = senderFactory.GetExtensions();
            HttpClientExtensionFactory clientFactoryLoader = new HttpClientExtensionFactory();

            _httpClientFactoryList = clientFactoryLoader.GetExtensions();
            _httpClientFactoryList.Add(new WebRequestClientFactory());
            _httpClientFactory = null;
            //find in the list of client factories the one with the name specified in options
            foreach (IHttpClientFactory clientFactory in _httpClientFactoryList)
            {
                if (String.Compare(clientFactory.ClientType, TrafficViewerOptions.Instance.HttpClientName) == 0)
                {
                    _httpClientFactory = clientFactory;
                    break;
                }
            }

            if (_httpClientFactory == null)
            {
                //if the factory was not found use the default
                _httpClientFactory = new TrafficViewerHttpClientFactory();
                //log a warning
                SdkSettings.Instance.Logger.Log(TraceLevel.Warning, "Could not find HTTP client factory for {0}", TrafficViewerOptions.Instance.HttpClientName);
                TrafficViewerOptions.Instance.HttpClientName = _httpClientFactory.ClientType;
            }

            HttpProxyFactory proxyFactory = new HttpProxyFactory();

            _httpProxyFactoryList = proxyFactory.GetExtensions();
        }