Exemplo n.º 1
0
 public MAPIProperty(Int32 Tag) : this()
 {
     _tag  = Tag;
     _type = MAPITagToType(Tag);
 }
Exemplo n.º 2
0
 public MAPIProperty(Int16 Tag, MAPIPropertyType Type) : this()
 {
     _tag  = Tag * 0x10000;
     _type = Type;
 }
Exemplo n.º 3
0
 UInt32 GetPropertyTag(MAPIPropertyType mapiPropertyType)
 {
     UInt16 propertyType = 0;
     switch (mapiPropertyType)
     {
         case MAPIPropertyType.BOOL:
             propertyType = (UInt16)PropertyType.PT_BOOLEAN;
             break;
         case MAPIPropertyType.ByteArray:
             propertyType = (UInt16)PropertyType.PT_BINARY;
             break;
         case MAPIPropertyType.DateTime:
             propertyType = (UInt16)PropertyType.PT_SYSTIME;
             break;
         case MAPIPropertyType.Double:
             propertyType = (UInt16)PropertyType.PT_DOUBLE;
             break;
         case MAPIPropertyType.Int16:
             propertyType = (UInt16)PropertyType.PT_I2;
             break;
         case MAPIPropertyType.Int32:
             propertyType = (UInt16)PropertyType.PT_LONG;
             break;
         case MAPIPropertyType.Int64:
             propertyType = (UInt16)PropertyType.PT_I8;
             break;
         case MAPIPropertyType.String:
             propertyType = (UInt16)PropertyType.PT_UNICODE;
             break;
         default:
             throw new NotSupportedException();
     }
     return ((UInt32)tagBegin++ << 16) | propertyType;
 }
Exemplo n.º 4
0
 void SetValue(byte[] value, int length, MAPIPropertyType propertyType)
 {
     byte[] buffer = null;
     switch (propertyType)
     {
         case MAPIPropertyType.BOOL:
             if (totalData++ % 2 == 0)
                 value[0] = 0x00;
             else
                 value[0] = 0x01;
             break;
         case MAPIPropertyType.ByteArray:
             for (int index = 0; index < length; index++)
             {
                 value[index] = (byte)(totalData++);
             }
             break;
         case MAPIPropertyType.DateTime:
             var dateTime = DateTime.Now.ToFileTimeUtc();
             buffer = BitConverter.GetBytes(dateTime);
             Array.Copy(buffer, 0, value, 0, length);
             break;
         case MAPIPropertyType.Double:
             double d = (double)random.NextDouble();
             buffer = BitConverter.GetBytes(d);
             Array.Copy(buffer, 0, value, 0, length);
             break;
         case MAPIPropertyType.Int16:
             Int16 i = (Int16)random.Next(UInt16.MinValue, UInt16.MaxValue);
             buffer = BitConverter.GetBytes(i);
             Array.Copy(buffer, 0, value, 0, length);
             break;
         case MAPIPropertyType.Int32:
             Int32 i16 = (Int32)random.Next((int)UInt32.MinValue, int.MaxValue);
             buffer = BitConverter.GetBytes(i16);
             Array.Copy(buffer, 0, value, 0, length);
             break;
         case MAPIPropertyType.Int64:
             Int64 i64 = (Int64)random.Next((int)UInt64.MinValue, int.MaxValue);
             buffer = BitConverter.GetBytes(i64);
             Array.Copy(buffer, 0, value, 0, length);
             break;
         case MAPIPropertyType.String:
             StringBuilder sb = new StringBuilder();
             for(int index = 0 ; index < length - 2;index++)
             {
                 sb.Append(totalData++ % 10);
             }
             buffer = Encoding.Unicode.GetBytes(sb.ToString());
             Array.Copy(buffer, 0, value, 0, buffer.Length);
             value[length - 2] = 0x00;
             value[length - 1] = 0x00;
             break;
         default:
             throw new NotSupportedException();
     }
 }
Exemplo n.º 5
0
 private int GetPropertyLength(MAPIPropertyType propertyType)
 {
     switch (propertyType)
     {
         case MAPIPropertyType.BOOL:
             return 1;
         case MAPIPropertyType.ByteArray:
             return random.Next() % 64;
         case MAPIPropertyType.DateTime:
             return 8;
         case MAPIPropertyType.Double:
             return 8;
         case MAPIPropertyType.Int16:
             return 2;
         case MAPIPropertyType.Int32:
             return 4;
         case MAPIPropertyType.Int64:
             return 8;
         case MAPIPropertyType.String:
             return random.Next() % 64;
         default:
             return 0;
     }
 }