Advertisement
magnusbakken

Untitled

Jan 31st, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1.     [Serializable]
  2.     public class PaymentExceptionTranslationAspect : OnExceptionAspect
  3.     {
  4.         public override void OnException(MethodExecutionArgs args)
  5.         {
  6.             Type type = args.Exception.GetType();
  7.             if (type.BaseType == typeof(PaymentException) && type.IsGenericType)
  8.             {
  9.                 var fault = type.GetProperty("Fault").GetGetMethod().Invoke(args.Exception, null);
  10.                 throw (Exception)typeof(FaultException<>)
  11.                     .MakeGenericType(fault.GetType())
  12.                     .GetConstructor(new Type[] { fault.GetType(), typeof(string) })
  13.                     .Invoke(new object[] { fault, args.Exception.Message });
  14.             }
  15.         }
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement