LCOV - code coverage report
Current view: top level - Cqrs/Infrastructure - DelegateAdjuster.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 2 0.0 %
Date: 2017-07-26

          Line data    Source code
       1             : #region Copyright
       2             : // // -----------------------------------------------------------------------
       3             : // // <copyright company="cdmdotnet Limited">
       4             : // //   Copyright cdmdotnet Limited. All rights reserved.
       5             : // // </copyright>
       6             : // // -----------------------------------------------------------------------
       7             : #endregion
       8             : 
       9             : using System;
      10             : using System.Linq.Expressions;
      11             : 
      12             : namespace Cqrs.Infrastructure
      13             : {
      14             :         public static class DelegateAdjuster
      15           0 :         {
      16           0 :                 public static Action<TBase> CastArgument<TBase, TDerived>(Expression<Action<TDerived>> source)
      17             :                         where TDerived : TBase
      18             :                 {
      19             :                         if (typeof(TDerived) == typeof(TBase))
      20             :                         {
      21             :                                 return (Action<TBase>)((Delegate)source.Compile());
      22             :                         }
      23             : 
      24             :                         ParameterExpression sourceParameter = Expression.Parameter(typeof(TBase), "source");
      25             :                         Expression<Action<TBase>> result = Expression.Lambda<Action<TBase>>
      26             :                         (
      27             :                                 Expression.Invoke(source, Expression.Convert(sourceParameter, typeof(TDerived))),
      28             :                                 sourceParameter
      29             :                         );
      30             :                         return result.Compile();
      31             :                 }
      32             :         }
      33             : }
      34             : 

Generated by: LCOV version 1.10