/// <summary> /// Create an abstract description of an element in a collection of filters, sorts and transforms. /// </summary> /// <param name="propertySchema">A description of the property.</param> /// <param name="xmlNode">The XML Schema extensions that describe the query.</param> public QuerySchema(PropertySchema propertySchema, XmlNode xmlNode) { // Initialize the object. this.propertySchema = propertySchema; // Extract the name of the query. This will default to an randomly generated name of not explicitly stated in the // schema. XmlAttribute nameAttribute = xmlNode.Attributes[QualifiedName.VariableName.Name, QualifiedName.VariableName.Namespace]; this.name = nameAttribute == null?RandomVariableName.NewName() : nameAttribute.Value; // Extract the resulting type. This will default to the property type if not explicitly stated in the schema. XmlAttribute resultTypeAttribute = xmlNode.Attributes[QualifiedName.ResultType.Name, QualifiedName.ResultType.Namespace]; this.resultType = resultTypeAttribute == null ? String.Empty : resultTypeAttribute.Value; // Extract the source of data for the query. This will default to the result of the previous query if not explicitly // stated in the schema. XmlAttribute sourceAttribute = xmlNode.Attributes[QualifiedName.Source.Name, QualifiedName.Source.Namespace]; this.source = sourceAttribute == null ? String.Empty : sourceAttribute.Value; // Extract the type of the source data. This will default to the type of the source of data for this query if not // explicitly stated in the schema. XmlAttribute sourceTypeAttribute = xmlNode.Attributes[QualifiedName.SourceType.Name, QualifiedName.SourceType.Namespace]; this.sourceType = sourceTypeAttribute == null ? String.Empty : sourceTypeAttribute.Value; }
/// <summary> /// Creates a description of a LINQ clause that selectively removes items from a data source. /// </summary> /// <param name="propertySchema">A description of the property.</param> /// <param name="xmlNode">The XML Schema extensions that describe the query.</param> public WhereSchema(PropertySchema propertySchema, XmlNode xmlNode) : base(propertySchema, xmlNode) { // Extract the name of the predicate (the method that selectively qualifies records) from the XML Schema extension. XmlAttribute predicateAttribute = xmlNode.Attributes[QualifiedName.Predicate.Name, QualifiedName.Predicate.Namespace]; this.predicate = predicateAttribute.Value; }
/// <summary> /// Create an abstract description of an operation that selects one object from another. /// </summary> /// <param name="propertySchema">A description of the property.</param> /// <param name="xmlNode">The XML Schema extensions that describe the query.</param> public SelectSchema(PropertySchema propertySchema, XmlNode xmlNode) : base(propertySchema, xmlNode) { // Extract the selector (the operation that provides the transformation of one object to another) from the XML // extension. XmlAttribute selectorAttribute = xmlNode.Attributes[QualifiedName.Selector.Name, QualifiedName.Selector.Namespace]; this.selector = selectorAttribute.Value; }
/// <summary> /// Creates a description of an 'OrderBy' clause of a LINQ query. /// </summary> /// <param name="propertySchema">A description of a property.</param> /// <param name="xmlNode">The XML Schema extension describing the 'OrderBy' clause.</param> public OrderBySchema(PropertySchema propertySchema, XmlNode xmlNode) : base(propertySchema, xmlNode) { // Extract the 'Comparer' clause. XmlAttribute comparerAttribute = xmlNode.Attributes[QualifiedName.Comparer.Name, QualifiedName.Comparer.Namespace]; this.comparer = comparerAttribute.Value; // Extract the 'KeySelector' clause. XmlAttribute keySelectorAttribute = xmlNode.Attributes[QualifiedName.KeySelector.Name, QualifiedName.KeySelector.Namespace]; this.keySelector = keySelectorAttribute.Value; // Extract the 'KeyType' clause. XmlAttribute keyTypeAttribute = xmlNode.Attributes[QualifiedName.KeyType.Name, QualifiedName.KeyType.Namespace]; this.keyType = keyTypeAttribute.Value; }