private static SmiMetaDataPropertyCollection CreateEmptyInstance() { var emptyInstance = new SmiMetaDataPropertyCollection(); emptyInstance.SetReadOnly(); return(emptyInstance); }
static SmiMetaDataPropertyCollection() { EmptyInstance.SetReadOnly(); }
// SMI V220 ctor. internal SmiMetaData( SqlDbType dbType, long maxLength, byte precision, byte scale, long localeId, SqlCompareOptions compareOptions, Type userDefinedType, string udtAssemblyQualifiedName, bool isMultiValued, IList<SmiExtendedMetaData> fieldTypes, SmiMetaDataPropertyCollection extendedProperties) { Debug.Assert( IsSupportedDbType(dbType), "Invalid SqlDbType: " + dbType ); SetDefaultsForType( dbType ); // switch ( dbType ) { case SqlDbType.BigInt: case SqlDbType.Bit: case SqlDbType.DateTime: case SqlDbType.Float: case SqlDbType.Image: case SqlDbType.Int: case SqlDbType.Money: case SqlDbType.Real: case SqlDbType.SmallDateTime: case SqlDbType.SmallInt: case SqlDbType.SmallMoney: case SqlDbType.Timestamp: case SqlDbType.TinyInt: case SqlDbType.UniqueIdentifier: case SqlDbType.Variant: case SqlDbType.Xml: case SqlDbType.Date: break; case SqlDbType.Binary: case SqlDbType.VarBinary: _maxLength = maxLength; break; case SqlDbType.Char: case SqlDbType.NChar: case SqlDbType.NVarChar: case SqlDbType.VarChar: // locale and compare options are not validated until they get to the server _maxLength = maxLength; _localeId = localeId; _compareOptions = compareOptions; break; case SqlDbType.NText: case SqlDbType.Text: _localeId = localeId; _compareOptions = compareOptions; break; case SqlDbType.Decimal: Debug.Assert( MinPrecision <= precision && SqlDecimal.MaxPrecision >= precision, "Invalid precision: " + precision ); Debug.Assert( MinScale <= scale && SqlDecimal.MaxScale >= scale, "Invalid scale: " + scale ); Debug.Assert( scale <= precision, "Precision: " + precision + " greater than scale: " + scale ); _precision = precision; _scale = scale; _maxLength = __maxLenFromPrecision[precision - 1]; break; case SqlDbType.Udt: // Assert modified for VSFTDEVDIV479492 - for SqlParameter both userDefinedType and udtAssemblyQualifiedName // can be NULL, we are checking only maxLength if it will be used (i.e. userDefinedType is NULL) Debug.Assert((null != userDefinedType) || (0 <= maxLength || UnlimitedMaxLengthIndicator == maxLength), String.Format((IFormatProvider)null, "SmiMetaData.ctor: Udt name={0}, maxLength={1}", udtAssemblyQualifiedName, maxLength)); // Type not validated until matched to a server. Could be null if extended metadata supplies three-part name! _clrType = userDefinedType; if (null != userDefinedType) { _maxLength = SerializationHelperSql9.GetUdtMaxLength(userDefinedType); } else { _maxLength = maxLength; } _udtAssemblyQualifiedName = udtAssemblyQualifiedName; break; case SqlDbType.Structured: if (null != fieldTypes) { _fieldMetaData = (new List<SmiExtendedMetaData>(fieldTypes)).AsReadOnly(); } _isMultiValued = isMultiValued; _maxLength = _fieldMetaData.Count; break; case SqlDbType.Time: Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale); _scale = scale; _maxLength = 5 - __maxVarTimeLenOffsetFromScale[scale]; break; case SqlDbType.DateTime2: Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale); _scale = scale; _maxLength = 8 - __maxVarTimeLenOffsetFromScale[scale]; break; case SqlDbType.DateTimeOffset: Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale); _scale = scale; _maxLength = 10 - __maxVarTimeLenOffsetFromScale[scale]; break; default: Debug.Assert( false, "How in the world did we get here? :" + dbType ); break; } if (null != extendedProperties) { extendedProperties.SetReadOnly(); _extendedProperties = extendedProperties; } // properties and fields must meet the following conditions at this point: // 1) not null // 2) read only // 3) same number of columns in each list (0 count acceptable for properties that are "unused") Debug.Assert(null != _extendedProperties && _extendedProperties.IsReadOnly, "SmiMetaData.ctor: _extendedProperties is " + (null!=_extendedProperties?"writeable":"null")); Debug.Assert(null != _fieldMetaData && _fieldMetaData.IsReadOnly, "SmiMetaData.ctor: _fieldMetaData is " + (null!=_fieldMetaData?"writeable":"null")); #if DEBUG ((SmiDefaultFieldsProperty)_extendedProperties[SmiPropertySelector.DefaultFields]).CheckCount(_fieldMetaData.Count); ((SmiOrderProperty)_extendedProperties[SmiPropertySelector.SortOrder]).CheckCount(_fieldMetaData.Count); ((SmiUniqueKeyProperty)_extendedProperties[SmiPropertySelector.UniqueKey]).CheckCount(_fieldMetaData.Count); #endif }
// SMI V220 ctor. internal SmiMetaData( SqlDbType dbType, long maxLength, byte precision, byte scale, long localeId, SqlCompareOptions compareOptions, bool isMultiValued, IList <SmiExtendedMetaData> fieldTypes, SmiMetaDataPropertyCollection extendedProperties) { Debug.Assert(IsSupportedDbType(dbType), "Invalid SqlDbType: " + dbType); SetDefaultsForType(dbType); switch (dbType) { case SqlDbType.BigInt: case SqlDbType.Bit: case SqlDbType.DateTime: case SqlDbType.Float: case SqlDbType.Image: case SqlDbType.Int: case SqlDbType.Money: case SqlDbType.Real: case SqlDbType.SmallDateTime: case SqlDbType.SmallInt: case SqlDbType.SmallMoney: case SqlDbType.Timestamp: case SqlDbType.TinyInt: case SqlDbType.UniqueIdentifier: case SqlDbType.Variant: case SqlDbType.Xml: case SqlDbType.Date: break; case SqlDbType.Binary: case SqlDbType.VarBinary: _maxLength = maxLength; break; case SqlDbType.Char: case SqlDbType.NChar: case SqlDbType.NVarChar: case SqlDbType.VarChar: // locale and compare options are not validated until they get to the server _maxLength = maxLength; _localeId = localeId; _compareOptions = compareOptions; break; case SqlDbType.NText: case SqlDbType.Text: _localeId = localeId; _compareOptions = compareOptions; break; case SqlDbType.Decimal: Debug.Assert(MinPrecision <= precision && SqlDecimal.MaxPrecision >= precision, "Invalid precision: " + precision); Debug.Assert(MinScale <= scale && SqlDecimal.MaxScale >= scale, "Invalid scale: " + scale); Debug.Assert(scale <= precision, "Precision: " + precision + " greater than scale: " + scale); _precision = precision; _scale = scale; _maxLength = s_maxLenFromPrecision[precision - 1]; break; case SqlDbType.Udt: throw System.Data.Common.ADP.DbTypeNotSupported(SqlDbType.Udt.ToString()); case SqlDbType.Structured: if (null != fieldTypes) { _fieldMetaData = new System.Collections.ObjectModel.ReadOnlyCollection <SmiExtendedMetaData>(fieldTypes); } _isMultiValued = isMultiValued; _maxLength = _fieldMetaData.Count; break; case SqlDbType.Time: Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale); _scale = scale; _maxLength = 5 - s_maxVarTimeLenOffsetFromScale[scale]; break; case SqlDbType.DateTime2: Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale); _scale = scale; _maxLength = 8 - s_maxVarTimeLenOffsetFromScale[scale]; break; case SqlDbType.DateTimeOffset: Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale); _scale = scale; _maxLength = 10 - s_maxVarTimeLenOffsetFromScale[scale]; break; default: Debug.Assert(false, "How in the world did we get here? :" + dbType); break; } if (null != extendedProperties) { extendedProperties.SetReadOnly(); _extendedProperties = extendedProperties; } // properties and fields must meet the following conditions at this point: // 1) not null // 2) read only // 3) same number of columns in each list (0 count acceptable for properties that are "unused") Debug.Assert(null != _extendedProperties && _extendedProperties.IsReadOnly, "SmiMetaData.ctor: _extendedProperties is " + (null != _extendedProperties ? "writable" : "null")); Debug.Assert(null != _fieldMetaData && _fieldMetaData.IsReadOnly, "SmiMetaData.ctor: _fieldMetaData is " + (null != _fieldMetaData ? "writable" : "null")); #if DEBUG ((SmiDefaultFieldsProperty)_extendedProperties[SmiPropertySelector.DefaultFields]).CheckCount(_fieldMetaData.Count); ((SmiOrderProperty)_extendedProperties[SmiPropertySelector.SortOrder]).CheckCount(_fieldMetaData.Count); ((SmiUniqueKeyProperty)_extendedProperties[SmiPropertySelector.UniqueKey]).CheckCount(_fieldMetaData.Count); #endif }
internal SmiMetaData(System.Data.SqlDbType dbType, long maxLength, byte precision, byte scale, long localeId, SqlCompareOptions compareOptions, System.Type userDefinedType, string udtAssemblyQualifiedName, bool isMultiValued, IList <SmiExtendedMetaData> fieldTypes, SmiMetaDataPropertyCollection extendedProperties) { this.SetDefaultsForType(dbType); switch (dbType) { case System.Data.SqlDbType.Binary: case System.Data.SqlDbType.VarBinary: this._maxLength = maxLength; goto Label_01BF; case System.Data.SqlDbType.Char: case System.Data.SqlDbType.NChar: case System.Data.SqlDbType.NVarChar: case System.Data.SqlDbType.VarChar: this._maxLength = maxLength; this._localeId = localeId; this._compareOptions = compareOptions; goto Label_01BF; case System.Data.SqlDbType.Decimal: this._precision = precision; this._scale = scale; this._maxLength = __maxLenFromPrecision[precision - 1]; goto Label_01BF; case System.Data.SqlDbType.NText: case System.Data.SqlDbType.Text: this._localeId = localeId; this._compareOptions = compareOptions; goto Label_01BF; case System.Data.SqlDbType.Udt: this._clrType = userDefinedType; if (null == userDefinedType) { this._maxLength = maxLength; break; } this._maxLength = SerializationHelperSql9.GetUdtMaxLength(userDefinedType); break; case System.Data.SqlDbType.Structured: if (fieldTypes != null) { this._fieldMetaData = new List <SmiExtendedMetaData>(fieldTypes).AsReadOnly(); } this._isMultiValued = isMultiValued; this._maxLength = this._fieldMetaData.Count; goto Label_01BF; case System.Data.SqlDbType.Time: this._scale = scale; this._maxLength = 5 - __maxVarTimeLenOffsetFromScale[scale]; goto Label_01BF; case System.Data.SqlDbType.DateTime2: this._scale = scale; this._maxLength = 8 - __maxVarTimeLenOffsetFromScale[scale]; goto Label_01BF; case System.Data.SqlDbType.DateTimeOffset: this._scale = scale; this._maxLength = 10 - __maxVarTimeLenOffsetFromScale[scale]; goto Label_01BF; default: goto Label_01BF; } this._udtAssemblyQualifiedName = udtAssemblyQualifiedName; Label_01BF: if (extendedProperties != null) { extendedProperties.SetReadOnly(); this._extendedProperties = extendedProperties; } }
// SMI V220 ctor. internal SmiMetaData( SqlDbType dbType, long maxLength, byte precision, byte scale, long localeId, SqlCompareOptions compareOptions, string udtAssemblyQualifiedName, bool isMultiValued, IList<SmiExtendedMetaData> fieldTypes, SmiMetaDataPropertyCollection extendedProperties) { Debug.Assert(IsSupportedDbType(dbType), "Invalid SqlDbType: " + dbType); SetDefaultsForType(dbType); switch (dbType) { case SqlDbType.BigInt: case SqlDbType.Bit: case SqlDbType.DateTime: case SqlDbType.Float: case SqlDbType.Image: case SqlDbType.Int: case SqlDbType.Money: case SqlDbType.Real: case SqlDbType.SmallDateTime: case SqlDbType.SmallInt: case SqlDbType.SmallMoney: case SqlDbType.Timestamp: case SqlDbType.TinyInt: case SqlDbType.UniqueIdentifier: case SqlDbType.Variant: case SqlDbType.Xml: case SqlDbType.Date: break; case SqlDbType.Binary: case SqlDbType.VarBinary: _maxLength = maxLength; break; case SqlDbType.Char: case SqlDbType.NChar: case SqlDbType.NVarChar: case SqlDbType.VarChar: // locale and compare options are not validated until they get to the server _maxLength = maxLength; _localeId = localeId; _compareOptions = compareOptions; break; case SqlDbType.NText: case SqlDbType.Text: _localeId = localeId; _compareOptions = compareOptions; break; case SqlDbType.Decimal: Debug.Assert(MinPrecision <= precision && SqlDecimal.MaxPrecision >= precision, "Invalid precision: " + precision); Debug.Assert(MinScale <= scale && SqlDecimal.MaxScale >= scale, "Invalid scale: " + scale); Debug.Assert(scale <= precision, "Precision: " + precision + " greater than scale: " + scale); _precision = precision; _scale = scale; _maxLength = s_maxLenFromPrecision[precision - 1]; break; case SqlDbType.Udt: throw System.Data.Common.ADP.DbTypeNotSupported(SqlDbType.Udt.ToString()); case SqlDbType.Structured: if (null != fieldTypes) { _fieldMetaData = new System.Collections.ObjectModel.ReadOnlyCollection<SmiExtendedMetaData>(fieldTypes); } _isMultiValued = isMultiValued; _maxLength = _fieldMetaData.Count; break; case SqlDbType.Time: Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale); _scale = scale; _maxLength = 5 - s_maxVarTimeLenOffsetFromScale[scale]; break; case SqlDbType.DateTime2: Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale); _scale = scale; _maxLength = 8 - s_maxVarTimeLenOffsetFromScale[scale]; break; case SqlDbType.DateTimeOffset: Debug.Assert(MinScale <= scale && scale <= MaxTimeScale, "Invalid time scale: " + scale); _scale = scale; _maxLength = 10 - s_maxVarTimeLenOffsetFromScale[scale]; break; default: Debug.Assert(false, "How in the world did we get here? :" + dbType); break; } if (null != extendedProperties) { extendedProperties.SetReadOnly(); _extendedProperties = extendedProperties; } // properties and fields must meet the following conditions at this point: // 1) not null // 2) read only // 3) same number of columns in each list (0 count acceptable for properties that are "unused") Debug.Assert(null != _extendedProperties && _extendedProperties.IsReadOnly, "SmiMetaData.ctor: _extendedProperties is " + (null != _extendedProperties ? "writeable" : "null")); Debug.Assert(null != _fieldMetaData && _fieldMetaData.IsReadOnly, "SmiMetaData.ctor: _fieldMetaData is " + (null != _fieldMetaData ? "writeable" : "null")); #if DEBUG ((SmiDefaultFieldsProperty)_extendedProperties[SmiPropertySelector.DefaultFields]).CheckCount(_fieldMetaData.Count); ((SmiUniqueKeyProperty)_extendedProperties[SmiPropertySelector.UniqueKey]).CheckCount(_fieldMetaData.Count); #endif }
static SmiMetaDataPropertyCollection() { EmptyInstance = new SmiMetaDataPropertyCollection(); EmptyInstance.SetReadOnly(); }
private static SmiMetaDataPropertyCollection CreateEmptyInstance() { var emptyInstance = new SmiMetaDataPropertyCollection(); emptyInstance.SetReadOnly(); return emptyInstance; }
internal SmiMetaData(System.Data.SqlDbType dbType, long maxLength, byte precision, byte scale, long localeId, SqlCompareOptions compareOptions, System.Type userDefinedType, string udtAssemblyQualifiedName, bool isMultiValued, IList<SmiExtendedMetaData> fieldTypes, SmiMetaDataPropertyCollection extendedProperties) { this.SetDefaultsForType(dbType); switch (dbType) { case System.Data.SqlDbType.Binary: case System.Data.SqlDbType.VarBinary: this._maxLength = maxLength; goto Label_01BF; case System.Data.SqlDbType.Char: case System.Data.SqlDbType.NChar: case System.Data.SqlDbType.NVarChar: case System.Data.SqlDbType.VarChar: this._maxLength = maxLength; this._localeId = localeId; this._compareOptions = compareOptions; goto Label_01BF; case System.Data.SqlDbType.Decimal: this._precision = precision; this._scale = scale; this._maxLength = __maxLenFromPrecision[precision - 1]; goto Label_01BF; case System.Data.SqlDbType.NText: case System.Data.SqlDbType.Text: this._localeId = localeId; this._compareOptions = compareOptions; goto Label_01BF; case System.Data.SqlDbType.Udt: this._clrType = userDefinedType; if (null == userDefinedType) { this._maxLength = maxLength; break; } this._maxLength = SerializationHelperSql9.GetUdtMaxLength(userDefinedType); break; case System.Data.SqlDbType.Structured: if (fieldTypes != null) { this._fieldMetaData = new List<SmiExtendedMetaData>(fieldTypes).AsReadOnly(); } this._isMultiValued = isMultiValued; this._maxLength = this._fieldMetaData.Count; goto Label_01BF; case System.Data.SqlDbType.Time: this._scale = scale; this._maxLength = 5 - __maxVarTimeLenOffsetFromScale[scale]; goto Label_01BF; case System.Data.SqlDbType.DateTime2: this._scale = scale; this._maxLength = 8 - __maxVarTimeLenOffsetFromScale[scale]; goto Label_01BF; case System.Data.SqlDbType.DateTimeOffset: this._scale = scale; this._maxLength = 10 - __maxVarTimeLenOffsetFromScale[scale]; goto Label_01BF; default: goto Label_01BF; } this._udtAssemblyQualifiedName = udtAssemblyQualifiedName; Label_01BF: if (extendedProperties != null) { extendedProperties.SetReadOnly(); this._extendedProperties = extendedProperties; } }