Example #1
0
 private static void WriteCustomHeader(string key, object val, IMapContainer map)
 {
     if (val is string)
     {
         map.AddString(key, val as string);
     }
     else if (val is Int16 || val is short)
     {
         map.AddInt16(key, (short)val);
     }
     else if (val is Int32 || val is int)
     {
         map.AddInt32(key, (int)val);
     }
     else if (val is Int64 || val is long)
     {
         map.AddInt64(key, (long)val);
     }
     else if (val is bool)
     {
         map.AddBool(key, (bool)val);
     }
     else if (val is float)
     {
         map.AddFloat(key, (float)val);
     }
     else if (val is double)
     {
         map.AddDouble(key, (double)val);
     }
     else if (val is UInt16 || val is ushort)
     {
         map.AddUInt16(key, (short)val);
     }
     else if (val is UInt32 || val is uint)
     {
         map.AddUInt32(key, (uint)val);
     }
     else if (val is UInt64 || val is ulong)
     {
         map.AddUInt64(key, (long)val);
     }
     else if (val is byte)
     {
         map.AddUInt8(key, (byte)val);
     }
     else if (val is sbyte)
     {
         map.AddInt8(key, (sbyte)val);
     }
     else if (val is byte[])
     {
         map.AddByteArray(key, (byte[])val);
     }
     else if (val is char)
     {
         map.AddChar(key, (char)val);
     }
     else
     {
         throw new MessagingException("Unsupported app header type" + val.GetType());
     }
 }