internal RecordState(RecordStateFactory recordStateFactory, CoordinatorFactory coordinatorFactory) { this.RecordStateFactory = recordStateFactory; this.CoordinatorFactory = coordinatorFactory; this.CurrentColumnValues = new object[RecordStateFactory.ColumnCount]; this.PendingColumnValues = new object[RecordStateFactory.ColumnCount]; }
private void SetShaper(Shaper<RecordState> shaper, CoordinatorFactory<RecordState> coordinatorFactory, int depth) { _shaper = shaper; _coordinatorFactory = coordinatorFactory; _dataRecord = new BridgeDataRecord(shaper, depth); // To determine whether there are any rows for this coordinator at this place in // the root enumerator, we pretty much just look at it's current record (we'll read // one if there isn't one waiting) and if it matches our coordinator, we've got rows. _hasRows = false; if (!_shaper.DataWaiting) { _shaper.DataWaiting = _shaper.RootEnumerator.MoveNext(); } if (_shaper.DataWaiting) { var currentRecord = _shaper.RootEnumerator.Current; if (null != currentRecord) { _hasRows = (currentRecord.CoordinatorFactory == _coordinatorFactory); } } // Once we've created the root enumerator, we can get the default record state _defaultRecordState = coordinatorFactory.GetDefaultRecordState(_shaper); Debug.Assert(null != _defaultRecordState, "no default?"); }
internal RecordState(RecordStateFactory recordStateFactory, CoordinatorFactory coordinatorFactory) { RecordStateFactory = recordStateFactory; CoordinatorFactory = coordinatorFactory; CurrentColumnValues = new object[RecordStateFactory.ColumnCount]; PendingColumnValues = new object[RecordStateFactory.ColumnCount]; }
/// <summary> /// Constructor used by the ResultColumn when doing GetValue, and by the Create factory /// method. /// </summary> /// <param name="collection"></param> /// <param name="isRoot"></param> /// <param name="nextResultShaperInfos">enumrator of the shapers for NextResult() calls</param> internal BridgeDataReader(Shaper<RecordState> shaper, CoordinatorFactory<RecordState> coordinatorFactory, int depth, IEnumerator<KeyValuePair<Shaper<RecordState>, CoordinatorFactory<RecordState>>> nextResultShaperInfos) : base() { Debug.Assert(null != shaper, "null shaper?"); Debug.Assert(null != coordinatorFactory, "null coordinatorFactory?"); Debug.Assert(depth == 0 || nextResultShaperInfos == null, "Nested data readers should not have multiple result sets."); NextResultShaperInfoEnumerator = nextResultShaperInfos != null ? nextResultShaperInfos : null; SetShaper(shaper, coordinatorFactory, depth); }
protected CoordinatorFactory( int depth, int stateSlot, Func<Shaper, bool> hasData, Func<Shaper, bool> setKeys, Func<Shaper, bool> checkKeys, CoordinatorFactory[] nestedCoordinators, RecordStateFactory[] recordStateFactories) { Depth = depth; StateSlot = stateSlot; // figure out if there are any nested coordinators IsLeafResult = 0 == nestedCoordinators.Length; // if there is no explicit 'has data' discriminator, it means all rows contain data for the coordinator if (hasData == null) { HasData = _alwaysTrue; } else { HasData = hasData; } // if there is no explicit set key delegate, just return true (the value is not used anyways) if (setKeys == null) { SetKeys = _alwaysTrue; } else { SetKeys = setKeys; } // If there are no keys, it means different things depending on whether we are a leaf // coordinator or an inner (or 'driving') coordinator. For a leaf coordinator, it means // that every row is a new result. For an inner coordinator, it means that there is no // key to check. This should only occur where there is a SingleRowTable (in other words, // all rows are elements of a single child collection). if (checkKeys == null) { if (IsLeafResult) { CheckKeys = _alwaysFalse; // every row is a new result (the keys don't match) } else { CheckKeys = _alwaysTrue; // every row belongs to a single child collection } } else { CheckKeys = checkKeys; } NestedCoordinators = new ReadOnlyCollection<CoordinatorFactory>(nestedCoordinators); RecordStateFactories = new ReadOnlyCollection<RecordStateFactory>(recordStateFactories); // Determines whether this coordinator can be handled by a 'simple' enumerator. See IsSimple for details. IsSimple = IsLeafResult && null == checkKeys && null == hasData; }
internal BridgeDataReader( Shaper<RecordState> shaper, CoordinatorFactory<RecordState> coordinatorFactory, int depth, IEnumerator<KeyValuePair<Shaper<RecordState>, CoordinatorFactory<RecordState>>> nextResultShaperInfos) { //Contract.Requires(null != shaper); //Contract.Requires(null != coordinatorFactory); //Contract.Requires(depth == 0 || nextResultShaperInfos == null, "Nested data readers should not have multiple result sets."); _nextResultShaperInfoEnumerator = nextResultShaperInfos; SetShaper(shaper, coordinatorFactory, depth); }
internal CoordinatorFactory Compile() { RecordStateFactory[] recordStateFactories; if (null != _recordStateScratchpads) { recordStateFactories = new RecordStateFactory[_recordStateScratchpads.Count]; for (int i = 0; i < recordStateFactories.Length; i++) { recordStateFactories[i] = _recordStateScratchpads[i].Compile(); } } else { recordStateFactories = new RecordStateFactory[0]; } CoordinatorFactory[] nestedCoordinators = new CoordinatorFactory[_nestedCoordinatorScratchpads.Count]; for (int i = 0; i < nestedCoordinators.Length; i++) { nestedCoordinators[i] = _nestedCoordinatorScratchpads[i].Compile(); } // compile inline delegates ReplacementExpressionVisitor replacementVisitor = new ReplacementExpressionVisitor(null, this._inlineDelegates); Expression element = new SecurityBoundaryExpressionVisitor().Visit(replacementVisitor.Visit(this.Element)); // substitute expressions that have error handlers into a new expression (used // when a more detailed exception message is needed) replacementVisitor = new ReplacementExpressionVisitor(this._expressionWithErrorHandlingMap, this._inlineDelegates); Expression elementWithErrorHandling = new SecurityBoundaryExpressionVisitor().Visit(replacementVisitor.Visit(this.Element)); CoordinatorFactory result = (CoordinatorFactory)Activator.CreateInstance(typeof(CoordinatorFactory <>).MakeGenericType(_elementType), new object[] { this.Depth, this.StateSlotNumber, this.HasData, this.SetKeys, this.CheckKeys, nestedCoordinators, element, elementWithErrorHandling, this.InitializeCollection, recordStateFactories }); return(result); }
protected Coordinator(CoordinatorFactory coordinatorFactory, Coordinator parent, Coordinator next) { this.CoordinatorFactory = coordinatorFactory; this.Parent = parent; this.Next = next; }
protected Coordinator(CoordinatorFactory coordinatorFactory, Coordinator parent, Coordinator next) { this.CoordinatorFactory = coordinatorFactory; this.Parent = parent; this.Next = next; }
/// <summary> /// It's GO time, create the record state. /// </summary> internal RecordState Create(CoordinatorFactory coordinatorFactory) { return new RecordState(this, coordinatorFactory); }
/// <summary> /// It's GO time, create the record state. /// </summary> internal RecordState Create(CoordinatorFactory coordinatorFactory) { return(new RecordState(this, coordinatorFactory)); }
internal CoordinatorFactory Compile() { RecordStateFactory[] recordStateFactories; if (null != _recordStateScratchpads) { recordStateFactories = new RecordStateFactory[_recordStateScratchpads.Count]; for (var i = 0; i < recordStateFactories.Length; i++) { recordStateFactories[i] = _recordStateScratchpads[i].Compile(); } } else { recordStateFactories = new RecordStateFactory[0]; } var nestedCoordinators = new CoordinatorFactory[_nestedCoordinatorScratchpads.Count]; for (var i = 0; i < nestedCoordinators.Length; i++) { nestedCoordinators[i] = _nestedCoordinatorScratchpads[i].Compile(); } // compile inline delegates var replacementVisitor = new ReplacementExpressionVisitor(null, _inlineDelegates); var element = new SecurityBoundaryExpressionVisitor().Visit(replacementVisitor.Visit(Element)); // substitute expressions that have error handlers into a new expression (used // when a more detailed exception message is needed) replacementVisitor = new ReplacementExpressionVisitor(_expressionWithErrorHandlingMap, _inlineDelegates); var elementWithErrorHandling = new SecurityBoundaryExpressionVisitor().Visit(replacementVisitor.Visit(Element)); var result = (CoordinatorFactory)Activator.CreateInstance( typeof(CoordinatorFactory<>).MakeGenericType(_elementType), new object[] { Depth, StateSlotNumber, HasData, SetKeys, CheckKeys, nestedCoordinators, element, elementWithErrorHandling, InitializeCollection, recordStateFactories }); return result; }