public ObjectSchemaLoader(DataDrivenCategory dataDrivenCategory, string xPath, string schema) { Stream manifestResource = WinformsHelper.GetManifestResource(dataDrivenCategory); SafeXmlDocument safeXmlDocument = new SafeXmlDocument(); safeXmlDocument.Load(manifestResource); foreach (object obj in safeXmlDocument.SelectNodes(xPath)) { XmlNode xmlNode = (XmlNode)obj; XmlNode namedItem = xmlNode.Attributes.GetNamedItem("Name"); if (namedItem.Value.Equals(schema)) { this.objectDefinition = xmlNode; break; } } }
public ResultsLoaderProfile GetProfile(string profileName) { Stream manifestResource = WinformsHelper.GetManifestResource(this.dataDrivenCategory); XmlTextReader reader = SafeXmlFactory.CreateSafeXmlTextReader(manifestResource); XElement po = XElement.Load(reader); DataTable inputTable; var <> f__AnonymousType = (from dataSource in po.Elements("ResultsLoader") where (string)dataSource.Attribute("Name") == profileName select new { Configuration = this.CreateUIPresentationProfile(po, dataSource.Element("Configuration")), DataTable = (from dataTable in dataSource.Elements("DataColumns") select new { DataColumns = dataTable.Elements("Column").Union(dataTable.Elements("RefColumns").SelectMany((XElement r) => (from c in po.Element("RefColumnsSection").Elements("RefColumns") where c.Attribute("Name").Value == r.Attribute("Name").Value select c).Elements("Column"))), PrimaryKey = (this.HasValue(dataTable.Attribute("PrimaryKey")) ? dataTable.Attribute("PrimaryKey").Value.Split(new char[] { ',' }) : new string[0]), NameProperty = (this.HasValue(dataTable.Attribute("NameProperty")) ? dataTable.Attribute("NameProperty").Value : "Name"), DataColumnsCalculator = (IDataColumnsCalculator)(this.HasValue(dataTable.Attribute("DataColumnsCalculator")) ? ObjectPickerProfileLoader.CreateObject(dataTable.Attribute("DataColumnsCalculator").Value) : null), WholeObjectProperty = (this.HasValue(dataTable.Attribute("WholeObjectProperty")) ? dataTable.Attribute("WholeObjectProperty").Value : string.Empty), DistinguishIdentity = (this.HasValue(dataTable.Attribute("DistinguishIdentity")) ? dataTable.Attribute("DistinguishIdentity").Value : string.Empty) }).First(), InputTable = (this.HasValue(dataSource.Element("InputColumns")) ? (from inputTable in dataSource.Elements("InputColumns") select new { DataColumns = inputTable.Elements("Column").Union(inputTable.Elements("RefColumns").SelectMany((XElement r) => (from c in po.Element("RefColumnsSection").Elements("RefColumns") where c.Attribute("Name").Value == r.Attribute("Name").Value select c).Elements("Column"))), PartialOrderComparer = (IPartialOrderComparer)(this.HasValue(inputTable.Attribute("PartialOrderComparer")) ? ObjectPickerProfileLoader.CreateObject(inputTable.Attribute("PartialOrderComparer").Value) : null) }).First() : null), DataReader = (from dataReader in dataSource.Elements("DataTableFillers") select new { DataTableFillers = dataReader.Elements(), BatchSize = (this.HasValue(dataReader.Attribute("BatchSize")) ? dataReader.Attribute("BatchSize").Value : ResultsLoaderProfile.DefaultBatchSize.ToString()), FillType = (this.HasValue(dataReader.Attribute("FillType")) ? ((FillType)Enum.Parse(typeof(FillType), dataReader.Attribute("FillType").Value)) : 0), LoadableFromProfilePredicate = (ILoadableFromProfile)(this.HasValue(dataReader.Attribute("LoadableFromProfilePredicate")) ? ObjectPickerProfileLoader.CreateObject(dataReader.Attribute("LoadableFromProfilePredicate").Value) : null), PostRefreshAction = (PostRefreshActionBase)(this.HasValue(dataReader.Attribute("PostRefreshAction")) ? ObjectPickerProfileLoader.CreateObject(dataReader.Attribute("PostRefreshAction").Value) : null) }).First() }).First(); DataTable resultTable = this.GetTableSchema(< > f__AnonymousType.DataTable.DataColumns, true); resultTable.PrimaryKey = (from c in < > f__AnonymousType.DataTable.PrimaryKey select resultTable.Columns[c]).ToArray <DataColumn>(); resultTable.TableName = profileName; inputTable = ((< > f__AnonymousType.InputTable != null) ? this.GetTableSchema(< > f__AnonymousType.InputTable.DataColumns, false) : new DataTable()); ResultsLoaderProfile resultsLoaderProfile = new ResultsLoaderProfile(< > f__AnonymousType.Configuration, inputTable, resultTable) { Name = profileName, InputTablePartialOrderComparer = ((< > f__AnonymousType.InputTable == null) ? null : < > f__AnonymousType.InputTable.PartialOrderComparer), WholeObjectProperty = < > f__AnonymousType.DataTable.WholeObjectProperty, NameProperty = < > f__AnonymousType.DataTable.NameProperty, DataColumnsCalculator = < > f__AnonymousType.DataTable.DataColumnsCalculator, LoadableFromProfilePredicate = < > f__AnonymousType.DataReader.LoadableFromProfilePredicate, PostRefreshAction = < > f__AnonymousType.DataReader.PostRefreshAction, BatchSize = ((string.Compare(< > f__AnonymousType.DataReader.BatchSize, "MaxValue", true) == 0) ? int.MaxValue : int.Parse(< > f__AnonymousType.DataReader.BatchSize)), DistinguishIdentity = < > f__AnonymousType.DataTable.DistinguishIdentity, FillType = < > f__AnonymousType.DataReader.FillType }; this.AddFillerCollection(resultsLoaderProfile, <> f__AnonymousType.DataReader.DataTableFillers); return(resultsLoaderProfile); }