internal RuntimeGroupingObjHash(RuntimeHierarchyObj owner, Microsoft.ReportingServices.ReportProcessing.ObjectType objectType)
            : base(owner, objectType)
        {
            OnDemandProcessingContext odpContext = owner.OdpContext;

            m_hashtable = new ScalableDictionary <object, IReference <RuntimeHierarchyObj> >(owner.Depth + 1, odpContext.TablixProcessingScalabilityCache, 101, 27, odpContext.ProcessingComparer);
        }
        internal static RuntimeGroupingObj CreateGroupingObj(GroupingTypes type, RuntimeHierarchyObj owner, Microsoft.ReportingServices.ReportProcessing.ObjectType objectType)
        {
            switch (type)
            {
            case GroupingTypes.None:
                return(new RuntimeGroupingObjLinkedList(owner, objectType));

            case GroupingTypes.Hash:
                return(new RuntimeGroupingObjHash(owner, objectType));

            case GroupingTypes.Sort:
                return(new RuntimeGroupingObjTree(owner, objectType));

            case GroupingTypes.Detail:
                return(new RuntimeGroupingObjDetail(owner, objectType));

            case GroupingTypes.DetailUserSort:
                return(new RuntimeGroupingObjDetailUserSort(owner, objectType));

            case GroupingTypes.NaturalGroup:
                return(new RuntimeGroupingObjNaturalGroup(owner, objectType));

            default:
                Global.Tracer.Assert(condition: false, "Unexpected GroupingTypes");
                throw new InvalidOperationException();
            }
        }
        internal void CreateInstances(CreateInstancesTraversalContext traversalContext)
        {
            if (m_grouping != null)
            {
                m_grouping.Traverse(ProcessingStages.CreateGroupTree, m_expression == null || m_expression.Direction, traversalContext);
            }
            if (m_hierarchyObjs == null)
            {
                return;
            }
            bool flag = true;

            for (int i = 0; i < m_hierarchyObjs.Count; i++)
            {
                IReference <RuntimeHierarchyObj> reference = m_hierarchyObjs[i];
                using (reference.PinValue())
                {
                    RuntimeHierarchyObj runtimeHierarchyObj = reference.Value();
                    if (!flag || runtimeHierarchyObj is RuntimeGroupLeafObj)
                    {
                        ((RuntimeGroupLeafObj)runtimeHierarchyObj).TraverseAllLeafNodes(ProcessingStages.CreateGroupTree, traversalContext);
                        flag = false;
                    }
                    else
                    {
                        ((RuntimeDetailObj)runtimeHierarchyObj).CreateInstance(traversalContext);
                    }
                }
            }
        }
        private void CopyDomainScopeGroupInstance(RuntimeGroupRootObj destination, ScalableDictionary <object, IReference <RuntimeHierarchyObj> > runtimeHierarchyObjRefs)
        {
            IReference <RuntimeHierarchyObj> reference = null;

            DomainScopeContext.DomainScopeInfo currentDomainScope = m_owner.OdpContext.DomainScopeContext.CurrentDomainScope;
            foreach (object key in runtimeHierarchyObjRefs.Keys)
            {
                currentDomainScope.AddKey(key);
                reference = runtimeHierarchyObjRefs[key];
                using (reference.PinValue())
                {
                    RuntimeHierarchyObj runtimeHierarchyObj = reference.Value();
                    if (runtimeHierarchyObj.HierarchyObjs == null)
                    {
                        RuntimeGroupingObjHash runtimeGroupingObjHash = (RuntimeGroupingObjHash)runtimeHierarchyObj.Grouping;
                        CopyDomainScopeGroupInstance(destination, runtimeGroupingObjHash.m_hashtable);
                    }
                    else
                    {
                        Global.Tracer.Assert(runtimeHierarchyObj.HierarchyObjs.Count == 1, "hierarchyObject.HierarchyObjs.Count == 1");
                        IReference <RuntimeHierarchyObj> reference2 = runtimeHierarchyObj.HierarchyObjs[0];
                        using (reference2.PinValue())
                        {
                            RuntimeDataTablixGroupLeafObj runtimeDataTablixGroupLeafObj = (RuntimeDataTablixGroupLeafObj)reference2.Value();
                            currentDomainScope.CurrentRow = runtimeDataTablixGroupLeafObj.FirstRow;
                            destination.NextRow();
                        }
                    }
                }
                currentDomainScope.RemoveKey();
            }
        }
        internal virtual void CalculateRunningValues(AggregateUpdateContext aggContext)
        {
            if (m_grouping != null)
            {
                m_grouping.Traverse(ProcessingStages.RunningValues, m_expression == null || m_expression.Direction, aggContext);
            }
            if (m_hierarchyObjs == null)
            {
                return;
            }
            bool flag = true;

            for (int i = 0; i < m_hierarchyObjs.Count; i++)
            {
                IReference <RuntimeHierarchyObj> reference = m_hierarchyObjs[i];
                using (reference.PinValue())
                {
                    RuntimeHierarchyObj runtimeHierarchyObj = reference.Value();
                    if (!flag || runtimeHierarchyObj is RuntimeGroupLeafObj)
                    {
                        ((RuntimeGroupLeafObj)runtimeHierarchyObj).TraverseAllLeafNodes(ProcessingStages.RunningValues, aggContext);
                        flag = false;
                    }
                }
            }
        }
        internal RuntimeGroupingObjTree(RuntimeHierarchyObj owner, Microsoft.ReportingServices.ReportProcessing.ObjectType objectType)
            : base(owner, objectType)
        {
            OnDemandProcessingContext odpContext = m_owner.OdpContext;

            m_tree = new BTree(owner, odpContext, owner.Depth + 1);
        }
 internal RuntimeHierarchyObj(RuntimeHierarchyObj outerHierarchy, Microsoft.ReportingServices.ReportProcessing.ObjectType objectType, int level)
     : base(outerHierarchy.OdpContext, objectType, level)
 {
     if (outerHierarchy.m_expression != null)
     {
         ConstructorHelper(outerHierarchy.m_expression.ExpressionIndex + 1, outerHierarchy.m_hierarchyRoot);
     }
     else
     {
         ConstructorHelper(-1, outerHierarchy.m_hierarchyRoot);
     }
 }
        protected RuntimeHierarchyObjReference CreateHierarchyObjAndAddToParent()
        {
            RuntimeHierarchyObjReference runtimeHierarchyObjReference = null;

            try
            {
                RuntimeHierarchyObj runtimeHierarchyObj = new RuntimeHierarchyObj(m_owner, m_objectType, ((IScope)m_owner).Depth + 1);
                runtimeHierarchyObjReference = (RuntimeHierarchyObjReference)runtimeHierarchyObj.SelfReference;
                runtimeHierarchyObj.NextRow();
            }
            finally
            {
                if (null != runtimeHierarchyObjReference)
                {
                    runtimeHierarchyObjReference.UnPinValue();
                }
            }
            return(runtimeHierarchyObjReference);
        }
 internal void SetOwner(RuntimeHierarchyObj owner)
 {
     m_owner = owner;
 }
 internal RuntimeGroupingObj(RuntimeHierarchyObj owner, Microsoft.ReportingServices.ReportProcessing.ObjectType objectType)
 {
     m_owner      = owner;
     m_objectType = objectType;
 }
        internal override void NextRow(object keyValue, bool hasParent, object parentKey)
        {
            IReference <RuntimeHierarchyObj> value = null;

            try
            {
                m_hashtable.TryGetValue(keyValue, out value);
            }
            catch (ReportProcessingException_SpatialTypeComparisonError reportProcessingException_SpatialTypeComparisonError)
            {
                throw new ReportProcessingException(m_owner.RegisterSpatialTypeComparisonError(reportProcessingException_SpatialTypeComparisonError.Type));
            }
            catch (ReportProcessingException_ComparisonError e)
            {
                throw new ReportProcessingException(m_owner.RegisterComparisonError("GroupExpression", e));
            }
            if (value != null)
            {
                using (value.PinValue())
                {
                    value.Value().NextRow();
                }
                return;
            }
            RuntimeHierarchyObj runtimeHierarchyObj = new RuntimeHierarchyObj(m_owner, m_objectType, ((IScope)m_owner).Depth + 1);

            value = (IReference <RuntimeHierarchyObj>)runtimeHierarchyObj.SelfReference;
            try
            {
                m_hashtable.Add(keyValue, value);
                runtimeHierarchyObj = value.Value();
                runtimeHierarchyObj.NextRow();
                if (hasParent)
                {
                    IReference <RuntimeHierarchyObj> value2    = null;
                    IReference <RuntimeGroupLeafObj> reference = null;
                    try
                    {
                        m_hashtable.TryGetValue(parentKey, out value2);
                    }
                    catch (ReportProcessingException_SpatialTypeComparisonError reportProcessingException_SpatialTypeComparisonError2)
                    {
                        throw new ReportProcessingException(m_owner.RegisterSpatialTypeComparisonError(reportProcessingException_SpatialTypeComparisonError2.Type));
                    }
                    catch (ReportProcessingException_ComparisonError e2)
                    {
                        throw new ReportProcessingException(m_owner.RegisterComparisonError("Parent", e2));
                    }
                    if (value2 != null)
                    {
                        RuntimeHierarchyObj runtimeHierarchyObj2 = value2.Value();
                        Global.Tracer.Assert(runtimeHierarchyObj2.HierarchyObjs != null, "(null != parentHierarchyObj.HierarchyObjs)");
                        reference = (RuntimeGroupLeafObjReference)runtimeHierarchyObj2.HierarchyObjs[0];
                    }
                    Global.Tracer.Assert(runtimeHierarchyObj.HierarchyObjs != null, "(null != hierarchyObj.HierarchyObjs)");
                    RuntimeGroupLeafObjReference runtimeGroupLeafObjReference = (RuntimeGroupLeafObjReference)runtimeHierarchyObj.HierarchyObjs[0];
                    bool addToWaitList = true;
                    if (reference == runtimeGroupLeafObjReference)
                    {
                        reference     = null;
                        addToWaitList = false;
                    }
                    ProcessChildren(keyValue, reference, runtimeGroupLeafObjReference);
                    ProcessParent(parentKey, reference, runtimeGroupLeafObjReference, addToWaitList);
                }
            }
            finally
            {
                value.UnPinValue();
            }
        }
 internal RuntimeGroupingObjDetailUserSort(RuntimeHierarchyObj owner, Microsoft.ReportingServices.ReportProcessing.ObjectType objectType)
     : base(owner, objectType)
 {
 }