DefconDotNet

Untitled

Jun 28th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1.  
  2.             public static void DoGenericValidation(VatDeclaration declaration)
  3.             {
  4.                 DoGenericValidation<VatDeclarationException>(declaration);
  5.             }
  6.  
  7.             public static void DoGenericValidation(IcpDeclaration declaration)
  8.             {
  9.                 DoGenericValidation<IcpDeclarationException>(declaration);
  10.             }
  11.  
  12.             private static void DoGenericValidation<T>(DeclarationBase declaration) where T : Exception, new()
  13.             {
  14.                 if(declaration.Period != "Corrent")
  15.                     throw new T("Error01", "Period is wrong");
  16.  
  17.                 throw new T("Error02", "Something else is wrong");
  18.             }
  19.             public class IcpDeclarationException : FaultException
  20.             {
  21.                 public IcpDeclarationException(string code, string description)
  22.                     : base(new FaultReason(description), new FaultCode("AI" + code))
  23.                 {
  24.                 }
  25.  
  26.                 public string OnzeCode { get; set; }
  27.             }
Advertisement
Add Comment
Please, Sign In to add comment