예제 #1
0
 internal static void VerifyProtocol(bool condition, string unformattedMessage, params object[] args)
 {
     Requires.NotNull(args, "args");
     Assumes.True(unformattedMessage != null);
     if (!condition)
     {
         var exception = new ProtocolException(string.Format(CultureInfo.CurrentCulture, unformattedMessage, args));
         if (Logger.Messaging.IsErrorEnabled)
         {
             Logger.Messaging.Error(
                 string.Format(
                     CultureInfo.CurrentCulture,
                     "Protocol error: {0}{1}{2}",
                     exception.Message,
                     Environment.NewLine,
                     new StackTrace()));
         }
         throw exception;
     }
 }
예제 #2
0
 internal static void VerifyProtocol(bool condition, string message, params object[] args)
 {
     Contract.Requires <ArgumentNullException>(args != null);
     Contract.Ensures(condition);
     Contract.EnsuresOnThrow <ProtocolException>(!condition);
     Contract.Assume(message != null);
     if (!condition)
     {
         var exception = new ProtocolException(string.Format(CultureInfo.CurrentCulture, message, args));
         if (Logger.Messaging.IsErrorEnabled)
         {
             Logger.Messaging.Error(
                 string.Format(
                     CultureInfo.CurrentCulture,
                     "Protocol error: {0}{1}{2}",
                     exception.Message,
                     Environment.NewLine,
                     new StackTrace()));
         }
         throw exception;
     }
 }