Ejemplo n.º 1
0
        public ResultsLoaderProfile BuildResultsLoaderProfile()
        {
            DataTable            inputTable           = new DataTable();
            ResultsColumnProfile resultsColumnProfile = new ResultsColumnProfile("CanonicalName", true, Strings.Name);
            ResultsLoaderProfile resultsLoaderProfile = new ResultsLoaderProfile(Strings.OrganizationalUnit, false, "ImageProperty", inputTable, OrganizationalUnitConfigurable.GetDataTable(), new ResultsColumnProfile[]
            {
                resultsColumnProfile
            });

            resultsLoaderProfile.UseTreeViewForm = true;
            ExchangeCommandBuilder exchangeCommandBuilder = new ExchangeCommandBuilder();

            exchangeCommandBuilder.ScopeBuilder = new OrganizationalUnitScopeBuilder();
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary["IncludeContainers"] = string.Empty;
            resultsLoaderProfile.AddTableFiller(new MonadAdapterFiller("Get-OrganizationalUnit", exchangeCommandBuilder)
            {
                Parameters          = dictionary,
                AddtionalParameters =
                {
                    "Identity",
                    "SingleNodeOnly"
                }
            });
            resultsLoaderProfile.HelpTopic = "Microsoft.Exchange.Management.SystemManager.WinForms.OrganizationalUnitPicker";
            return(resultsLoaderProfile);
        }
 private void AddFillerCollection(ResultsLoaderProfile objectPickerProfile, IEnumerable <XElement> dataTableFillers)
 {
     foreach (XElement xelement in dataTableFillers)
     {
         if ("MonadAdapterFiller" == xelement.Name || xelement.Name == "DAGNetworkDataFiller" || xelement.Name == "SupervisionListFiller" || xelement.Name == "DatabaseStatusFiller" || xelement.Name == "SecurityIdentifierResolveFiller")
         {
             IExchangeScopeBuilder exchangeScopeBuilder = null;
             if (this.HasValue(xelement.Attribute("ScopeBuilder")))
             {
                 string name = (string)xelement.Attribute("ScopeBuilder");
                 exchangeScopeBuilder = (IExchangeScopeBuilder)ObjectSchemaLoader.GetTypeByString(name).GetConstructor(new Type[0]).Invoke(new object[0]);
             }
             IExchangeCommandFilterBuilder filterBuilder = null;
             if (this.HasValue(xelement.Attribute("FilterBuilder")))
             {
                 string name2 = (string)xelement.Attribute("FilterBuilder");
                 filterBuilder = (IExchangeCommandFilterBuilder)ObjectSchemaLoader.GetTypeByString(name2).GetConstructor(new Type[0]).Invoke(new object[0]);
             }
             string resolveCommandText = null;
             if (this.HasValue(xelement.Attribute("ResolveCommand")))
             {
                 resolveCommandText = (string)xelement.Attribute("ResolveCommand");
             }
             ExchangeCommandBuilder exchangeCommandBuilder = new ExchangeCommandBuilder(filterBuilder);
             if (exchangeScopeBuilder != null)
             {
                 exchangeCommandBuilder.ScopeBuilder = exchangeScopeBuilder;
             }
             if (this.HasValue(xelement.Attribute("SearchType")))
             {
                 exchangeCommandBuilder.SearchType = (ExchangeCommandBuilderSearch)Enum.Parse(typeof(ExchangeCommandBuilderSearch), (string)xelement.Attribute("SearchType"));
             }
             if (this.HasValue(xelement.Attribute("UseFilterToResolveNonId")))
             {
                 exchangeCommandBuilder.UseFilterToResolveNonId = bool.Parse((string)xelement.Attribute("UseFilterToResolveNonId"));
             }
             exchangeCommandBuilder.NamePropertyFilter = objectPickerProfile.NameProperty;
             if ("MonadAdapterFiller" == xelement.Name)
             {
                 MonadAdapterFiller monadAdapterFiller = new MonadAdapterFiller((string)xelement.Attribute("Command"), exchangeCommandBuilder)
                 {
                     ResolveCommandText = resolveCommandText
                 };
                 IEnumerable <XElement> enumerable = xelement.Elements("Column");
                 foreach (XElement xelement2 in enumerable)
                 {
                     string value  = xelement2.Attribute("Name").Value;
                     string value2 = xelement2.Attribute("Value").Value;
                     ICustomTextConverter customTextConverter = objectPickerProfile.DataTable.Columns[value].ExtendedProperties.ContainsKey("TextConverter") ? ((ICustomTextConverter)objectPickerProfile.DataTable.Columns[value].ExtendedProperties["TextConverter"]) : new TextConverter();
                     monadAdapterFiller.FixedValues[value] = customTextConverter.Parse(objectPickerProfile.DataTable.Columns[value].DataType, value2, null);
                 }
                 if (xelement.Element("Parameters") != null)
                 {
                     IEnumerable <XElement> enumerable2 = xelement.Element("Parameters").Elements("Parameter");
                     foreach (XElement xelement3 in enumerable2)
                     {
                         monadAdapterFiller.Parameters[xelement3.Attribute("Name").Value] = xelement3.Attribute("Value").Value;
                     }
                     IEnumerable <XElement> enumerable3 = xelement.Element("Parameters").Elements("AdditionalParameter");
                     foreach (XElement xelement4 in enumerable3)
                     {
                         monadAdapterFiller.AddtionalParameters.Add(xelement4.Attribute("Name").Value);
                     }
                 }
                 string runnableLambdaExpression = string.Empty;
                 if (this.HasValue(xelement.Attribute("RunnableLambdaExpression")))
                 {
                     runnableLambdaExpression = (string)xelement.Attribute("RunnableLambdaExpression");
                 }
                 objectPickerProfile.AddTableFiller(monadAdapterFiller, runnableLambdaExpression);
             }
             else if ("SupervisionListFiller" == xelement.Name)
             {
                 objectPickerProfile.AddTableFiller(new SupervisionListFiller((string)xelement.Attribute("Command")));
             }
             else if ("DatabaseStatusFiller" == xelement.Name)
             {
                 string runnableLambdaExpression2 = string.Empty;
                 if (this.HasValue(xelement.Attribute("RunnableLambdaExpression")))
                 {
                     runnableLambdaExpression2 = (string)xelement.Attribute("RunnableLambdaExpression");
                 }
                 objectPickerProfile.AddTableFiller(new DatabaseStatusFiller((string)xelement.Attribute("Command"), exchangeCommandBuilder)
                 {
                     ResolveCommandText = resolveCommandText
                 }, runnableLambdaExpression2);
             }
             else if ("DAGNetworkDataFiller" == xelement.Name)
             {
                 objectPickerProfile.AddTableFiller(new DAGNetworkDataFiller((string)xelement.Attribute("Command"), exchangeCommandBuilder)
                 {
                     ResolveCommandText = resolveCommandText
                 });
             }
             else
             {
                 string sidColumn  = (string)xelement.Attribute("SidColumn");
                 string userColumn = (string)xelement.Attribute("UserColumn");
                 objectPickerProfile.AddTableFiller(new SecurityIdentifierResolveFiller(sidColumn, userColumn));
             }
         }
         else if ("FixedDataFiller" == xelement.Name)
         {
             FixedDataFiller fixedDataFiller = new FixedDataFiller();
             fixedDataFiller.DataTable = objectPickerProfile.DataTable.Clone();
             IEnumerable <XElement> enumerable4 = xelement.Elements("Row");
             foreach (XElement xelement5 in enumerable4)
             {
                 DataRow dataRow = fixedDataFiller.DataTable.NewRow();
                 IEnumerable <XElement> enumerable5 = xelement5.Elements("Column");
                 foreach (XElement xelement6 in enumerable5)
                 {
                     string value3 = xelement6.Attribute("Name").Value;
                     string value4 = xelement6.Attribute("Value").Value;
                     ICustomTextConverter customTextConverter2 = fixedDataFiller.DataTable.Columns[value3].ExtendedProperties.ContainsKey("TextConverter") ? ((ICustomTextConverter)fixedDataFiller.DataTable.Columns[value3].ExtendedProperties["TextConverter"]) : new TextConverter();
                     dataRow[value3] = customTextConverter2.Parse(fixedDataFiller.DataTable.Columns[value3].DataType, value4, null);
                 }
                 fixedDataFiller.DataTable.Rows.Add(dataRow);
             }
             objectPickerProfile.AddTableFiller(fixedDataFiller);
         }
     }
 }