Exemple #1
0
        /// <summary>
        ///     Adds a <see cref="NamedPropertyTag" />
        /// </summary>
        /// <remarks>
        ///     Only support for properties by ID for now.
        /// </remarks>
        /// <param name="mapiTag"></param>
        /// <param name="obj"></param>
        internal void AddProperty(NamedPropertyTag mapiTag, object obj)
        {
            // Named property field 0000. 0x8000 + property offset
            //_topLevelProperties.AddProperty(new PropertyTag((ushort)(0x8000 + _namedPropertyIndex++), mapiTag.Type), obj);

            var propertyIndex = (ushort)(0x8000 + this.Count);
            var kind          = mapiTag.Name.StartsWith("PidName") ? PropertyKind.Name : PropertyKind.Lid;
            var namedProperty = new NamedProperty
            {
                NameIdentifier = kind == PropertyKind.Lid ? mapiTag.Id : propertyIndex,
                Guid           = mapiTag.Guid,
                Kind           = kind,
                Name           = mapiTag.Name.Replace("PidName", "").Replace("PidLid", ""),
                NameSize       = (uint)(kind == PropertyKind.Name ? mapiTag.Name.Length : 0)
            };

            if (mapiTag.Guid != PropertySets.PS_MAPI &&
                mapiTag.Guid != PropertySets.PS_PUBLIC_STRINGS &&
                !Guids.Contains(mapiTag.Guid))
            {
                Guids.Add(mapiTag.Guid);
            }

            _topLevelProperties.AddProperty(new PropertyTag(propertyIndex, mapiTag.Type), obj);

            Add(namedProperty);
        }
        private static void CreateTempDir()
        {
            Directory.CreateDirectory(_TempDir);

            FSW = new FileSystemWatcher(_TempDir);

            FSW.Deleted += (sender, e) =>
            {
                if (Guids.Contains(e.Name))
                {
                    Guids.Remove(e.Name);
                }
            };

            FSW.EnableRaisingEvents = true;
        }