Пример #1
0
 public void WriteTo(ComStorage messageStorage)
 {
     using (ComStorage comStorage = messageStorage.CreateStorage("__nameid_version1.0", ComStorage.OpenMode.CreateWrite))
     {
         List <Guid> list = new List <Guid>(32);
         list.AddRange(NamedPropertyList.StandardGuids);
         Dictionary <Guid, int> dictionary = new Dictionary <Guid, int>(32);
         int num = 0;
         foreach (Guid key in list)
         {
             dictionary[key] = num++;
         }
         using (BinaryWriter binaryWriter = new BinaryWriter(new BufferedStream(comStorage.CreateStream("__substg1.0_00030102", ComStorage.OpenMode.CreateWrite), 8192)))
         {
             using (BinaryWriter binaryWriter2 = new BinaryWriter(new BufferedStream(comStorage.CreateStream("__substg1.0_00040102", ComStorage.OpenMode.CreateWrite), 8192), new UnicodeEncoding(false, false)))
             {
                 foreach (TnefPropertyId tnefPropertyId in this.idToName.Keys)
                 {
                     bool isString = false;
                     TnefNameIdWrapper tnefNameIdWrapper = this.idToName[tnefPropertyId];
                     int count;
                     if (!dictionary.TryGetValue(tnefNameIdWrapper.PropertySetGuid, out count))
                     {
                         count = list.Count;
                         list.Add(tnefNameIdWrapper.PropertySetGuid);
                         dictionary.Add(tnefNameIdWrapper.PropertySetGuid, count);
                     }
                     int namedId;
                     if (tnefNameIdWrapper.Kind == TnefNameIdKind.Id)
                     {
                         namedId = tnefNameIdWrapper.Id;
                     }
                     else
                     {
                         namedId  = NamedPropertyList.WriteName(binaryWriter2, tnefNameIdWrapper.Name);
                         isString = true;
                     }
                     NamedPropertyList.NamedPropertyEntry namedPropertyEntry = new NamedPropertyList.NamedPropertyEntry(tnefPropertyId, isString, (ushort)count, namedId);
                     namedPropertyEntry.WriteEntry(binaryWriter);
                 }
             }
         }
         using (Stream stream = new BufferedStream(comStorage.CreateStream("__substg1.0_00020102", ComStorage.OpenMode.CreateWrite), 8192))
         {
             for (int i = 3; i < list.Count; i++)
             {
                 byte[] array = list[i].ToByteArray();
                 stream.Write(array, 0, array.Length);
             }
         }
         comStorage.Flush();
     }
 }
Пример #2
0
 public static NamedPropertyList.NamedPropertyEntry ReadEntry(byte[] byteArray, ref int position)
 {
     NamedPropertyList.NamedPropertyEntry result = default(NamedPropertyList.NamedPropertyEntry);
     result.namedId = BitConverter.ToInt32(byteArray, position);
     position      += 4;
     result.info    = BitConverter.ToUInt32(byteArray, position);
     position      += 4;
     if (((int)result.TnefPropertyId & 32768) == 0)
     {
         throw new MsgStorageException(MsgStorageErrorCode.CorruptNamedPropertyData, MsgStorageStrings.CorruptData);
     }
     return(result);
 }
Пример #3
0
        private static NamedPropertyList.NamedPropertyEntry[] ReadEntryList(ComStorage namedPropertiesStorage)
        {
            byte[] array = namedPropertiesStorage.ReadFromStreamMaxLength("__substg1.0_00030102", 262144);
            int    num   = 0;
            int    num2  = array.Length / 8;

            NamedPropertyList.NamedPropertyEntry[] array2 = new NamedPropertyList.NamedPropertyEntry[num2];
            for (int num3 = 0; num3 != num2; num3++)
            {
                array2[num3] = NamedPropertyList.NamedPropertyEntry.ReadEntry(array, ref num);
            }
            return(array2);
        }