Beispiel #1
0
 /// <summary>
 /// Raises the LambdaValuesChanged event.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="operation"></param>
 /// <param name="oldValue"></param>
 /// <param name="newValue"></param>
 void RaiseValueChanged(TSource item, LambdaOperation <TResult> operation, TResult oldValue, TResult newValue)
 {
     if (ValueChanged != null)
     {
         ValueChanged(this, new LambdaValueChangedEventArgs <TSource, TResult>(item, operation, oldValue, newValue));
     }
 }
Beispiel #2
0
        /// <summary>
        /// Disposes of the given lambda operation.
        /// </summary>
        /// <param name="lambda"></param>
        void ReleaseLambdaOperation(LambdaOperation <TResult> lambda)
        {
            // remove from selectors
            lambdas.Remove((TSource)lambda.Tag);

            // dispose of selector and variables
            lambda.ValueChanged -= lambda_ValueChanged;
            lambda.Dispose();
            foreach (var var in lambda.Context.Variables)
            {
                var.Value.Dispose();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new lambda operation.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        LambdaOperation <TResult> CreateLambdaOperation(TSource item)
        {
            // generate new context
            var ctx = CreateContextAction(item, Expression.Parameters.ToArray());

            if (ctx == null)
            {
                throw new InvalidOperationException("Could not generate context for new lambda operation.");
            }

            // create new test and subscribe to test modifications
            var lambda = new LambdaOperation <TResult>(ctx, Expression);

            lambda.Tag           = item;
            lambda.ValueChanged += lambda_ValueChanged;
            lambdas[item]        = lambda;

            return(lambda);
        }
Beispiel #4
0
 /// <summary>
 /// Gets the original source for the given lambda.
 /// </summary>
 /// <param name="lambda"></param>
 /// <returns></returns>
 public TSource this[LambdaOperation <TResult> lambda]
 {
     get { return((TSource)lambda.Tag); }
 }
Beispiel #5
0
 public int Compare(LambdaOperation <TResult> x, LambdaOperation <TResult> y)
 {
     return(comparer.Compare(x.Value, y.Value));
 }