Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / SqlClient / TdsRecordBufferSetter.cs / 1305376 / 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
- xml.cs
- MessageFilter.cs
- Point4DValueSerializer.cs
- WindowExtensionMethods.cs
- CodeTypeParameterCollection.cs
- Helpers.cs
- ADMembershipUser.cs
- XPathNodeHelper.cs
- PathParser.cs
- IncrementalHitTester.cs
- RuleSettingsCollection.cs
- Figure.cs
- ReaderOutput.cs
- CollectionViewSource.cs
- WorkflowServiceBuildProvider.cs
- WriteFileContext.cs
- DataGridViewDataErrorEventArgs.cs
- HealthMonitoringSectionHelper.cs
- complextypematerializer.cs
- DataTemplateSelector.cs
- ClientCredentialsSecurityTokenManager.cs
- AnnotationDocumentPaginator.cs
- MembershipSection.cs
- PopupRoot.cs
- XmlSchemaAttributeGroupRef.cs
- SafeSerializationManager.cs
- TimelineCollection.cs
- FormsAuthenticationTicket.cs
- OleDbConnectionFactory.cs
- View.cs
- KnownBoxes.cs
- SimpleRecyclingCache.cs
- Authorization.cs
- UnsafeMethods.cs
- CopyNamespacesAction.cs
- BamlVersionHeader.cs
- ActivityExecutorDelegateInfo.cs
- sqlpipe.cs
- View.cs
- FileLogRecordStream.cs
- CookieHandler.cs
- XPathCompileException.cs
- RadioButton.cs
- CompressEmulationStream.cs
- ProjectedSlot.cs
- ErrorLog.cs
- cookiecollection.cs
- MapPathBasedVirtualPathProvider.cs
- DispatcherOperation.cs
- CodeDomDecompiler.cs
- HttpCacheParams.cs
- SafeNativeMethods.cs
- ServiceBuildProvider.cs
- RepeaterItem.cs
- MetadataArtifactLoaderCompositeFile.cs
- TdsParameterSetter.cs
- figurelength.cs
- ShellProvider.cs
- OdbcTransaction.cs
- FilterableAttribute.cs
- WebPartsSection.cs
- XmlQueryOutput.cs
- HostedHttpRequestAsyncResult.cs
- JapaneseCalendar.cs
- VectorCollection.cs
- InstalledFontCollection.cs
- AesManaged.cs
- PrintControllerWithStatusDialog.cs
- ExtensibleClassFactory.cs
- PropertyInfoSet.cs
- TrackingParticipant.cs
- OperationContext.cs
- TrustLevel.cs
- RowToFieldTransformer.cs
- TypedOperationInfo.cs
- XmlObjectSerializerReadContext.cs
- ResourceFallbackManager.cs
- DisplayMemberTemplateSelector.cs
- ParentUndoUnit.cs
- DesignerTransaction.cs
- basecomparevalidator.cs
- JournalEntryStack.cs
- MarshalByRefObject.cs
- XmlComplianceUtil.cs
- TraceContext.cs
- SmiMetaData.cs
- MultipartContentParser.cs
- NullableConverter.cs
- ActiveXSerializer.cs
- Ipv6Element.cs
- SoapTransportImporter.cs
- UnsafeNativeMethods.cs
- IdnMapping.cs
- CqlGenerator.cs
- Logging.cs
- ReflectionTypeLoadException.cs
- EventItfInfo.cs
- Int32EqualityComparer.cs
- BufferedReadStream.cs
- WorkflowInstance.cs