Beispiel #1
0
        public List <DataColumn> LoadDataColumns(List <string> bindingMapping)
        {
            List <DataColumn> list = new List <DataColumn>();

            bindingMapping.Clear();
            XmlNode xmlNode = base.ObjectDefinition.SelectSingleNode("Columns");

            foreach (object obj in xmlNode.SelectNodes("Column"))
            {
                XmlNode xmlNode2     = (XmlNode)obj;
                string  value        = xmlNode2.Attributes.GetNamedItem("Name").Value;
                string  value2       = xmlNode2.Attributes.GetNamedItem("Type").Value;
                Type    typeByString = ObjectSchemaLoader.GetTypeByString(value2);
                ICustomTextConverter customTextConverter = null;
                XmlNode namedItem = xmlNode2.Attributes.GetNamedItem("TextConverter");
                if (namedItem != null && !string.IsNullOrEmpty(namedItem.Value))
                {
                    customTextConverter = (ICustomTextConverter)ObjectSchemaLoader.GetTypeByString(namedItem.Value).GetConstructor(new Type[0]).Invoke(new object[0]);
                }
                XmlNode    namedItem2 = xmlNode2.Attributes.GetNamedItem("DefaultValue");
                DataColumn dataColumn = new DataColumn(value, typeByString);
                if (namedItem2 != null)
                {
                    string value3 = namedItem2.Value;
                    dataColumn.DefaultValue = ((customTextConverter != null) ? customTextConverter.Parse(typeByString, value3, null) : value3);
                }
                string value4 = xmlNode2.Attributes.GetNamedItem("UpdateTable").Value;
                if (value4.Equals("true", StringComparison.InvariantCultureIgnoreCase))
                {
                    bindingMapping.Add(value);
                }
                XmlNode namedItem3 = xmlNode2.Attributes.GetNamedItem("Expression");
                if (namedItem3 != null && !string.IsNullOrEmpty(namedItem3.Value))
                {
                    dataColumn.Expression = namedItem3.Value;
                }
                list.Add(dataColumn);
            }
            return(list);
        }
 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);
         }
     }
 }