private DataPipelineManager GetOrCreatePipelineManager(AspNetCore.ReportingServices.ReportIntermediateFormat.DataSet dataSet, IRIFReportDataScope targetScope)
 {
     if (this.m_pipelineManager != null)
     {
         if (this.m_pipelineManager.DataSetIndex == dataSet.IndexInCollection)
         {
             return(this.m_pipelineManager);
         }
         if (base.m_odpContext.IsTablixProcessingComplete(dataSet.IndexInCollection))
         {
             Global.Tracer.Trace(TraceLevel.Verbose, "Performance: While rendering the report: '{0}' the data set {1} was processed multiple times due to rendering traversal order.", base.m_odpContext.ReportContext.ItemPathAsString.MarkAsPrivate(), dataSet.Name.MarkAsPrivate());
         }
         this.CleanupPipelineManager();
         base.ShutdownSequentialReadersAndIdcDataManagers();
     }
     if (dataSet.AllowIncrementalProcessing)
     {
         this.m_pipelineManager = new IncrementalDataPipelineManager(base.m_odpContext, dataSet);
     }
     else
     {
         this.m_pipelineManager = new StreamingAtomicDataPipelineManager(base.m_odpContext, dataSet);
     }
     this.m_pipelineThrottle = new DataPipelineThrottle();
     this.m_pipelineThrottle.StartUsingContext(PipelineAdvanceMode.ToStoppingScopeInstance, targetScope);
     this.m_pipelineManager.StartProcessing();
     this.m_pipelineThrottle.StopUsingContext();
     this.TryProcessToNextScopeInstance(targetScope);
     return(this.m_pipelineManager);
 }
 private void CleanupPipelineManager()
 {
     if (this.m_pipelineManager != null)
     {
         this.m_pipelineManager.StopProcessing();
         this.m_pipelineManager = null;
     }
 }
        private void BindScopeToInstance(IRIFReportDataScope reportDataScope)
        {
            if (!reportDataScope.IsBoundToStreamingScopeInstance)
            {
                if (!reportDataScope.IsScope)
                {
                    IRIFReportDataScope parentReportScope = reportDataScope.ParentReportScope;
                    this.EnsureScopeIsBound(parentReportScope);
                    reportDataScope.BindToStreamingScopeInstance(parentReportScope.CurrentStreamingScopeInstance);
                }
                else
                {
                    switch (reportDataScope.InstancePathItem.Type)
                    {
                    case InstancePathItemType.Cell:
                        if (reportDataScope.IsDataIntersectionScope)
                        {
                            IRIFReportIntersectionScope          iRIFReportIntersectionScope = (IRIFReportIntersectionScope)reportDataScope;
                            IRIFReportDataScope                  parentRowReportScope        = iRIFReportIntersectionScope.ParentRowReportScope;
                            IReference <IOnDemandMemberInstance> reference3 = default(IReference <IOnDemandMemberInstance>);
                            if (this.TryBindParentScope <IOnDemandMemberInstance>(reportDataScope, parentRowReportScope, out reference3))
                            {
                                IRIFReportDataScope parentColumnReportScope     = iRIFReportIntersectionScope.ParentColumnReportScope;
                                IReference <IOnDemandMemberInstance> reference4 = default(IReference <IOnDemandMemberInstance>);
                                if (this.TryBindParentScope <IOnDemandMemberInstance>(reportDataScope, parentColumnReportScope, out reference4))
                                {
                                    IReference <IOnDemandMemberInstance> reference5;
                                    IReference <IOnDemandMemberInstance> reference6;
                                    if (!iRIFReportIntersectionScope.IsColumnOuterGrouping)
                                    {
                                        reference5 = reference3;
                                        reference6 = reference4;
                                    }
                                    else
                                    {
                                        reference5 = reference4;
                                        reference6 = reference3;
                                    }
                                    this.CheckForPrematureScopeInstance(reportDataScope);
                                    IReference <IOnDemandScopeInstance> reference7 = default(IReference <IOnDemandScopeInstance>);
                                    IOnDemandScopeInstance cellInstance            = SyntheticTriangulatedCellReference.GetCellInstance(reference5, reference6, out reference7);
                                    if (cellInstance == null && iRIFReportIntersectionScope.DataScopeInfo.NeedsIDC && this.TryProcessToCreateCell(iRIFReportIntersectionScope, (RuntimeDataTablixGroupLeafObjReference)reference6, (RuntimeDataTablixGroupLeafObjReference)reference5))
                                    {
                                        cellInstance = SyntheticTriangulatedCellReference.GetCellInstance(reference5, reference6, out reference7);
                                    }
                                    if (cellInstance != null)
                                    {
                                        if (reference7 == null)
                                        {
                                            iRIFReportIntersectionScope.BindToStreamingScopeInstance(reference5, reference6);
                                            this.SetupEnvironment(reportDataScope, cellInstance, iRIFReportIntersectionScope.CurrentStreamingScopeInstance);
                                        }
                                        else
                                        {
                                            reportDataScope.BindToStreamingScopeInstance(reference7);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Global.Tracer.Assert(false, "Non-intersection cell scopes are not yet supported by streaming ODP.");
                        }
                        break;

                    case InstancePathItemType.ColumnMemberInstanceIndexTopMost:
                    case InstancePathItemType.ColumnMemberInstanceIndex:
                    case InstancePathItemType.RowMemberInstanceIndex:
                    {
                        IRIFReportDataScope parentReportScope3 = reportDataScope.ParentReportScope;
                        IReference <IOnDemandMemberOwnerInstance> reference2 = default(IReference <IOnDemandMemberOwnerInstance>);
                        if (this.TryBindParentScope <IOnDemandMemberOwnerInstance>(reportDataScope, parentReportScope3, out reference2))
                        {
                            this.CheckForPrematureScopeInstance(reportDataScope);
                            using (reference2.PinValue())
                            {
                                IOnDemandMemberOwnerInstance onDemandMemberOwnerInstance = reference2.Value();
                                AspNetCore.ReportingServices.ReportIntermediateFormat.ReportHierarchyNode rifMember = (AspNetCore.ReportingServices.ReportIntermediateFormat.ReportHierarchyNode)reportDataScope;
                                IOnDemandMemberInstanceReference firstMemberInstance = onDemandMemberOwnerInstance.GetFirstMemberInstance(rifMember);
                                if (this.RequiresIdcProcessing(reportDataScope, firstMemberInstance, (IReference <IOnDemandScopeInstance>)reference2))
                                {
                                    firstMemberInstance = onDemandMemberOwnerInstance.GetFirstMemberInstance(rifMember);
                                }
                                reportDataScope.BindToStreamingScopeInstance(firstMemberInstance);
                            }
                        }
                        break;
                    }

                    case InstancePathItemType.DataRegion:
                    {
                        IRIFReportDataScope parentReportScope2 = reportDataScope.ParentReportScope;
                        AspNetCore.ReportingServices.ReportIntermediateFormat.DataRegion dataRegion = (AspNetCore.ReportingServices.ReportIntermediateFormat.DataRegion)reportDataScope;
                        IReference <IOnDemandScopeInstance> reference = default(IReference <IOnDemandScopeInstance>);
                        if (parentReportScope2 == null)
                        {
                            AspNetCore.ReportingServices.ReportIntermediateFormat.DataSet dataSet = dataRegion.DataScopeInfo.DataSet;
                            DataPipelineManager orCreatePipelineManager = this.GetOrCreatePipelineManager(dataSet, dataRegion);
                            reportDataScope.BindToStreamingScopeInstance(orCreatePipelineManager.GroupTreeRoot.GetDataRegionInstance(dataRegion));
                        }
                        else if (this.TryBindParentScope <IOnDemandScopeInstance>(reportDataScope, parentReportScope2, out reference))
                        {
                            this.CheckForPrematureScopeInstance(reportDataScope);
                            using (reference.PinValue())
                            {
                                IOnDemandScopeInstance onDemandScopeInstance           = reference.Value();
                                IReference <IOnDemandScopeInstance> dataRegionInstance = onDemandScopeInstance.GetDataRegionInstance(dataRegion);
                                if (this.RequiresIdcProcessing(reportDataScope, dataRegionInstance, reference))
                                {
                                    dataRegionInstance = onDemandScopeInstance.GetDataRegionInstance(dataRegion);
                                }
                                reportDataScope.BindToStreamingScopeInstance(dataRegionInstance);
                            }
                        }
                        break;
                    }

                    default:
                        Global.Tracer.Assert(false, "SetupObjectModels cannot handle IRIFReportDataScope of type: {0}", Enum.GetName(typeof(InstancePathItemType), reportDataScope.InstancePathItem.Type));
                        break;
                    }
                }
            }
        }