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
- X509Chain.cs
- DataBindingExpressionBuilder.cs
- CapabilitiesAssignment.cs
- Wow64ConfigurationLoader.cs
- RuntimeArgument.cs
- SyntaxCheck.cs
- WindowsFont.cs
- WindowVisualStateTracker.cs
- DrawingContext.cs
- OutputCacheSettingsSection.cs
- DataGridViewColumnHeaderCell.cs
- TypePresenter.xaml.cs
- LocalizableAttribute.cs
- X509Utils.cs
- XmlComplianceUtil.cs
- xamlnodes.cs
- TableDesigner.cs
- Identifier.cs
- MetafileHeaderWmf.cs
- AuditLogLocation.cs
- TextSelectionHighlightLayer.cs
- MachineKeyValidationConverter.cs
- WebRequestModuleElement.cs
- UserControl.cs
- EventProperty.cs
- GeneralEndpointIdentity.cs
- externdll.cs
- ClientFormsAuthenticationCredentials.cs
- XamlBuildTaskServices.cs
- Helper.cs
- ValueConversionAttribute.cs
- CryptoKeySecurity.cs
- ContextMenu.cs
- ComponentCollection.cs
- Cell.cs
- LayoutTable.cs
- CompiledQuery.cs
- Clock.cs
- ConnectorMovedEventArgs.cs
- CheckBoxRenderer.cs
- AssemblyAttributesGoHere.cs
- AutoGeneratedField.cs
- TransactionProtocol.cs
- ReaderWriterLock.cs
- FixedTextView.cs
- IDispatchConstantAttribute.cs
- HierarchicalDataBoundControl.cs
- QueryOperatorEnumerator.cs
- DataColumnPropertyDescriptor.cs
- TextTreeRootTextBlock.cs
- PersonalizationProvider.cs
- EditingCoordinator.cs
- ControlCollection.cs
- DataGridViewColumnHeaderCell.cs
- Brushes.cs
- IndicShape.cs
- CustomValidator.cs
- PersonalizationEntry.cs
- DisplayNameAttribute.cs
- BamlResourceSerializer.cs
- UnauthorizedAccessException.cs
- HttpCacheVaryByContentEncodings.cs
- ListViewInsertedEventArgs.cs
- SafeCancelMibChangeNotify.cs
- DbProviderSpecificTypePropertyAttribute.cs
- UiaCoreApi.cs
- XPathExpr.cs
- VisualStates.cs
- RowCache.cs
- CheckBoxList.cs
- DataServiceKeyAttribute.cs
- VisualStyleElement.cs
- DataSourceConverter.cs
- XPathNodeList.cs
- CodeAttributeDeclarationCollection.cs
- ManifestResourceInfo.cs
- Stopwatch.cs
- MustUnderstandSoapException.cs
- RangeValidator.cs
- TypedReference.cs
- GPPOINT.cs
- TemplateBindingExpressionConverter.cs
- DynamicPhysicalDiscoSearcher.cs
- DiffuseMaterial.cs
- figurelength.cs
- ReadWriteObjectLock.cs
- QilCloneVisitor.cs
- WindowsIPAddress.cs
- RegionInfo.cs
- TransformProviderWrapper.cs
- SyndicationItemFormatter.cs
- EntityDataSourceDataSelection.cs
- OperationResponse.cs
- SafeNativeMethods.cs
- Quad.cs
- Cursor.cs
- NavigationPropertySingletonExpression.cs
- TemplateAction.cs
- HtmlContainerControl.cs
- TraceContext.cs