Esempio n. 1
0
 public TWO_BYTE_UNSIGNED_INTEGER(ushort num)
 {
     if (num > 0x7FFF)
     {
         throw new ArgumentException("The integer is out of the valid range of TWO_BYTE_UNSIGNED_INTEGER.", "num");
     }
     if (num > 0x7F)
     {
         c = TWO_BYTE_C_Values.TWO_BYTE_VAL;
         val1 = (byte)(num >> 8);
         val2 = (byte)(num & 0xFF);
     }
     else
     {
         c = TWO_BYTE_C_Values.ONE_BYTE_VAL;
         val1 = (byte)num;
     }
 }
Esempio n. 2
0
 public bool Decode(PduMarshaler marshaler)
 {
     try
     {
         byte t = marshaler.ReadByte();
         c = (TWO_BYTE_C_Values)(t >> 7);
         val1 = (byte)(t & 0x7F);
         if (c == TWO_BYTE_C_Values.TWO_BYTE_VAL)
         {
             val2 = marshaler.ReadByte();
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
Esempio n. 3
0
 public TWO_BYTE_SIGNED_INTEGER(short num)
 {
     if (num > 0x3FFF || num < -0x3FFF)
     {
         throw new ArgumentException("The integer is out of the valid range of TWO_BYTE_SIGNED_INTEGER.", "num");
     }
     ushort n;
     if (num < 0)
     {
         n = (ushort)(-num);
         s = S_Values.NEGATIVE_VAL;
     }
     else
     {
         n = (ushort)num;
         s = S_Values.POSITIVE_VAL;
     }
     if (n > 0x3F)
     {
         c = TWO_BYTE_C_Values.TWO_BYTE_VAL;
         val1 = (byte)(n >> 8);
         val2 = (byte)n;
     }
     else
     {
         c = TWO_BYTE_C_Values.ONE_BYTE_VAL;
         val1 = (byte)n;
     }
 }