Ejemplo n.º 1
0
        /// <summary>
        /// Merges the member initialization list of two lambda expressions into one.
        /// </summary>
        /// <typeparam name="TSource">Source type.</typeparam>
        /// <typeparam name="TBaseDest">Resulting type of the base mapping expression. TBaseDest is
        /// typically a super class of TExtendedDest</typeparam>
        /// <typeparam name="TExtendedDest">Resulting type of the extended mapping expression.</typeparam>
        /// <param name="baseExpression">The base mapping expression, containing a member
        /// initialization expression.</param>
        /// <param name="mergeExpression">The extended mapping expression to be merged into the
        /// base member initialization expression.</param>
        /// <returns>Resulting expression, after the merged select expression has been applied.</returns>
        public static Expression <Func <TSource, TExtendedDest> > Merge <TSource, TBaseDest, TExtendedDest>(
            this Expression <Func <TSource, TBaseDest> > baseExpression,
            Expression <Func <TSource, TExtendedDest> > mergeExpression)
        {
            var visitor = new MergingVisitor <TSource, TBaseDest, TExtendedDest>(baseExpression);

            return((Expression <Func <TSource, TExtendedDest> >)visitor.Visit(mergeExpression));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Merges the member initialization list of two lambda expressions into one.
        /// </summary>
        /// <typeparam name="TSource">Source type.</typeparam>
        /// <typeparam name="TBaseDest">Resulting type of the base mapping expression. TBaseDest is
        /// typically a super class of TExtendedDest</typeparam>
        /// <typeparam name="TExtendedDest">Resulting type of the extended mapping expression.</typeparam>
        /// <param name="baseExpression">The base mapping expression, containing a member
        /// initialization expression.</param>
        /// <param name="mergeExpression">The extended mapping expression to be merged into the
        /// base member initialization expression.</param>
        /// <returns>Resulting expression, after the merged select expression has been applied.</returns>
        public static Expression <Func <TSource, TExtendedDest> > Merge <TSource, TBaseDest, TExtendedDest>(
            this Expression <Func <TSource, TBaseDest> > baseExpression,
            Expression <Func <TSource, TExtendedDest> > mergeExpression)
        {
            // Use an expression visitor to perform the merge of the select expressions.
            var visitor = new MergingVisitor <TSource, TBaseDest, TExtendedDest>(baseExpression);

            return((Expression <Func <TSource, TExtendedDest> >)visitor.Visit(mergeExpression));
        }
Ejemplo n.º 3
0
		private void mergeMetrics(){
			for(int index = 0 ; index < ( metrics.Count - 1) ; index++) {
				CSF_metric original = metrics[index];
				MergingVisitor visitor = new MergingVisitor(original);
				for(int endIndex = index+1 ; endIndex < metrics.Count; ) {
					CSF_metric toBeMerged = metrics[endIndex];
					if(toBeMerged.aceptWithBool(visitor)) {
						metrics.RemoveAt(endIndex);
					} else {
						endIndex++;
					}
				}
			}
		}