/// <summary>
        /// Gets the cached delegate for the specified type. If the delegate does not exist in the cache, it
        /// will automatically be created when this method is called.
        /// </summary>
        /// <param name="type">The type for which to retrieve a comparison delegate.</param>
        /// <param name="op">A <see cref="TriggerComparisonOp"/> value which specifies the type of the comparison operation.</param>
        /// <returns>The cached <see cref="TriggerComparison"/> delegate for the specified type and operation, or <see langword="null"/>
        /// if the specified operation is not supported by the given type.</returns>
        public static TriggerComparison Get(Type type, TriggerComparisonOp op)
        {
            lock (cache)
            {
                Dictionary <Int32, TriggerComparison> cacheForType;
                if (!cache.TryGetValue(type, out cacheForType))
                {
                    cache[type] = cacheForType = new Dictionary <Int32, TriggerComparison>();
                    CreateComparisonDelegates(type);
                }

                TriggerComparison comparison;
                cacheForType.TryGetValue((Int32)op, out comparison);
                return(comparison);
            }
        }
        /// <summary>
        /// Gets the cached delegate for the specified type. If the delegate does not exist in the cache, it
        /// will automatically be created when this method is called.
        /// </summary>
        /// <param name="type">The type for which to retrieve a comparison delegate.</param>
        /// <param name="op">A <see cref="TriggerComparisonOp"/> value which specifies the type of the comparison operation.</param>
        /// <returns>The cached <see cref="TriggerComparison"/> delegate for the specified type and operation, or <c>null</c>
        /// if the specified operation is not supported by the given type.</returns>
        public static TriggerComparison Get(Type type, TriggerComparisonOp op)
        {
            lock (cache)
            {
                Dictionary<Int32, TriggerComparison> cacheForType;
                if (!cache.TryGetValue(type, out cacheForType))
                {
                    cache[type] = cacheForType = new Dictionary<Int32, TriggerComparison>();
                    CreateComparisonDelegates(type);
                }

                TriggerComparison comparison;
                cacheForType.TryGetValue((Int32)op, out comparison);
                return comparison;
            }
        }
예제 #3
0
        /// <summary>
        /// Converts a <see cref="TriggerComparisonOp"/> value to the corresponding symbol.
        /// </summary>
        /// <param name="op">The <see cref="TriggerComparisonOp"/> value to convert.</param>
        /// <returns>A symbol that represents the specified operation.</returns>
        public static String ConvertToSymbol(this TriggerComparisonOp op)
        {
            switch (op)
            {
            case TriggerComparisonOp.Equals:
                return("=");

            case TriggerComparisonOp.NotEquals:
                return("<>");

            case TriggerComparisonOp.GreaterThan:
                return(">");

            case TriggerComparisonOp.GreaterThanOrEqualTo:
                return(">=");

            case TriggerComparisonOp.LessThan:
                return("<");

            case TriggerComparisonOp.LessThanOrEqualTo:
                return("<=");
            }
            throw new ArgumentOutOfRangeException("op");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyTriggerCondition"/> class.
 /// </summary>
 /// <param name="op">A <see cref="TriggerComparisonOp"/> value that specifies the type of comparison performed by this condition.</param>
 /// <param name="dpropName">The name of the dependency property to evaluate.</param>
 /// <param name="refval">The reference value to compare to the value of the dependency property.</param>
 internal PropertyTriggerCondition(TriggerComparisonOp op, String dpropName, String refval)
 {
     this.op        = op;
     this.dpropName = new UvmlName(dpropName);
     this.refval    = refval;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UvssPropertyTriggerCondition"/> class.
 /// </summary>
 /// <param name="op">A <see cref="TriggerComparisonOp"/> value that specifies the type of comparison performed by this condition.</param>
 /// <param name="propertyName">The name of the property to evaluate.</param>
 /// <param name="propertyValue">The value to compare to the value of the evaluated property.</param>
 internal UvssPropertyTriggerCondition(TriggerComparisonOp op, DependencyName propertyName, DependencyValue propertyValue)
 {
     this.op            = op;
     this.propertyName  = propertyName;
     this.propertyValue = propertyValue;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UvssPropertyTriggerCondition"/> class.
 /// </summary>
 /// <param name="op">A <see cref="TriggerComparisonOp"/> value that specifies the type of comparison performed by this condition.</param>
 /// <param name="propertyName">The name of the property to evaluate.</param>
 /// <param name="propertyValue">The value to compare to the value of the evaluated property.</param>
 internal UvssPropertyTriggerCondition(TriggerComparisonOp op, DependencyName propertyName, DependencyValue propertyValue)
 {
     this.op = op;
     this.propertyName = propertyName;
     this.propertyValue = propertyValue;
 }