private void Initializations()
 {
     _injectionStrategies            = new List <IInjectionStrategy>();
     _concreteInjectionStrategyTypes = new List <Type>();
     //DatabaseNames = new ObservableCollection<string>();
     //TableNames = new  ObservableCollection<string>();
     //ColumnNames = new ObservableCollection<string>();
     ////ItemsSource="{Binding Path=DatabaseNames}"
     //lbDatabases.ItemsSource = DatabaseNames;
     //lbTables.ItemsSource = TableNames;
     //lbColumns.ItemsSource = ColumnNames;
     _currentIpObtainerStrategy = new Seringa.Engine.Implementations.IPObtainers.SimpleIPObtainerStrategy();
     UIHelpers.ClearTreeView(tvDs);
     cmbProxyType.SelectedValue = ProxyType.None;
     btnAutodetect.IsEnabled    = false;
 }
 private void ClearAll()
 {
     txtCustomQueryResult.Text = string.Empty;
     UIHelpers.ClearTreeView(tvDs);
 }
        private void btnOverrideCurrentSettings_Click(object sender, RoutedEventArgs e)
        {
            string mappingFile = txtMappingFile.Text.Trim();

            if (!string.IsNullOrEmpty(mappingFile))
            {
                if (!File.Exists(mappingFile))
                {
                    MessageBox.Show("Could not load file");
                    return;
                }

                string injectionStrategyTypeName = XmlHelpers.GetAttributeValueFromDoc <string>(mappingFile, "/map/injection-strategy", "name",
                                                                                                string.Empty);

                int injectionStrategyNrOriginalQueryCols = XmlHelpers.GetElementValueFromDoc <int>(mappingFile,
                                                                                                   "/map/injection-strategy/columns/originalquery", 0);

                int injectionStrategyNrHtmlCols = XmlHelpers.GetElementValueFromDoc <int>(mappingFile,
                                                                                          "/map/injection-strategy/columns/resultinghtml", 0);

                string injectionStrategyColumnIndexes = XmlHelpers.GetElementValueFromDoc <string>(mappingFile,
                                                                                                   "/map/injection-strategy/columns/indexes", string.Empty);


                string vulnerableUrl = XmlHelpers.GetElementValueFromDoc <string>(mappingFile, "/map/vulnerable-url", string.Empty);

                string dbms = XmlHelpers.GetAttributeValueFromDoc <string>(mappingFile, "/map/dbms", "name",
                                                                           string.Empty);

                IInjectionStrategy strategy = _injectionStrategies.Where(i => i.GetType().Name == injectionStrategyTypeName).FirstOrDefault();
                if (strategy != null)
                {
                    cbCurrentInjectionStrategy.SelectedValue = strategy.DisplayName;
                }
                if (_currentInjectionStrategy != null)
                {
                    if (!string.IsNullOrEmpty(vulnerableUrl))
                    {
                        txtUrl.Text = vulnerableUrl;
                        UrlOrStrategyChange();
                        //ParameterChange();
                    }
                    _currentInjectionStrategy.NrColumnsInOriginalQuery  = injectionStrategyNrOriginalQueryCols;
                    _currentInjectionStrategy.NumberOfResultsPerRequest = injectionStrategyNrHtmlCols;
                    _currentInjectionStrategy.ColumnIndexes             = ListHelpers.CommaSeparatedValuesToList <int>(injectionStrategyColumnIndexes);
                }

                if (!string.IsNullOrEmpty(dbms))
                {
                    cbDbms.SelectedValue = dbms;
                }

                var databasesElem = XmlHelpers.GetXmlElementViaXpath(mappingFile, "/map/databases");
                if (databasesElem != null)
                {
                    var newRootElement = UIHelpers.ClearTreeView(tvDs);

                    UIHelpers.BuildNodes(newRootElement, databasesElem);

                    #region different approach
                    //    XmlDataProvider dataProvider = this.FindResource("xmlDataProvider") as XmlDataProvider;
                    //    var bindDoc = new XmlDocument();
                    //    var reader = databasesElem.CreateReader();
                    //    reader.MoveToContent();
                    //    bindDoc.LoadXml(reader.ReadOuterXml());
                    //    dataProvider.Document = bindDoc;
                    #endregion different approach
                }
            }
        }