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 != 255 && reader.BaseStream.Position <= offsetEndPage)
            {
                switch (b)
                {
                case 16:
                    item.LevelForRepeat = reader.ReadInt32();
                    break;

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

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

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

                case 19:
                {
                    byte           b2             = reader.ReadByte();
                    PageItemHelper pageItemHelper = null;
                    switch (b2)
                    {
                    case 5:
                    case 6:
                    {
                        PageItemContainerHelper pageItemContainerHelper = new PageItemContainerHelper(b2);
                        pageItemHelper = pageItemContainerHelper;
                        PageItemHelper.ReadPageItemContainerProperties(pageItemContainerHelper, 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);
                        PageItemHelper.ReadPageItemProperties(pageItemHelper, reader, offsetEndPage);
                        break;

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

                    case 11:
                    {
                        PageTablixHelper pageTablixHelper = new PageTablixHelper(b2);
                        pageItemHelper = pageTablixHelper;
                        PageItemHelper.ReadTablixProperties(pageTablixHelper, 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)
            {
                return;
            }
            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 != 255 && reader.BaseStream.Position <= offsetEndPage)
            {
                switch (b)
                {
                case 6:
                    item.ItemsCreated = reader.ReadBoolean();
                    break;

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

                case 9:
                {
                    byte b3 = reader.ReadByte();
                    if (b3 != 3)
                    {
                        throw new InvalidDataException(SPBRes.InvalidPaginationStream);
                    }
                    PageItemHelper pageItemHelper = new PageItemHelper(3);
                    PageItemHelper.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 b4 = reader.ReadByte();
                        switch (b4)
                        {
                        case 5:
                        case 6:
                            PageItemHelper.ReadPageItemContainerProperties((PageItemContainerHelper)(array2[j] = new PageItemContainerHelper(b4)), 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(b4);
                            PageItemHelper.ReadPageItemProperties(array2[j], reader, offsetEndPage);
                            break;

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

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

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

                        default:
                            throw new InvalidDataException(SPBRes.InvalidTokenPaginationItems(b4.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)
                        {
                            PageItemHelper.ReadRepeatWithItemProperties(array[i], reader, offsetEndPage);
                        }
                        else
                        {
                            reader.ReadByte();
                            array[i] = null;
                        }
                    }
                    item.RepeatWithItems = array;
                    break;
                }

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