private void Parse()
        {
            int num = 0;

            if (this.entryBlob != null && this.entryBlob.Length > 1)
            {
                for (;;)
                {
                    ushort num2 = Ex12ExRenEntryParser.ParseUInt16(this.entryBlob, num);
                    if (num2 == 0)
                    {
                        break;
                    }
                    Ex12ExRenEntryParser.ExFolderEntry exFolderEntry = this.GetExFolderEntry(num2);
                    num += 2;
                    ushort num3 = Ex12ExRenEntryParser.ParseUInt16(this.entryBlob, num);
                    num += 2;
                    int num4 = num;
                    while (num - num4 < (int)num3)
                    {
                        Ex12ExRenEntryParser.ParseEntryBlock(this.entryBlob, ref num, num3, ref exFolderEntry);
                    }
                    if (num + 2 >= this.entryBlob.Length)
                    {
                        return;
                    }
                }
                return;
            }
        }
        internal override void SetEntryId(DefaultFolderContext context, byte[] entryId)
        {
            Ex12ExRenEntryParser ex12ExRenEntryParser = Ex12ExRenEntryParser.FromBytes(this.GetLocationPropertyBag(context).TryGetProperty(this.Property) as byte[]);

            ex12ExRenEntryParser.Insert(this.persistenceId, entryId);
            base.SetEntryId(context, ex12ExRenEntryParser.ToBytes());
        }
        internal override FolderSaveResult UnsetEntryId(DefaultFolderContext context)
        {
            Ex12ExRenEntryParser ex12ExRenEntryParser = Ex12ExRenEntryParser.FromBytes(this.GetLocationPropertyBag(context).TryGetProperty(this.Property) as byte[]);

            ex12ExRenEntryParser.Remove(this.persistenceId);
            base.SetEntryId(context, ex12ExRenEntryParser.ToBytes());
            return(FolderPropertyBag.SuccessfulSave);
        }
        private static void DebugCheckReplaceBlob(byte[] newBlob, Ex12RenEntryIdStrategy.PersistenceId persistenceId, byte[] entryId)
        {
            Ex12ExRenEntryParser ex12ExRenEntryParser = new Ex12ExRenEntryParser(newBlob);

            ex12ExRenEntryParser.Parse();
            ex12ExRenEntryParser.GetEntryId(persistenceId);
            for (int i = 0; i < entryId.Length; i++)
            {
            }
        }
        private void InsertEntryBlock(Ex12RenEntryIdStrategy.PersistenceId persistenceId, Ex12ExRenEntryParser.ExFolderEntry exFolderEntry)
        {
            this.defaultFolderRenEx[(ushort)persistenceId] = exFolderEntry;
            int num = (this.entryBlob == null) ? 0 : this.entryBlob.Length;
            int num2;
            int num3;

            byte[] array = exFolderEntry.ToBlock(persistenceId, out num2, out num3);
            this.entryBlob      = Ex12ExRenEntryParser.ReplaceBlob(this.entryBlob, 0, 0, array);
            exFolderEntry.Start = num + num2;
            exFolderEntry.End   = num + array.Length;
        }
 internal bool Remove(Ex12RenEntryIdStrategy.PersistenceId persistenceId)
 {
     Ex12ExRenEntryParser.ExFolderEntry exFolderEntry = null;
     if (this.defaultFolderRenEx.TryGetValue((ushort)persistenceId, out exFolderEntry))
     {
         int start = exFolderEntry.Start - 4;
         this.entryBlob = Ex12ExRenEntryParser.ReplaceBlob(this.entryBlob, start, exFolderEntry.End, Array <byte> .Empty);
         this.defaultFolderRenEx.Clear();
         this.Parse();
         return(true);
     }
     return(false);
 }
        internal static Ex12ExRenEntryParser FromBytes(byte[] blob)
        {
            Ex12ExRenEntryParser ex12ExRenEntryParser = new Ex12ExRenEntryParser(blob);

            try
            {
                ex12ExRenEntryParser.Parse();
            }
            catch (FormatException)
            {
                ExTraceGlobals.DefaultFoldersTracer.TraceWarning <string>(-1L, "Ex12ExRenEntryParser::FromBytes. The blob is not correctly formated. Bytes = {0}.", (blob == null) ? "<null>" : Convert.ToBase64String(blob));
                ex12ExRenEntryParser.entryBlob          = Array <byte> .Empty;
                ex12ExRenEntryParser.defaultFolderRenEx = new Dictionary <ushort, Ex12ExRenEntryParser.ExFolderEntry>();
            }
            return(ex12ExRenEntryParser);
        }
 private bool ReplaceEntryBlock(Ex12RenEntryIdStrategy.PersistenceId persistenceId, Ex12ExRenEntryParser.ExFolderEntry exFolderEntry)
 {
     Ex12ExRenEntryParser.ExFolderEntry exFolderEntry2 = null;
     if (this.defaultFolderRenEx.TryGetValue((ushort)persistenceId, out exFolderEntry2))
     {
         byte[] array = exFolderEntry.ToBytes();
         if (array.Length == exFolderEntry2.End - exFolderEntry2.Start)
         {
             exFolderEntry.Start = exFolderEntry2.Start;
             exFolderEntry.End   = array.Length + exFolderEntry.Start;
             this.defaultFolderRenEx[(ushort)persistenceId] = exFolderEntry;
             this.entryBlob = Ex12ExRenEntryParser.ReplaceBlob(this.entryBlob, exFolderEntry2.Start, exFolderEntry2.End, array);
             return(true);
         }
     }
     return(false);
 }
 private static void ParseEntryBlock(byte[] additionalRenEntryIdsEx, ref int index, ushort blockSize, ref Ex12ExRenEntryParser.ExFolderEntry entry)
 {
     for (;;)
     {
         int  start = index;
         uint num   = (uint)Ex12ExRenEntryParser.ParseUInt16(additionalRenEntryIdsEx, index);
         index += 2;
         ushort num2 = Ex12ExRenEntryParser.ParseUInt16(additionalRenEntryIdsEx, index);
         index     += 2;
         blockSize -= 4;
         if (num2 > blockSize)
         {
             break;
         }
         try
         {
             if (num == 1U)
             {
                 entry.EntryId = new byte[(int)num2];
                 Array.Copy(additionalRenEntryIdsEx, index, entry.EntryId, 0, (int)num2);
             }
             else if (num == 2U)
             {
                 entry.ElementId = Ex12ExRenEntryParser.ParseUInt16(additionalRenEntryIdsEx, index);
             }
             else
             {
                 entry.Unknown = new byte[(int)num2];
                 Array.Copy(additionalRenEntryIdsEx, index, entry.Unknown, 0, (int)num2);
             }
         }
         catch (ArgumentException innerException)
         {
             throw new FormatException("ParseEntryBlock", innerException);
         }
         index      += (int)num2;
         blockSize  -= num2;
         entry.Start = start;
         entry.End   = index;
         if (blockSize <= 0)
         {
             return;
         }
     }
 }
        internal override byte[] GetEntryId(DefaultFolderContext context)
        {
            Ex12ExRenEntryParser ex12ExRenEntryParser = Ex12ExRenEntryParser.FromBytes(this.GetLocationPropertyBag(context).TryGetProperty(this.Property) as byte[]);

            return(ex12ExRenEntryParser.GetEntryId(this.persistenceId));
        }