internal static object DecodeFolderFlags(object extendedFolderFlagsInternalPropertyValue)
 {
     if (extendedFolderFlagsInternalPropertyValue is byte[])
     {
         ExtendedFolderFlagsProperty.ParsedFlags parsedFlags = new ExtendedFolderFlagsProperty.ParsedFlags();
         using (ParticipantEntryId.Reader reader = new ParticipantEntryId.Reader((byte[])extendedFolderFlagsInternalPropertyValue))
         {
             while (!reader.IsEnd)
             {
                 byte key = reader.ReadByte();
                 if (!reader.IsEnd)
                 {
                     byte b = reader.ReadByte();
                     if (reader.BytesRemaining >= (int)b)
                     {
                         parsedFlags[(ExtendedFolderFlagsProperty.FlagTag)key] = reader.ReadExactBytes((int)b);
                         continue;
                     }
                 }
                 return(new PropertyError(InternalSchema.ExtendedFolderFlags, PropertyErrorCode.CorruptedData));
             }
         }
         return(parsedFlags);
     }
     return(extendedFolderFlagsInternalPropertyValue);
 }
Пример #2
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            object obj = ExtendedFolderFlagsProperty.DecodeFolderFlags(propertyBag.GetValue(InternalSchema.ExtendedFolderFlagsInternal));

            ExtendedFolderFlagsProperty.ParsedFlags parsedFlags = obj as ExtendedFolderFlagsProperty.ParsedFlags;
            return(parsedFlags != null && parsedFlags.ContainsKey(ExtendedFolderFlagsProperty.FlagTag.Clsid));
        }
 protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
 {
     ExtendedFolderFlagsProperty.ParsedFlags parsedFlags = ExtendedFolderFlagsProperty.DecodeFolderFlags(propertyBag.GetValue(InternalSchema.ExtendedFolderFlagsInternal)) as ExtendedFolderFlagsProperty.ParsedFlags;
     if (parsedFlags == null)
     {
         parsedFlags = new ExtendedFolderFlagsProperty.ParsedFlags();
     }
     parsedFlags[this.flag] = BitConverter.GetBytes((int)value);
     propertyBag.SetValueWithFixup(InternalSchema.ExtendedFolderFlagsInternal, ExtendedFolderFlagsProperty.EncodeFolderFlags(parsedFlags));
 }
 protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
 {
     byte[] value2 = ((Guid)value).ToByteArray();
     ExtendedFolderFlagsProperty.ParsedFlags parsedFlags = ExtendedFolderFlagsProperty.DecodeFolderFlags(propertyBag.GetValue(InternalSchema.ExtendedFolderFlagsInternal)) as ExtendedFolderFlagsProperty.ParsedFlags;
     if (parsedFlags == null)
     {
         parsedFlags = new ExtendedFolderFlagsProperty.ParsedFlags();
     }
     parsedFlags[ExtendedFolderFlagsProperty.FlagTag.Clsid] = value2;
     propertyBag.SetValueWithFixup(InternalSchema.ExtendedFolderFlagsInternal, ExtendedFolderFlagsProperty.EncodeFolderFlags(parsedFlags));
 }
        internal static byte[] EncodeFolderFlags(ExtendedFolderFlagsProperty.ParsedFlags flags)
        {
            MemoryStream memoryStream = new MemoryStream();

            using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
            {
                foreach (KeyValuePair <ExtendedFolderFlagsProperty.FlagTag, byte[]> keyValuePair in flags)
                {
                    binaryWriter.Write((byte)keyValuePair.Key);
                    binaryWriter.Write((byte)keyValuePair.Value.Length);
                    binaryWriter.Write(keyValuePair.Value);
                }
            }
            return(memoryStream.ToArray());
        }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            object obj = ExtendedFolderFlagsProperty.DecodeFolderFlags(propertyBag.GetValue(InternalSchema.ExtendedFolderFlagsInternal));

            if (!(obj is ExtendedFolderFlagsProperty.ParsedFlags))
            {
                return(obj);
            }
            ExtendedFolderFlagsProperty.ParsedFlags parsedFlags = (ExtendedFolderFlagsProperty.ParsedFlags)obj;
            if (parsedFlags.ContainsKey(this.flag))
            {
                return((ExtendedFolderFlags)BitConverter.ToInt32(parsedFlags[this.flag], 0));
            }
            return(new PropertyError(this, PropertyErrorCode.NotFound));
        }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            object obj = ExtendedFolderFlagsProperty.DecodeFolderFlags(propertyBag.GetValue(InternalSchema.ExtendedFolderFlagsInternal));

            ExtendedFolderFlagsProperty.ParsedFlags parsedFlags = obj as ExtendedFolderFlagsProperty.ParsedFlags;
            if (parsedFlags != null)
            {
                byte[] b;
                if (parsedFlags.TryGetValue(ExtendedFolderFlagsProperty.FlagTag.Clsid, out b))
                {
                    try
                    {
                        return(new Guid(b));
                    }
                    catch (ArgumentException)
                    {
                        return(new PropertyError(this, PropertyErrorCode.CorruptedData));
                    }
                }
                return(new PropertyError(this, PropertyErrorCode.NotFound));
            }
            return(obj);
        }