Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Data / System / Data / SqlClient / TdsRecordBufferSetter.cs / 1 / TdsRecordBufferSetter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data.SqlClient { using Microsoft.SqlServer.Server; using System; using System.Data; using System.Data.SqlClient; using System.Diagnostics; using System.Data.SqlTypes; // TdsRecordBufferSetter handles writing a structured value out to a TDS stream internal class TdsRecordBufferSetter : SmiRecordBuffer { #region Fields (private) private TdsValueSetter[] _fieldSetters; // setters for individual fields private TdsParserStateObject _stateObj; // target to write to private SmiMetaData _metaData; // metadata describing value #if DEBUG private const int ReadyForToken = -1; // must call new/end element next private const int EndElementsCalled = -2; // already called EndElements, can only call Close private const int Closed = -3; // closed (zombied) private int _currentField; // validate that caller sets columns in correct order. #endif #endregion #region Exposed Construct and control methods/properties internal TdsRecordBufferSetter(TdsParserStateObject stateObj, SmiMetaData md) { Debug.Assert(SqlDbType.Structured == md.SqlDbType, "Unsupported SqlDbType: " + md.SqlDbType); _fieldSetters = new TdsValueSetter[md.FieldMetaData.Count]; for(int i=0; i_currentField, "_currentField out of range for setting a column:" + _currentField); Debug.Assert(ordinal == _currentField, "Setter called out of order. Should be " + _currentField + ", but was " + ordinal); // Must not write to field with a DefaultFieldsProperty set to true Debug.Assert(!((SmiDefaultFieldsProperty)_metaData.ExtendedProperties[SmiPropertySelector.DefaultFields])[ordinal], "Attempt to write to a default-valued field: " + ordinal); #endif } // Handle logic of skipping default columns [Conditional("DEBUG")] private void SkipPossibleDefaultedColumns(int targetColumn) { #if DEBUG Debug.Assert(targetColumn < _metaData.FieldMetaData.Count && targetColumn >= ReadyForToken, "TdsRecordBufferSetter.SkipPossibleDefaultedColumns: Invalid target column: " + targetColumn); // special setup for ReadyForToken as the target if (targetColumn == ReadyForToken) { if (ReadyForToken == _currentField) { return; } // Handle readyfortoken by using count of columns in the loop. targetColumn = _metaData.FieldMetaData.Count; } // Handle skipping default-valued fields while (targetColumn > _currentField) { // All intermediate fields must be default fields (i.e. have a "true" entry in SmiDefaultFieldsProperty Debug.Assert(((SmiDefaultFieldsProperty)_metaData.ExtendedProperties[SmiPropertySelector.DefaultFields])[_currentField], "Skipping a field that was not default: " + _currentField); _currentField++; } if (_metaData.FieldMetaData.Count == _currentField) { _currentField = ReadyForToken; } #endif } [Conditional("DEBUG")] internal void CheckSettingColumn(int ordinal) { #if DEBUG // Make sure target column can be written to. CheckWritingToColumn(ordinal); _currentField++; if (_metaData.FieldMetaData.Count == _currentField) { _currentField = ReadyForToken; } #endif } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data.SqlClient { using Microsoft.SqlServer.Server; using System; using System.Data; using System.Data.SqlClient; using System.Diagnostics; using System.Data.SqlTypes; // TdsRecordBufferSetter handles writing a structured value out to a TDS stream internal class TdsRecordBufferSetter : SmiRecordBuffer { #region Fields (private) private TdsValueSetter[] _fieldSetters; // setters for individual fields private TdsParserStateObject _stateObj; // target to write to private SmiMetaData _metaData; // metadata describing value #if DEBUG private const int ReadyForToken = -1; // must call new/end element next private const int EndElementsCalled = -2; // already called EndElements, can only call Close private const int Closed = -3; // closed (zombied) private int _currentField; // validate that caller sets columns in correct order. #endif #endregion #region Exposed Construct and control methods/properties internal TdsRecordBufferSetter(TdsParserStateObject stateObj, SmiMetaData md) { Debug.Assert(SqlDbType.Structured == md.SqlDbType, "Unsupported SqlDbType: " + md.SqlDbType); _fieldSetters = new TdsValueSetter[md.FieldMetaData.Count]; for(int i=0; i_currentField, "_currentField out of range for setting a column:" + _currentField); Debug.Assert(ordinal == _currentField, "Setter called out of order. Should be " + _currentField + ", but was " + ordinal); // Must not write to field with a DefaultFieldsProperty set to true Debug.Assert(!((SmiDefaultFieldsProperty)_metaData.ExtendedProperties[SmiPropertySelector.DefaultFields])[ordinal], "Attempt to write to a default-valued field: " + ordinal); #endif } // Handle logic of skipping default columns [Conditional("DEBUG")] private void SkipPossibleDefaultedColumns(int targetColumn) { #if DEBUG Debug.Assert(targetColumn < _metaData.FieldMetaData.Count && targetColumn >= ReadyForToken, "TdsRecordBufferSetter.SkipPossibleDefaultedColumns: Invalid target column: " + targetColumn); // special setup for ReadyForToken as the target if (targetColumn == ReadyForToken) { if (ReadyForToken == _currentField) { return; } // Handle readyfortoken by using count of columns in the loop. targetColumn = _metaData.FieldMetaData.Count; } // Handle skipping default-valued fields while (targetColumn > _currentField) { // All intermediate fields must be default fields (i.e. have a "true" entry in SmiDefaultFieldsProperty Debug.Assert(((SmiDefaultFieldsProperty)_metaData.ExtendedProperties[SmiPropertySelector.DefaultFields])[_currentField], "Skipping a field that was not default: " + _currentField); _currentField++; } if (_metaData.FieldMetaData.Count == _currentField) { _currentField = ReadyForToken; } #endif } [Conditional("DEBUG")] internal void CheckSettingColumn(int ordinal) { #if DEBUG // Make sure target column can be written to. CheckWritingToColumn(ordinal); _currentField++; if (_metaData.FieldMetaData.Count == _currentField) { _currentField = ReadyForToken; } #endif } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Route.cs
- RouteUrlExpressionBuilder.cs
- DataRowView.cs
- HwndHostAutomationPeer.cs
- DebugView.cs
- FixedPosition.cs
- PolygonHotSpot.cs
- WindowsIdentity.cs
- Column.cs
- SecondaryIndexList.cs
- TextEditorSelection.cs
- CallInfo.cs
- TextAnchor.cs
- VirtualDirectoryMapping.cs
- DateTimeParse.cs
- InputScopeManager.cs
- FixedTextSelectionProcessor.cs
- ToolboxCategoryItems.cs
- TableItemPatternIdentifiers.cs
- QuaternionAnimation.cs
- JavaScriptSerializer.cs
- StringFunctions.cs
- FileRecordSequence.cs
- ToolTip.cs
- InvokeHandlers.cs
- EditorPartChrome.cs
- DataGridViewImageCell.cs
- Trace.cs
- __FastResourceComparer.cs
- Scripts.cs
- VersionUtil.cs
- ExpressionStringBuilder.cs
- IISMapPath.cs
- PerformanceCounterPermissionAttribute.cs
- UIElementIsland.cs
- ClipboardData.cs
- ObjRef.cs
- OutputCacheProfileCollection.cs
- OleServicesContext.cs
- securitycriticaldataClass.cs
- PageContentCollection.cs
- Empty.cs
- SqlClientWrapperSmiStreamChars.cs
- TreeIterators.cs
- SchemaInfo.cs
- MenuRendererClassic.cs
- Accessible.cs
- DirectoryGroupQuery.cs
- ColumnResizeUndoUnit.cs
- DesignerAttribute.cs
- PieceDirectory.cs
- coordinator.cs
- DesignerOptionService.cs
- MimeReflector.cs
- SecurityContext.cs
- FocusChangedEventArgs.cs
- RtfNavigator.cs
- XPathChildIterator.cs
- NativeMethodsOther.cs
- ObjectTypeMapping.cs
- DataGridViewCellConverter.cs
- SendActivity.cs
- LongValidatorAttribute.cs
- EventLogEntryCollection.cs
- TextDecorations.cs
- MessageQueueEnumerator.cs
- PingReply.cs
- SqlProfileProvider.cs
- basenumberconverter.cs
- SynchronousSendBindingElement.cs
- SeekStoryboard.cs
- PropertyContainer.cs
- FrameworkTemplate.cs
- RowParagraph.cs
- HuffCodec.cs
- ReflectionUtil.cs
- ChannelDispatcherBase.cs
- PeerDefaultCustomResolverClient.cs
- Semaphore.cs
- CodeStatement.cs
- AtomEntry.cs
- GridViewCellAutomationPeer.cs
- SimpleType.cs
- TraceHandler.cs
- XmlDataSourceNodeDescriptor.cs
- SQLResource.cs
- EventSetterHandlerConverter.cs
- ObjectHandle.cs
- HtmlEncodedRawTextWriter.cs
- SubstitutionList.cs
- JsonFormatReaderGenerator.cs
- EntityContainer.cs
- ToolboxItemCollection.cs
- VirtualDirectoryMappingCollection.cs
- ColorIndependentAnimationStorage.cs
- SqlParameterizer.cs
- XPathNavigatorKeyComparer.cs
- RectAnimationBase.cs
- querybuilder.cs
- CommonXSendMessage.cs