Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Serializable]
- public class PaymentExceptionTranslationAspect : OnExceptionAspect
- {
- public override void OnException(MethodExecutionArgs args)
- {
- Type type = args.Exception.GetType();
- if (type.BaseType == typeof(PaymentException) && type.IsGenericType)
- {
- var fault = type.GetProperty("Fault").GetGetMethod().Invoke(args.Exception, null);
- throw (Exception)typeof(FaultException<>)
- .MakeGenericType(fault.GetType())
- .GetConstructor(new Type[] { fault.GetType(), typeof(string) })
- .Invoke(new object[] { fault, args.Exception.Message });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement