Example #1
0
        /// <summary>
        /// Determines if the specified single-valued attribute change matches this object filter
        /// </summary>
        /// <param name="attributeChange">The attribute change object</param>
        /// <returns>A value indicating whether the specified object should be filtered from the result set</returns>
        private bool IsFilteredSingleValue(AttributeChange attributeChange)
        {
            ValueChange valueChange = attributeChange.ValueChanges.FirstOrDefault(t => t.ModificationType == ValueModificationType.Add);

            if (valueChange == null)
            {
                return(false);
            }

            switch (this.Attribute.Type)
            {
            case AttributeType.Binary:
                return(ComparisonEngine.CompareBinary((byte[])valueChange.Value, this.Value, this.Operator));

            case AttributeType.Boolean:
                return(ComparisonEngine.CompareBoolean(valueChange.Value as string, this.Value, this.Operator));

            case AttributeType.Integer:
                return(ComparisonEngine.CompareLong(valueChange.Value as string, this.Value, this.Operator));

            case AttributeType.String:
                return(ComparisonEngine.CompareString((string)valueChange.Value, this.Value, this.Operator));

            case AttributeType.Reference:
            default:
                throw new NotSupportedException();
            }
        }
        /// <summary>
        /// Evaluates a specific value against the rule
        /// </summary>
        /// <param name="value">The value to evaluate</param>
        /// <returns>A value indicating whether the rule conditions were met</returns>
        protected bool EvaluateAttributeValue(object value)
        {
            if (value == null)
            {
                return(false);
            }

            switch (MASchema.Attributes[this.AttributeName].Type)
            {
            case AttributeType.Binary:
                return(ComparisonEngine.CompareBinary((byte[])value, this.Value, this.Operator));

            case AttributeType.Boolean:
                return(ComparisonEngine.CompareBoolean((bool)value, this.Value, this.Operator));

            case AttributeType.Integer:
                return(ComparisonEngine.CompareLong((long)value, this.Value, this.Operator));

            case AttributeType.String:
                return(ComparisonEngine.CompareString((string)value, this.Value, this.Operator));

            case AttributeType.Reference:
            default:
                throw new NotSupportedException();
            }
        }
Example #3
0
        /// <summary>
        /// Determines if the specified multi-valued attribute change matches this object filter
        /// </summary>
        /// <param name="attributeChange">The attribute change object</param>
        /// <returns>A value indicating whether the specified object should be filtered from the result set</returns>
        private bool IsFilteredMultiValue(AttributeChange attributeChange)
        {
            foreach (ValueChange valueChange in attributeChange.ValueChanges.Where(t => t.ModificationType == ValueModificationType.Add))
            {
                bool result;

                switch (this.Attribute.Type)
                {
                case AttributeType.Binary:
                    result = ComparisonEngine.CompareBinary((byte[])valueChange.Value, this.Value, this.Operator);
                    break;

                case AttributeType.Boolean:
                    result = ComparisonEngine.CompareBoolean(valueChange.Value as string, this.Value, this.Operator);
                    break;

                case AttributeType.Integer:
                    result = ComparisonEngine.CompareLong(valueChange.Value as string, this.Value, this.Operator);
                    break;

                case AttributeType.String:
                    result = ComparisonEngine.CompareString((string)valueChange.Value, this.Value, this.Operator);
                    break;

                case AttributeType.Reference:
                    result = ComparisonEngine.CompareString((string)valueChange.Value, this.Value, this.Operator);
                    break;

                default:
                    throw new NotSupportedException();
                }

                if (result)
                {
                    return(result);
                }
            }

            return(false);
        }