protected PropertyValueFilter(string propertyName, object expectedPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { PropertyName = propertyName; _behaviorOnNoMatch = behaviorOnNoMatch; OriginalExpectedPropertyValue = expectedPropertyValue; CimTypedExpectedPropertyValue = CimValueConverter.ConvertFromDotNetToCim(expectedPropertyValue); }
public override bool ShouldReportErrorOnNoMatches_IfMultipleFilters() { IEnumerable <ClientSideQuery.PropertyValueFilter> propertyValueFilters; BehaviorOnNoMatch behaviorOnNoMatch = base.BehaviorOnNoMatch; switch (behaviorOnNoMatch) { case BehaviorOnNoMatch.Default: { IEnumerable <ClientSideQuery.PropertyValueFilter> propertyValueFilters1 = base.PropertyValueFilters; propertyValueFilters = propertyValueFilters1.Where <ClientSideQuery.PropertyValueFilter>((ClientSideQuery.PropertyValueFilter f) => !f.HadMatch); break; } case BehaviorOnNoMatch.ReportErrors: { return(true); } case BehaviorOnNoMatch.SilentlyContinue: { return(false); } default: { IEnumerable <ClientSideQuery.PropertyValueFilter> propertyValueFilters1 = base.PropertyValueFilters; propertyValueFilters = propertyValueFilters1.Where <ClientSideQuery.PropertyValueFilter>((ClientSideQuery.PropertyValueFilter f) => !f.HadMatch); break; } } return(propertyValueFilters.Where <ClientSideQuery.PropertyValueFilter>((ClientSideQuery.PropertyValueFilter f) => f.BehaviorOnNoMatch == BehaviorOnNoMatch.ReportErrors).Any <ClientSideQuery.PropertyValueFilter>()); }
public virtual bool ShouldReportErrorOnNoMatches_IfMultipleFilters() { BehaviorOnNoMatch behaviorOnNoMatch = this.BehaviorOnNoMatch; switch (behaviorOnNoMatch) { case BehaviorOnNoMatch.Default: { return(false); } case BehaviorOnNoMatch.ReportErrors: { return(true); } case BehaviorOnNoMatch.SilentlyContinue: { return(false); } default: { return(false); } } }
public CimInstanceAssociationFilter(BehaviorOnNoMatch behaviorOnNoMatch) { if (behaviorOnNoMatch == BehaviorOnNoMatch.Default) { this.BehaviorOnNoMatch = BehaviorOnNoMatch.ReportErrors; } else { this.BehaviorOnNoMatch = behaviorOnNoMatch; } }
public CimInstanceAssociationFilter(BehaviorOnNoMatch behaviorOnNoMatch) { if (behaviorOnNoMatch != BehaviorOnNoMatch.Default) { base.BehaviorOnNoMatch = behaviorOnNoMatch; return; } else { base.BehaviorOnNoMatch = BehaviorOnNoMatch.ReportErrors; return; } }
public virtual IEnumerable <ClientSideQuery.NotFoundError> GetNotFoundErrors_IfThisIsTheOnlyFilter() { BehaviorOnNoMatch behaviorOnNoMatch = this.BehaviorOnNoMatch; switch (behaviorOnNoMatch) { case BehaviorOnNoMatch.Default: { return(Enumerable.Empty <ClientSideQuery.NotFoundError>()); } case BehaviorOnNoMatch.ReportErrors: { if (!this.HadMatches) { ClientSideQuery.NotFoundError[] notFoundError = new ClientSideQuery.NotFoundError[1]; notFoundError[0] = new ClientSideQuery.NotFoundError(); return(notFoundError); } else { return(Enumerable.Empty <ClientSideQuery.NotFoundError>()); } } case BehaviorOnNoMatch.SilentlyContinue: { return(Enumerable.Empty <ClientSideQuery.NotFoundError>()); } default: { return(Enumerable.Empty <ClientSideQuery.NotFoundError>()); } } }
/// <summary> /// Modifies the query, so that it does not return objects with a given property value /// </summary> /// <param name="propertyName">Property name to query on</param> /// <param name="excludedPropertyValues">Property values to reject in the query</param> /// <param name="wildcardsEnabled"> /// <c>true</c> if <paramref name="excludedPropertyValues"/> should be treated as a <see cref="System.String"/> containing a wildcard pattern; /// <c>false otherwise</c> /// </param> /// <param name="behaviorOnNoMatch"> /// Describes how to handle filters that didn't match any objects /// </param> public override void ExcludeByProperty(string propertyName, IEnumerable excludedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { this.ClientSideQuery.ExcludeByProperty(propertyName, excludedPropertyValues, wildcardsEnabled, behaviorOnNoMatch); string positiveWqlCondition = CimQuery.GetMatchCondition(propertyName, excludedPropertyValues, wildcardsEnabled); if (!string.IsNullOrWhiteSpace(positiveWqlCondition)) { string condition = string.Format( CultureInfo.InvariantCulture, "NOT ({0})", positiveWqlCondition); this.AddWqlCondition(condition); } }
/// <summary> /// Adds key properties. Each property has a single value (first). /// </summary> /// <param name="propertyName">Name of the property (key)</param> /// <param name="allowedPropertyValues">Property value</param> /// <param name="wildcardsEnabled">ignored</param> /// <param name="behaviorOnNoMatch">ignored</param> public override void FilterByProperty(string propertyName, IEnumerable allowedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { if (propertyName == null) { throw new ArgumentNullException("propertyName"); } if (allowedPropertyValues == null) { throw new ArgumentNullException("allowedPropertyValues"); } // association properties are in the format ReferredResource:propertyName:Key var propertyNameSplit = propertyName.Split(':'); string basePropertyName; // regular Get if (propertyNameSplit.Length == 1) { basePropertyName = propertyName; } // Check if its a Query Option. else if (propertyNameSplit.Length == 2 && string.Equals(propertyNameSplit[0], "QueryOption", StringComparison.OrdinalIgnoreCase)) { basePropertyName = propertyNameSplit[1]; } // association Get else if (propertyNameSplit.Length == 3) { ReferredResource = propertyNameSplit[0]; if (propertyNameSplit[2] != "Key") { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, Resources.IncorrectPropertyNameFormat, propertyName)); } basePropertyName = propertyNameSplit[1]; } else { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, Resources.IncorrectPropertyNameFormat, propertyName)); } var enumerator = allowedPropertyValues.GetEnumerator(); enumerator.MoveNext(); object value = enumerator.Current; if (value != null) { // Select is the only Query parameter for which filtering is // supported on mutliple property names. // The Property names selected go over the wire as strings. if (string.Compare(basePropertyName, "Select", StringComparison.OrdinalIgnoreCase) == 0) { StringBuilder selectQueryValues = new StringBuilder(value.ToString()); while (enumerator.MoveNext()) { value = enumerator.Current; if (value != null) { selectQueryValues.Append(","); selectQueryValues.Append(value.ToString()); } } value = selectQueryValues.ToString(); } bool isQueryTypeParameter = TryProcessQueryProperty(basePropertyName, value); if (!isQueryTypeParameter) { Keys.Add(new Tuple <string, object>(basePropertyName, value)); } } }
public PropertyValueMinFilter(string propertyName, object expectedPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) : base(propertyName, expectedPropertyValue, behaviorOnNoMatch) { }
public override void ExcludeByProperty(string propertyName, IEnumerable excludedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { this.ClientSideQuery.ExcludeByProperty(propertyName, excludedPropertyValues, wildcardsEnabled, behaviorOnNoMatch); string matchCondition = CimQuery.GetMatchCondition(propertyName, excludedPropertyValues, wildcardsEnabled); if (!string.IsNullOrWhiteSpace(matchCondition)) { object[] objArray = new object[1]; objArray[0] = matchCondition; string str = string.Format(CultureInfo.InvariantCulture, "NOT ({0})", objArray); this.AddWqlCondition(str); } }
public CimInstanceRegularFilter(string propertyName, IEnumerable allowedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { var valueBehaviors = new HashSet <BehaviorOnNoMatch>(); foreach (object allowedPropertyValue in allowedPropertyValues) { PropertyValueFilter filter = new PropertyValueRegularFilter( propertyName, allowedPropertyValue, wildcardsEnabled, behaviorOnNoMatch); this.AddPropertyValueFilter(filter); valueBehaviors.Add(filter.BehaviorOnNoMatch); } if (valueBehaviors.Count == 1) { this.BehaviorOnNoMatch = valueBehaviors.First(); } else { this.BehaviorOnNoMatch = behaviorOnNoMatch; } }
public override void FilterByAssociatedInstance(object associatedInstance, string associationName, string sourceRole, string resultRole, BehaviorOnNoMatch behaviorOnNoMatch) { _filters.Add(new CimInstanceAssociationFilter(behaviorOnNoMatch)); }
public override void FilterByMinPropertyValue(string propertyName, object minPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { this._filters.Add(new ClientSideQuery.CimInstanceMinFilter(propertyName, minPropertyValue, behaviorOnNoMatch)); }
public CimInstanceRegularFilter(string propertyName, IEnumerable allowedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { HashSet <BehaviorOnNoMatch> behaviorOnNoMatches = new HashSet <BehaviorOnNoMatch>(); foreach (object allowedPropertyValue in allowedPropertyValues) { ClientSideQuery.PropertyValueFilter propertyValueRegularFilter = new ClientSideQuery.PropertyValueRegularFilter(propertyName, allowedPropertyValue, wildcardsEnabled, behaviorOnNoMatch); base.AddPropertyValueFilter(propertyValueRegularFilter); behaviorOnNoMatches.Add(propertyValueRegularFilter.BehaviorOnNoMatch); } if (behaviorOnNoMatches.Count != 1) { base.BehaviorOnNoMatch = behaviorOnNoMatch; return; } else { base.BehaviorOnNoMatch = behaviorOnNoMatches.Single <BehaviorOnNoMatch>(); return; } }
public CimInstanceMinFilter(string propertyName, object minPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { if (behaviorOnNoMatch != BehaviorOnNoMatch.Default) { base.BehaviorOnNoMatch = behaviorOnNoMatch; } else { base.BehaviorOnNoMatch = BehaviorOnNoMatch.SilentlyContinue; } base.AddPropertyValueFilter(new ClientSideQuery.PropertyValueMinFilter(propertyName, minPropertyValue, behaviorOnNoMatch)); }
/// <summary> /// Modifies the query, so that it returns only objects associated with <paramref name="associatedInstance"/> /// </summary> /// <param name="associatedInstance">object that query results have to be associated with</param> /// <param name="associationName">name of the association</param> /// <param name="resultRole">name of the role that <paramref name="associatedInstance"/> has in the association</param> /// <param name="sourceRole">name of the role that query results have in the association</param> /// <param name="behaviorOnNoMatch"> /// Describes how to handle filters that didn't match any objects /// </param> public override void FilterByAssociatedInstance(object associatedInstance, string associationName, string sourceRole, string resultRole, BehaviorOnNoMatch behaviorOnNoMatch) { this.ClientSideQuery.FilterByAssociatedInstance(associatedInstance, associationName, sourceRole, resultRole, behaviorOnNoMatch); _associatedObject = associatedInstance as CimInstance; _associationName = associationName; _resultRole = resultRole; _sourceRole = sourceRole; }
public override void ExcludeByProperty(string propertyName, IEnumerable excludedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { _filters.Add(new CimInstanceExcludeFilter(propertyName, excludedPropertyValues, wildcardsEnabled, behaviorOnNoMatch)); }
public CimInstanceRegularFilter(string propertyName, IEnumerable allowedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { var valueBehaviors = new HashSet<BehaviorOnNoMatch>(); foreach (object allowedPropertyValue in allowedPropertyValues) { PropertyValueFilter filter = new PropertyValueRegularFilter( propertyName, allowedPropertyValue, wildcardsEnabled, behaviorOnNoMatch); this.AddPropertyValueFilter(filter); valueBehaviors.Add(filter.BehaviorOnNoMatch); } if (valueBehaviors.Count == 1) { this.BehaviorOnNoMatch = valueBehaviors.Single(); } else { this.BehaviorOnNoMatch = behaviorOnNoMatch; } }
public virtual void FilterByMinPropertyValue(string propertyName, object minPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { throw new NotImplementedException(); }
public CimInstanceMaxFilter(string propertyName, object minPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { if (behaviorOnNoMatch == BehaviorOnNoMatch.Default) { this.BehaviorOnNoMatch = BehaviorOnNoMatch.SilentlyContinue; } else { this.BehaviorOnNoMatch = behaviorOnNoMatch; } this.AddPropertyValueFilter( new PropertyValueMaxFilter( propertyName, minPropertyValue, behaviorOnNoMatch)); }
public PropertyValueExcludeFilter(string propertyName, object expectedPropertyValue, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) : base(propertyName, expectedPropertyValue, wildcardsEnabled, behaviorOnNoMatch) { }
public override void FilterByMaxPropertyValue(string propertyName, object maxPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { _filters.Add(new CimInstanceMaxFilter(propertyName, maxPropertyValue, behaviorOnNoMatch)); }
protected PropertyValueFilter(string propertyName, object expectedPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { this.propertyName = propertyName; this._behaviorOnNoMatch = behaviorOnNoMatch; this._originalExpectedPropertyValue = expectedPropertyValue; this._cimTypedExpectedPropertyValue = CimValueConverter.ConvertFromDotNetToCim(expectedPropertyValue); }
/// <summary> /// Modifies the query, so that it returns only objects associated with <paramref name="associatedInstance"/> /// </summary> /// <param name="associatedInstance">object that query results have to be associated with</param> /// <param name="associationName">name of the association</param> /// <param name="resultRole">name of the role that <paramref name="associatedInstance"/> has in the association</param> /// <param name="sourceRole">name of the role that query results have in the association</param> /// <param name="behaviorOnNoMatch"> /// Describes how to handle filters that didn't match any objects /// </param> public virtual void FilterByAssociatedInstance(object associatedInstance, string associationName, string sourceRole, string resultRole, BehaviorOnNoMatch behaviorOnNoMatch) { throw new NotImplementedException(); }
public PropertyValueRegularFilter(string propertyName, object expectedPropertyValue, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) : base(propertyName, expectedPropertyValue, behaviorOnNoMatch) { this._wildcardsEnabled = wildcardsEnabled; }
/// <summary> /// Modifies the query, so that it does not return objects with a given property value /// </summary> /// <param name="propertyName">Property name to query on</param> /// <param name="excludedPropertyValues">Property values to reject in the query</param> /// <param name="wildcardsEnabled"> /// <c>true</c> if <paramref name="excludedPropertyValues"/> should be treated as a <see cref="System.String"/> containing a wildcard pattern; /// <c>false otherwise</c> /// </param> /// <param name="behaviorOnNoMatch"> /// Describes how to handle filters that didn't match any objects /// </param> public virtual void ExcludeByProperty(string propertyName, IEnumerable excludedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { throw new NotImplementedException(); }
/// <summary> /// Modifies the query, so that it only returns objects with a given property value /// </summary> /// <param name="propertyName">Property name to query on</param> /// <param name="allowedPropertyValues">Property values to accept in the query</param> /// <param name="wildcardsEnabled"> /// <c>true</c> if <paramref name="allowedPropertyValues"/> should be treated as a <see cref="System.String"/> containing a wildcard pattern; /// <c>false otherwise</c> /// </param> /// <param name="behaviorOnNoMatch"> /// Describes how to handle filters that didn't match any objects /// </param> public override void FilterByProperty(string propertyName, IEnumerable allowedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { this.ClientSideQuery.FilterByProperty(propertyName, allowedPropertyValues, wildcardsEnabled, behaviorOnNoMatch); string matchCondition = CimQuery.GetMatchCondition(propertyName, allowedPropertyValues, wildcardsEnabled); if (!string.IsNullOrWhiteSpace(matchCondition)) { this.AddWqlCondition(matchCondition); } }
/// <summary> /// Modifies the query, so that it returns only objects that have a property value greater than or equal to a <paramref name="minPropertyValue"/> threshold /// </summary> /// <param name="propertyName">Property name to query on</param> /// <param name="minPropertyValue">Minimum property value</param> /// <param name="behaviorOnNoMatch"> /// Describes how to handle filters that didn't match any objects /// </param> public virtual void FilterByMinPropertyValue(string propertyName, object minPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { throw new NotImplementedException(); }
/// <summary> /// Modifies the query, so that it returns only objects that have a property value less than or equal to a <paramref name="maxPropertyValue"/> threshold /// </summary> /// <param name="propertyName">Property name to query on</param> /// <param name="maxPropertyValue">Maximum property value</param> /// <param name="behaviorOnNoMatch"> /// Describes how to handle filters that didn't match any objects /// </param> public override void FilterByMaxPropertyValue(string propertyName, object maxPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { this.ClientSideQuery.FilterByMaxPropertyValue(propertyName, maxPropertyValue, behaviorOnNoMatch); string wqlLiteral = CimQuery.ObjectToWqlLiteral(maxPropertyValue); if (!string.IsNullOrWhiteSpace(wqlLiteral)) { string condition = string.Format( CultureInfo.InvariantCulture, "{0} <= {1}", propertyName, CimQuery.ObjectToWqlLiteral(maxPropertyValue)); this.AddWqlCondition(condition); } }
public override void FilterByProperty(string propertyName, IEnumerable allowedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { _filters.Add(new CimInstanceRegularFilter(propertyName, allowedPropertyValues, wildcardsEnabled, behaviorOnNoMatch)); }
public CimInstanceExcludeFilter(string propertyName, IEnumerable excludedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { if (behaviorOnNoMatch != BehaviorOnNoMatch.Default) { base.BehaviorOnNoMatch = behaviorOnNoMatch; } else { base.BehaviorOnNoMatch = BehaviorOnNoMatch.SilentlyContinue; } foreach (object excludedPropertyValue in excludedPropertyValues) { base.AddPropertyValueFilter(new ClientSideQuery.PropertyValueExcludeFilter(propertyName, excludedPropertyValue, wildcardsEnabled, behaviorOnNoMatch)); } }
public virtual void FilterByAssociatedInstance(object associatedInstance, string associationName, string sourceRole, string resultRole, BehaviorOnNoMatch behaviorOnNoMatch) { throw new NotImplementedException(); }
public override void ExcludeByProperty(string propertyName, IEnumerable excludedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { this._filters.Add(new ClientSideQuery.CimInstanceExcludeFilter(propertyName, excludedPropertyValues, wildcardsEnabled, behaviorOnNoMatch)); }
public virtual void FilterByProperty(string propertyName, IEnumerable allowedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { throw new NotImplementedException(); }
public CimInstanceRegularFilter(string propertyName, IEnumerable allowedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { HashSet<BehaviorOnNoMatch> behaviorOnNoMatches = new HashSet<BehaviorOnNoMatch>(); foreach (object allowedPropertyValue in allowedPropertyValues) { ClientSideQuery.PropertyValueFilter propertyValueRegularFilter = new ClientSideQuery.PropertyValueRegularFilter(propertyName, allowedPropertyValue, wildcardsEnabled, behaviorOnNoMatch); base.AddPropertyValueFilter(propertyValueRegularFilter); behaviorOnNoMatches.Add(propertyValueRegularFilter.BehaviorOnNoMatch); } if (behaviorOnNoMatches.Count != 1) { base.BehaviorOnNoMatch = behaviorOnNoMatch; return; } else { base.BehaviorOnNoMatch = behaviorOnNoMatches.Single<BehaviorOnNoMatch>(); return; } }
public CimInstanceExcludeFilter(string propertyName, IEnumerable excludedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { if (behaviorOnNoMatch == BehaviorOnNoMatch.Default) { this.BehaviorOnNoMatch = BehaviorOnNoMatch.SilentlyContinue; } else { this.BehaviorOnNoMatch = behaviorOnNoMatch; } foreach (object excludedPropertyValue in excludedPropertyValues) { this.AddPropertyValueFilter( new PropertyValueExcludeFilter( propertyName, excludedPropertyValue, wildcardsEnabled, behaviorOnNoMatch)); } }
public override void FilterByAssociatedInstance(object associatedInstance, string associationName, string sourceRole, string resultRole, BehaviorOnNoMatch behaviorOnNoMatch) { this._filters.Add(new ClientSideQuery.CimInstanceAssociationFilter(behaviorOnNoMatch)); }
public override void FilterByProperty(string propertyName, IEnumerable allowedPropertyValues, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) { this._filters.Add(new ClientSideQuery.CimInstanceRegularFilter(propertyName, allowedPropertyValues, wildcardsEnabled, behaviorOnNoMatch)); }
public PropertyValueRegularFilter(string propertyName, object expectedPropertyValue, bool wildcardsEnabled, BehaviorOnNoMatch behaviorOnNoMatch) : base(propertyName, expectedPropertyValue, behaviorOnNoMatch) { _wildcardsEnabled = wildcardsEnabled; }
public PropertyValueMaxFilter(string propertyName, object expectedPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) : base(propertyName, expectedPropertyValue, behaviorOnNoMatch) { }
public override void FilterByMinPropertyValue(string propertyName, object minPropertyValue, BehaviorOnNoMatch behaviorOnNoMatch) { this.ClientSideQuery.FilterByMinPropertyValue(propertyName, minPropertyValue, behaviorOnNoMatch); string wqlLiteral = CimQuery.ObjectToWqlLiteral(minPropertyValue); if (!string.IsNullOrWhiteSpace(wqlLiteral)) { object[] objArray = new object[2]; objArray[0] = propertyName; objArray[1] = wqlLiteral; string str = string.Format(CultureInfo.InvariantCulture, "{0} >= {1}", objArray); this.AddWqlCondition(str); } }