internal static GlobalIDOwnerCollection DeserializeOdpReportSnapshot(ProcessingContext pc, IChunkFactory originalSnapshotChunks, ProcessingErrorContext errorContext, bool fetchSubreports, bool deserializeGroupTree, IConfiguration configuration, ref OnDemandMetadata odpMetadata, out Report report)
            {
                GlobalIDOwnerCollection globalIDOwnerCollection = new GlobalIDOwnerCollection();

                report = Microsoft.ReportingServices.ReportProcessing.ReportProcessing.DeserializeKatmaiReport(pc.ChunkFactory, keepReferences: true, globalIDOwnerCollection);
                IChunkFactory chunkFactory = originalSnapshotChunks ?? pc.ChunkFactory;

                if (odpMetadata == null)
                {
                    odpMetadata = DeserializeOnDemandMetadata(chunkFactory, globalIDOwnerCollection);
                }
                if (pc.Parameters != null)
                {
                    pc.Parameters.StoreLabels();
                }
                if (fetchSubreports)
                {
                    Microsoft.ReportingServices.ReportProcessing.ReportProcessing.FetchSubReports(report, pc.ChunkFactory, errorContext, odpMetadata, pc.ReportContext, pc.OnDemandSubReportCallback, 0, snapshotProcessing: true, processWithCachedData: false, globalIDOwnerCollection, pc.QueryParameters);
                    if (deserializeGroupTree)
                    {
                        DeserializeGroupTree(report, chunkFactory, globalIDOwnerCollection, configuration, ref odpMetadata);
                    }
                }
                odpMetadata.GlobalIDOwnerCollection = globalIDOwnerCollection;
                return(globalIDOwnerCollection);
            }
        internal static Report DeserializeReport(bool keepReferences, GlobalIDOwnerCollection globalIDOwnerCollection, IDOwner parentIDOwner, ReportItem parentReportItem, Stream stream)
        {
            IntermediateFormatReader intermediateFormatReader = new IntermediateFormatReader(stream, new ProcessingRIFObjectCreator(parentIDOwner, parentReportItem), globalIDOwnerCollection);
            Report obj = (Report)intermediateFormatReader.ReadRIFObject();

            obj.ReportOrDescendentHasUserSortFilter = obj.HasUserSortFilter;
            if (!keepReferences)
            {
                intermediateFormatReader.ClearReferences();
            }
            return(obj);
        }
            internal static SortFilterEventInfoMap DeserializeSortFilterEventInfo(IChunkFactory originalSnapshotChunks, GlobalIDOwnerCollection globalIDOwnerCollection)
            {
                Stream stream = null;
                SortFilterEventInfoMap sortFilterEventInfoMap = null;

                try
                {
                    stream = originalSnapshotChunks.GetChunk("SortFilterEventInfo", Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ReportChunkTypes.Interactivity, ChunkMode.Open, out string _);
                    if (stream != null)
                    {
                        IntermediateFormatReader intermediateFormatReader;
                        do
                        {
                            intermediateFormatReader = new IntermediateFormatReader(stream, new ProcessingRIFObjectCreator(null, null), globalIDOwnerCollection);
                            SortFilterEventInfoMap sortFilterEventInfoMap2 = (SortFilterEventInfoMap)intermediateFormatReader.ReadRIFObject();
                            Global.Tracer.Assert(sortFilterEventInfoMap2 != null, "(null != newInfo)");
                            if (sortFilterEventInfoMap == null)
                            {
                                sortFilterEventInfoMap = sortFilterEventInfoMap2;
                            }
                            else
                            {
                                sortFilterEventInfoMap.Merge(sortFilterEventInfoMap2);
                            }
                        }while (!intermediateFormatReader.EOS);
                        return(sortFilterEventInfoMap);
                    }
                    return(sortFilterEventInfoMap);
                }
                finally
                {
                    stream?.Close();
                }
            }
            internal static OnDemandMetadata DeserializeOnDemandMetadata(IChunkFactory chunkFactory, GlobalIDOwnerCollection globalIDOwnerCollection)
            {
                Stream stream = null;

                try
                {
                    stream = chunkFactory.GetChunk("Metadata", Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ReportChunkTypes.Main, ChunkMode.Open, out string _);
                    IntermediateFormatReader intermediateFormatReader = new IntermediateFormatReader(stream, default(GroupTreeRIFObjectCreator), globalIDOwnerCollection);
                    OnDemandMetadata         onDemandMetadata         = (OnDemandMetadata)intermediateFormatReader.ReadRIFObject();
                    Global.Tracer.Assert(onDemandMetadata != null, "(null != odpMetadata)");
                    stream.Close();
                    stream = null;
                    onDemandMetadata.OdpChunkManager = new OnDemandProcessingManager();
                    return(onDemandMetadata);
                }
                finally
                {
                    stream?.Close();
                }
            }
 internal static void EnsureGroupTreeStorageSetup(OnDemandMetadata odpMetadata, IChunkFactory chunkFactory, GlobalIDOwnerCollection globalIDOwnerCollection, bool openExisting, int rifCompatVersion, bool prohibitSerializableValues)
 {
     if (odpMetadata.GroupTreeScalabilityCache == null)
     {
         IStorage storage = new RIFAppendOnlyStorage(BuildChunkStreamHandler("GroupTree", Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ReportChunkTypes.Main, chunkFactory, openExisting), default(GroupTreeRIFObjectCreator), GroupTreeReferenceCreator.Instance, globalIDOwnerCollection, openExisting, rifCompatVersion, prohibitSerializableValues);
         odpMetadata.GroupTreeScalabilityCache = new GroupTreeScalabilityCache(odpMetadata.GroupTreePartitionManager, storage);
     }
 }
            internal static void DeserializeGroupTree(Report report, IChunkFactory chunkFactory, GlobalIDOwnerCollection globalIDOwnerCollection, IConfiguration configuration, ref OnDemandMetadata odpMetadata)
            {
                bool prohibitSerializableValues = configuration?.ProhibitSerializableValues ?? false;

                EnsureGroupTreeStorageSetup(odpMetadata, chunkFactory, globalIDOwnerCollection, openExisting: true, ReportProcessingCompatibilityVersion.GetCompatibilityVersion(configuration), prohibitSerializableValues);
                GroupTreePartition groupTreePartition = (GroupTreePartition)odpMetadata.GroupTreeScalabilityCache.Storage.Retrieve(odpMetadata.GroupTreeRootOffset);

                Global.Tracer.Assert(groupTreePartition.TopLevelScopeInstances[0].GetObjectType() == ObjectType.ReportInstanceReference, "GroupTree root partition did not contain a ReportInstance");
                odpMetadata.ReportInstance        = (groupTreePartition.TopLevelScopeInstances[0] as IReference <ReportInstance>);
                odpMetadata.Report                = report;
                odpMetadata.ReportSnapshot.Report = report;
            }