private static void ReadTablixProperties(PageTablixHelper item, BinaryReader reader, long offsetEndPage)
        {
            RSTrace.RenderingTracer.Assert(item != null, "The item helper is null.");
            RSTrace.RenderingTracer.Assert(reader != null, "The pagination stream is null.");
            RSTrace.RenderingTracer.Assert(offsetEndPage > 0, "The pagination stream is corrupt.");
            byte b = reader.ReadByte();

            while (b != byte.MaxValue && reader.BaseStream.Position <= offsetEndPage)
            {
                switch (b)
                {
                case 16:
                    item.LevelForRepeat = reader.ReadInt32();
                    break;

                case 22:
                    item.IgnoreTotalsOnLastLevel = reader.ReadBoolean();
                    break;

                case 17:
                    item.TablixCreateState = ReadIntList(reader, offsetEndPage);
                    break;

                case 18:
                    item.MembersInstanceIndex = ReadIntList(reader, offsetEndPage);
                    break;

                case 19:
                {
                    byte           b2             = reader.ReadByte();
                    PageItemHelper pageItemHelper = null;
                    switch (b2)
                    {
                    case 5:
                    case 6:
                        ReadPageItemContainerProperties((PageItemContainerHelper)(pageItemHelper = new PageItemContainerHelper(b2)), reader, offsetEndPage);
                        break;

                    case 1:
                    case 2:
                    case 3:
                    case 8:
                    case 9:
                    case 10:
                    case 12:
                    case 15:
                    case 17:
                        pageItemHelper = new PageItemHelper(b2);
                        ReadPageItemProperties(pageItemHelper, reader, offsetEndPage);
                        break;

                    case 4:
                        pageItemHelper = new PageItemHelper(b2);
                        ReadSubReportProperties(pageItemHelper, reader, offsetEndPage);
                        break;

                    case 11:
                        ReadTablixProperties((PageTablixHelper)(pageItemHelper = new PageTablixHelper(b2)), reader, offsetEndPage);
                        break;

                    default:
                        throw new InvalidDataException(SPBRes.InvalidTokenPaginationItems(b2.ToString("x", CultureInfo.InvariantCulture)));
                    }
                    item.ChildPage = pageItemHelper;
                    break;
                }

                default:
                    item.ProcessPageItemToken(b, reader, offsetEndPage);
                    break;
                }
                b = reader.ReadByte();
            }
            if (reader.BaseStream.Position > offsetEndPage)
            {
                throw new InvalidDataException(SPBRes.InvalidPaginationStream);
            }
        }
        private static void ReadPageItemContainerProperties(PageItemContainerHelper item, BinaryReader reader, long offsetEndPage)
        {
            RSTrace.RenderingTracer.Assert(item != null, "The item helper is null.");
            RSTrace.RenderingTracer.Assert(reader != null, "The pagination stream is null.");
            RSTrace.RenderingTracer.Assert(offsetEndPage > 0, "The pagination stream is corrupt.");
            byte b = reader.ReadByte();

            while (b != byte.MaxValue && reader.BaseStream.Position <= offsetEndPage)
            {
                switch (b)
                {
                case 6:
                    item.ItemsCreated = reader.ReadBoolean();
                    break;

                case 11:
                    item.PrevPageEnd = reader.ReadDouble();
                    break;

                case 9:
                {
                    if (reader.ReadByte() != 3)
                    {
                        throw new InvalidDataException(SPBRes.InvalidPaginationStream);
                    }
                    PageItemHelper pageItemHelper = new PageItemHelper(3);
                    ReadPageItemProperties(pageItemHelper, reader, offsetEndPage);
                    item.RightEdgeItem = pageItemHelper;
                    break;
                }

                case 7:
                {
                    int   num3   = reader.ReadInt32();
                    int[] array3 = new int[num3];
                    for (int k = 0; k < num3; k++)
                    {
                        array3[k] = reader.ReadInt32();
                    }
                    item.IndexesLeftToRight = array3;
                    break;
                }

                case 20:
                {
                    int   num4   = reader.ReadInt32();
                    int[] array4 = new int[num4];
                    for (int l = 0; l < num4; l++)
                    {
                        array4[l] = reader.ReadInt32();
                    }
                    item.IndexesTopToBottom = array4;
                    break;
                }

                case 10:
                {
                    int num2 = reader.ReadInt32();
                    PageItemHelper[] array2 = new PageItemHelper[num2];
                    for (int j = 0; j < num2; j++)
                    {
                        byte b3 = reader.ReadByte();
                        switch (b3)
                        {
                        case 5:
                        case 6:
                            ReadPageItemContainerProperties((PageItemContainerHelper)(array2[j] = new PageItemContainerHelper(b3)), reader, offsetEndPage);
                            break;

                        case 1:
                        case 2:
                        case 3:
                        case 8:
                        case 9:
                        case 10:
                        case 12:
                        case 15:
                        case 17:
                            array2[j] = new PageItemHelper(b3);
                            ReadPageItemProperties(array2[j], reader, offsetEndPage);
                            break;

                        case 4:
                            array2[j] = new PageItemHelper(b3);
                            ReadSubReportProperties(array2[j], reader, offsetEndPage);
                            break;

                        case 11:
                            ReadTablixProperties((PageTablixHelper)(array2[j] = new PageTablixHelper(b3)), reader, offsetEndPage);
                            break;

                        case 14:
                            reader.ReadByte();
                            array2[j] = null;
                            break;

                        default:
                            throw new InvalidDataException(SPBRes.InvalidTokenPaginationItems(b3.ToString("x", CultureInfo.InvariantCulture)));
                        }
                    }
                    item.Children = array2;
                    break;
                }

                case 8:
                {
                    int num = reader.ReadInt32();
                    PageItemRepeatWithHelper[] array = new PageItemRepeatWithHelper[num];
                    for (int i = 0; i < num; i++)
                    {
                        byte b2 = reader.ReadByte();
                        array[i] = new PageItemRepeatWithHelper(b2);
                        if (b2 != 14)
                        {
                            ReadRepeatWithItemProperties(array[i], reader, offsetEndPage);
                            continue;
                        }
                        reader.ReadByte();
                        array[i] = null;
                    }
                    item.RepeatWithItems = array;
                    break;
                }

                default:
                    item.ProcessPageItemToken(b, reader, offsetEndPage);
                    break;
                }
                b = reader.ReadByte();
            }
            if (reader.BaseStream.Position > offsetEndPage)
            {
                throw new InvalidDataException(SPBRes.InvalidPaginationStream);
            }
        }