示例#1
0
 /// <summary>
 /// Checks a reply for error. If reply has error relevant exception is thrown
 /// </summary>
 /// <param name='reply'>
 /// The reply to check
 /// </param>
 /// <param name='expectedLength'>
 /// Expected reply length
 /// </param>
 /// <param name='cleanUp'>
 /// Clean up method called before the exception is thrown
 /// </param>
 public static void CheckForError(Reply reply, byte expectedLength, CleanUpMethod cleanUp)
 {
     if (reply.HasError)
     {
         if (cleanUp != null)
         {
             cleanUp();
         }
         ThrowException(reply);
     }
     if (reply.Length != expectedLength)
     {
         if (cleanUp != null)
         {
             cleanUp();
         }
         throw new BrickException(BrickError.WrongNumberOfBytes);
     }
 }
示例#2
0
 private static void CheckForError(Reply reply, int expectedLength, UInt16 expectedSequenceNumber, CleanUpMethod cleanUp, bool ignoreLength)
 {
     if (reply.HasError)
     {
         if (cleanUp != null)
         {
             cleanUp();
         }
         ThrowException(reply);
     }
     if (!ignoreLength)
     {
         if (reply.Length != expectedLength)
         {
             if (cleanUp != null)
             {
                 cleanUp();
             }
             throw new BrickException(BrickError.WrongNumberOfBytes);
         }
     }
     if (reply.SequenceNumber != expectedSequenceNumber)
     {
         if (cleanUp != null)
         {
             cleanUp();
         }
         throw new BrickException(BrickError.WrongSequenceNumber);
     }
 }
示例#3
0
 /// <summary>
 /// Checks a reply for error. If reply has error relevant exception is thrown
 /// </summary>
 /// <param name='reply'>
 /// The reply to check
 /// </param>
 /// <param name='expectedLength'>
 /// Expected reply length
 /// </param>
 /// <param name='expectedSequenceNumber'>
 /// Expected sequence number
 /// </param>
 /// <param name='cleanUp'>
 /// Clean up method called before the exception is thrown
 /// </param>
 public static void CheckForError(Reply reply, int expectedLength, UInt16 expectedSequenceNumber, CleanUpMethod cleanUp)
 {
     CheckForError(reply, expectedLength, expectedSequenceNumber, cleanUp, false);
 }
		private static void CheckForError(Reply reply, int expectedLength, UInt16 expectedSequenceNumber, CleanUpMethod cleanUp, bool ignoreLength){
			if(reply.HasError){
				if(cleanUp!= null){
					cleanUp();
				}
				ThrowException(reply);
			}
			if (!ignoreLength) {
				if (reply.Length != expectedLength) {
					if (cleanUp != null) {
							cleanUp ();
					}
					throw new BrickException (BrickError.WrongNumberOfBytes);
				}
			}
			if(reply.SequenceNumber != expectedSequenceNumber){
				if(cleanUp!= null){
					cleanUp();
				}
				throw new BrickException(BrickError.WrongSequenceNumber);
			}
		}
		/// <summary>
		/// Checks a reply for error. If reply has error relevant exception is thrown
		/// </summary>
		/// <param name='reply'>
		/// The reply to check
		/// </param>
		/// <param name='expectedLength'>
		/// Expected reply length
		/// </param>
		/// <param name='expectedSequenceNumber'>
		/// Expected sequence number
		/// </param>
		/// <param name='cleanUp'>
		/// Clean up method called before the exception is thrown
		/// </param>
		public static void CheckForError(Reply reply, int expectedLength, UInt16 expectedSequenceNumber, CleanUpMethod cleanUp){
			CheckForError (reply, expectedLength, expectedSequenceNumber, cleanUp, false);
		}
		/// <summary>
		/// Checks a reply for error. If reply has error relevant exception is thrown
		/// </summary>
		/// <param name='reply'>
		/// The reply to check
		/// </param>
		/// <param name='expectedLength'>
		/// Expected reply length
		/// </param>
		/// <param name='cleanUp'>
		/// Clean up method called before the exception is thrown
		/// </param>
		public static void CheckForError(Reply reply, byte expectedLength, CleanUpMethod cleanUp){
			if(reply.HasError){
				if(cleanUp!= null){
					cleanUp();
				}
				ThrowException(reply);
			}
			if(reply.Length != expectedLength){
				if(cleanUp!= null){
					cleanUp();
				}
				throw new BrickException(BrickError.WrongNumberOfBytes);
			}
		}
示例#7
0
 public static void Add(CleanUpMethod method)
 {
     methods.Add(method);
 }