Ejemplo n.º 1
0
        public bool TryGetValue(TnefPropertyId propertyId, out TnefNameId namedId)
        {
            TnefNameIdWrapper tnefNameIdWrapper = null;

            if (!this.idToName.TryGetValue(propertyId, out tnefNameIdWrapper))
            {
                namedId = default(TnefNameId);
                return(false);
            }
            namedId = tnefNameIdWrapper.TnefNameId;
            return(true);
        }
Ejemplo n.º 2
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();
     }
 }
Ejemplo n.º 3
0
        private bool TryAdd(TnefPropertyId id, TnefNameId namedProperty)
        {
            TnefNameIdWrapper tnefNameIdWrapper;

            if (this.idToName.TryGetValue(id, out tnefNameIdWrapper))
            {
                return(false);
            }
            tnefNameIdWrapper = new TnefNameIdWrapper(namedProperty);
            this.idToName[id] = tnefNameIdWrapper;
            this.nameToId[tnefNameIdWrapper] = id;
            return(true);
        }
Ejemplo n.º 4
0
        public TnefPropertyId Add(TnefNameId namedProperty)
        {
            if (!this.canModify)
            {
                throw new InvalidOperationException("Cannot modify the property list");
            }
            TnefNameIdWrapper tnefNameIdWrapper = new TnefNameIdWrapper(namedProperty);
            TnefPropertyId    tnefPropertyId;

            if (!this.nameToId.TryGetValue(tnefNameIdWrapper, out tnefPropertyId))
            {
                tnefPropertyId = (TnefPropertyId)(this.lastPropertyId++);
                this.idToName.Add(tnefPropertyId, tnefNameIdWrapper);
                this.nameToId.Add(tnefNameIdWrapper, tnefPropertyId);
            }
            return(tnefPropertyId);
        }
Ejemplo n.º 5
0
        public override bool Equals(object obj)
        {
            TnefNameIdWrapper tnefNameIdWrapper = obj as TnefNameIdWrapper;

            return(tnefNameIdWrapper != null && this.PropertySetGuid == tnefNameIdWrapper.PropertySetGuid && this.Id == tnefNameIdWrapper.Id && this.Name == tnefNameIdWrapper.Name);
        }