本文整理汇总了C#中ITypedGettersV3.GetVariantType方法的典型用法代码示例。如果您正苦于以下问题:C# ITypedGettersV3.GetVariantType方法的具体用法?C# ITypedGettersV3.GetVariantType怎么用?C# ITypedGettersV3.GetVariantType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypedGettersV3
的用法示例。
在下文中一共展示了ITypedGettersV3.GetVariantType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTextReader
internal static TextReader GetTextReader( SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData ) {
bool isDbNull = ValueUtilsSmi.IsDBNull_Unchecked(sink, getters, ordinal);
// If a sql_variant, get the internal type
if ((!isDbNull) && (metaData.SqlDbType == SqlDbType.Variant)) {
metaData = getters.GetVariantType(sink, ordinal);
}
// If the SqlDbType is still variant, then it must contain null, so don't throw InvalidCast
if ((metaData.SqlDbType != SqlDbType.Variant) && (!CanAccessGetterDirectly(metaData, ExtendedClrTypeCode.TextReader))) {
throw ADP.InvalidCast();
}
string data;
if (isDbNull) {
// "null" textreader
data = string.Empty;
}
else {
// Read all data
data = GetString_Unchecked(sink, getters, ordinal);
}
// Wrap in pre-built object
return new StringReader(data);
}
示例2: GetSqlValue
// implements SqlClient 1.1-compatible GetSqlValue() semantics for everything except output parameters
internal static object GetSqlValue(
SmiEventSink_Default sink,
ITypedGettersV3 getters,
int ordinal,
SmiMetaData metaData,
SmiContext context
) {
object result = null;
if ( IsDBNull_Unchecked( sink, getters, ordinal ) ) {
if (SqlDbType.Udt == metaData.SqlDbType) {
result = NullUdtInstance(metaData);
}
else {
result = __typeSpecificNullForSqlValue[(int)metaData.SqlDbType];
}
}
else {
switch( metaData.SqlDbType ) {
case SqlDbType.BigInt:
result = new SqlInt64( GetInt64_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.Binary:
result = GetSqlBinary_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.Bit:
result = new SqlBoolean( GetBoolean_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.Char:
result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.DateTime:
result = new SqlDateTime( GetDateTime_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.Decimal:
result = GetSqlDecimal_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.Float:
result = new SqlDouble( GetDouble_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.Image:
result = GetSqlBinary_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.Int:
result = new SqlInt32( GetInt32_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.Money:
result = GetSqlMoney_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.NChar:
result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.NText:
result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.NVarChar:
result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.Real:
result = new SqlSingle( GetSingle_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.UniqueIdentifier:
result = new SqlGuid( GetGuid_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.SmallDateTime:
result = new SqlDateTime( GetDateTime_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.SmallInt:
result = new SqlInt16( GetInt16_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.SmallMoney:
result = GetSqlMoney_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.Text:
result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.Timestamp:
result = GetSqlBinary_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.TinyInt:
result = new SqlByte( GetByte_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.VarBinary:
result = GetSqlBinary_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.VarChar:
result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.Variant:
metaData = getters.GetVariantType( sink, ordinal );
sink.ProcessMessagesAndThrow();
Debug.Assert( SqlDbType.Variant != metaData.SqlDbType, "Variant-within-variant causes endless recursion!" );
result = GetSqlValue( sink, getters, ordinal, metaData, context );
break;
case SqlDbType.Xml:
result = GetSqlXml_Unchecked( sink, getters, ordinal, context );
break;
case SqlDbType.Udt:
result = GetUdt_LengthChecked( sink, getters, ordinal, metaData );
break;
//.........这里部分代码省略.........
示例3: GetStream
internal static Stream GetStream(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData, bool bypassTypeCheck = false) {
bool isDbNull = ValueUtilsSmi.IsDBNull_Unchecked(sink, getters, ordinal);
// If a sql_variant, get the internal type
if ( !bypassTypeCheck ) {
if ((!isDbNull) && (metaData.SqlDbType == SqlDbType.Variant)) {
metaData = getters.GetVariantType(sink, ordinal);
}
// If the SqlDbType is still variant, then it must contain null, so don't throw InvalidCast
if ((metaData.SqlDbType != SqlDbType.Variant) && (!CanAccessGetterDirectly(metaData, ExtendedClrTypeCode.Stream))) {
throw ADP.InvalidCast();
}
}
byte[] data;
if (isDbNull) {
// "null" stream
data = new byte[0];
}
else {
// Read all data
data = GetByteArray_Unchecked(sink, getters, ordinal);
}
// Wrap data in pre-built object
return new MemoryStream(data, writable: false);
}
示例4: GetOutputParameterV3Smi
// UDTs and null variants come back via return value, all else is via targetBuffer.
// implements SqlClient 2.0-compatible output parameter semantics
internal static object GetOutputParameterV3Smi(
SmiEventSink_Default sink, // event sink for errors
ITypedGettersV3 getters, // getters interface to grab value from
int ordinal, // parameter within getters
SmiMetaData metaData, // Getter's type for this ordinal
SmiContext context, // used to obtain scratch streams
SqlBuffer targetBuffer // destination
) {
object result = null; // Workaround for UDT hack in non-Smi code paths.
if ( IsDBNull_Unchecked( sink, getters, ordinal ) ) {
GetNullOutputParameterSmi(metaData, targetBuffer, ref result);
}
else {
switch( metaData.SqlDbType )
{
case SqlDbType.BigInt:
targetBuffer.Int64 = GetInt64_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.Binary:
case SqlDbType.Image:
case SqlDbType.Timestamp:
case SqlDbType.VarBinary:
targetBuffer.SqlBinary = GetSqlBinary_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.Bit:
targetBuffer.Boolean = GetBoolean_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.NChar:
case SqlDbType.NText:
case SqlDbType.NVarChar:
case SqlDbType.Char:
case SqlDbType.VarChar:
case SqlDbType.Text:
targetBuffer.SetToString( GetString_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.DateTime:
case SqlDbType.SmallDateTime: {
SqlDateTime dt = new SqlDateTime( GetDateTime_Unchecked( sink, getters, ordinal ) );
targetBuffer.SetToDateTime( dt.DayTicks, dt.TimeTicks );
break;
}
case SqlDbType.Decimal: {
SqlDecimal dec = GetSqlDecimal_Unchecked( sink, getters, ordinal );
targetBuffer.SetToDecimal( dec.Precision, dec.Scale, dec.IsPositive, dec.Data );
break;
}
case SqlDbType.Float:
targetBuffer.Double = GetDouble_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.Int:
targetBuffer.Int32 = GetInt32_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.Money:
case SqlDbType.SmallMoney:
targetBuffer.SetToMoney( GetInt64_Unchecked( sink, getters, ordinal) );
break;
case SqlDbType.Real:
targetBuffer.Single = GetSingle_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.UniqueIdentifier:
targetBuffer.SqlGuid = new SqlGuid( GetGuid_Unchecked( sink, getters, ordinal ) );
break;
case SqlDbType.SmallInt:
targetBuffer.Int16 = GetInt16_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.TinyInt:
targetBuffer.Byte = GetByte_Unchecked( sink, getters, ordinal );
break;
case SqlDbType.Variant:
// For variants, recur using the current value's sqldbtype
metaData = getters.GetVariantType( sink, ordinal );
sink.ProcessMessagesAndThrow();
Debug.Assert( SqlDbType.Variant != metaData.SqlDbType, "Variant-within-variant not supposed to be possible!" );
GetOutputParameterV3Smi( sink, getters, ordinal, metaData, context, targetBuffer );
break;
case SqlDbType.Udt:
result = GetUdt_LengthChecked( sink, getters, ordinal, metaData );
break;
case SqlDbType.Xml:
targetBuffer.SqlXml = GetSqlXml_Unchecked( sink, getters, ordinal, null );
break;
default:
Debug.Assert( false, "Unexpected SqlDbType" );
break;
}
}
return result;
}
示例5: GetValue
// implements SqlClient 1.1-compatible GetValue() semantics for everything except output parameters
internal static object GetValue(
SmiEventSink_Default sink,
ITypedGettersV3 getters,
int ordinal,
SmiMetaData metaData
)
{
object result = null;
if (IsDBNull_Unchecked(sink, getters, ordinal))
{
result = DBNull.Value;
}
else
{
switch (metaData.SqlDbType)
{
case SqlDbType.BigInt:
result = GetInt64_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Binary:
result = GetByteArray_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Bit:
result = GetBoolean_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Char:
result = GetString_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.DateTime:
result = GetDateTime_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Decimal:
result = GetSqlDecimal_Unchecked(sink, getters, ordinal).Value;
break;
case SqlDbType.Float:
result = GetDouble_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Image:
result = GetByteArray_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Int:
result = GetInt32_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Money:
result = GetSqlMoney_Unchecked(sink, getters, ordinal).Value;
break;
case SqlDbType.NChar:
result = GetString_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.NText:
result = GetString_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.NVarChar:
result = GetString_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Real:
result = GetSingle_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.UniqueIdentifier:
result = GetGuid_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.SmallDateTime:
result = GetDateTime_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.SmallInt:
result = GetInt16_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.SmallMoney:
result = GetSqlMoney_Unchecked(sink, getters, ordinal).Value;
break;
case SqlDbType.Text:
result = GetString_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Timestamp:
result = GetByteArray_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.TinyInt:
result = GetByte_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.VarBinary:
result = GetByteArray_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.VarChar:
result = GetString_Unchecked(sink, getters, ordinal);
break;
case SqlDbType.Variant:
metaData = getters.GetVariantType(sink, ordinal);
sink.ProcessMessagesAndThrow();
Debug.Assert(SqlDbType.Variant != metaData.SqlDbType, "Variant-within-variant causes endless recursion!");
result = GetValue(sink, getters, ordinal, metaData);
break;
case SqlDbType.Xml:
result = GetSqlXml_Unchecked(sink, getters, ordinal).Value;
break;
case SqlDbType.Udt:
throw ADP.DbTypeNotSupported(SqlDbType.Udt.ToString());
}
}
//.........这里部分代码省略.........
示例6: GetValue
internal static object GetValue(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData, SmiContext context)
{
object obj2 = null;
if (IsDBNull_Unchecked(sink, getters, ordinal))
{
return DBNull.Value;
}
switch (metaData.SqlDbType)
{
case SqlDbType.BigInt:
return GetInt64_Unchecked(sink, getters, ordinal);
case SqlDbType.Binary:
return GetByteArray_Unchecked(sink, getters, ordinal);
case SqlDbType.Bit:
return GetBoolean_Unchecked(sink, getters, ordinal);
case SqlDbType.Char:
return GetString_Unchecked(sink, getters, ordinal);
case SqlDbType.DateTime:
return GetDateTime_Unchecked(sink, getters, ordinal);
case SqlDbType.Decimal:
return GetSqlDecimal_Unchecked(sink, getters, ordinal).Value;
case SqlDbType.Float:
return GetDouble_Unchecked(sink, getters, ordinal);
case SqlDbType.Image:
return GetByteArray_Unchecked(sink, getters, ordinal);
case SqlDbType.Int:
return GetInt32_Unchecked(sink, getters, ordinal);
case SqlDbType.Money:
return GetSqlMoney_Unchecked(sink, getters, ordinal).Value;
case SqlDbType.NChar:
return GetString_Unchecked(sink, getters, ordinal);
case SqlDbType.NText:
return GetString_Unchecked(sink, getters, ordinal);
case SqlDbType.NVarChar:
return GetString_Unchecked(sink, getters, ordinal);
case SqlDbType.Real:
return GetSingle_Unchecked(sink, getters, ordinal);
case SqlDbType.UniqueIdentifier:
return GetGuid_Unchecked(sink, getters, ordinal);
case SqlDbType.SmallDateTime:
return GetDateTime_Unchecked(sink, getters, ordinal);
case SqlDbType.SmallInt:
return GetInt16_Unchecked(sink, getters, ordinal);
case SqlDbType.SmallMoney:
return GetSqlMoney_Unchecked(sink, getters, ordinal).Value;
case SqlDbType.Text:
return GetString_Unchecked(sink, getters, ordinal);
case SqlDbType.Timestamp:
return GetByteArray_Unchecked(sink, getters, ordinal);
case SqlDbType.TinyInt:
return GetByte_Unchecked(sink, getters, ordinal);
case SqlDbType.VarBinary:
return GetByteArray_Unchecked(sink, getters, ordinal);
case SqlDbType.VarChar:
return GetString_Unchecked(sink, getters, ordinal);
case SqlDbType.Variant:
metaData = getters.GetVariantType(sink, ordinal);
sink.ProcessMessagesAndThrow();
return GetValue(sink, getters, ordinal, metaData, context);
case (SqlDbType.SmallInt | SqlDbType.Int):
case (SqlDbType.Text | SqlDbType.Int):
case (SqlDbType.Xml | SqlDbType.Bit):
case (SqlDbType.TinyInt | SqlDbType.Int):
return obj2;
case SqlDbType.Xml:
return GetSqlXml_Unchecked(sink, getters, ordinal, context).Value;
case SqlDbType.Udt:
return GetUdt_LengthChecked(sink, getters, ordinal, metaData);
}
return obj2;
}
示例7: GetOutputParameterV3Smi
internal static object GetOutputParameterV3Smi(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData, SmiContext context, SqlBuffer targetBuffer)
{
object result = null;
if (IsDBNull_Unchecked(sink, getters, ordinal))
{
GetNullOutputParameterSmi(metaData, targetBuffer, ref result);
return result;
}
switch (metaData.SqlDbType)
{
case SqlDbType.BigInt:
targetBuffer.Int64 = GetInt64_Unchecked(sink, getters, ordinal);
return result;
case SqlDbType.Binary:
case SqlDbType.Image:
case SqlDbType.Timestamp:
case SqlDbType.VarBinary:
targetBuffer.SqlBinary = GetSqlBinary_Unchecked(sink, getters, ordinal);
return result;
case SqlDbType.Bit:
targetBuffer.Boolean = GetBoolean_Unchecked(sink, getters, ordinal);
return result;
case SqlDbType.Char:
case SqlDbType.NChar:
case SqlDbType.NText:
case SqlDbType.NVarChar:
case SqlDbType.Text:
case SqlDbType.VarChar:
targetBuffer.SetToString(GetString_Unchecked(sink, getters, ordinal));
return result;
case SqlDbType.DateTime:
case SqlDbType.SmallDateTime:
{
SqlDateTime time = new SqlDateTime(GetDateTime_Unchecked(sink, getters, ordinal));
targetBuffer.SetToDateTime(time.DayTicks, time.TimeTicks);
return result;
}
case SqlDbType.Decimal:
{
SqlDecimal num = GetSqlDecimal_Unchecked(sink, getters, ordinal);
targetBuffer.SetToDecimal(num.Precision, num.Scale, num.IsPositive, num.Data);
return result;
}
case SqlDbType.Float:
targetBuffer.Double = GetDouble_Unchecked(sink, getters, ordinal);
return result;
case SqlDbType.Int:
targetBuffer.Int32 = GetInt32_Unchecked(sink, getters, ordinal);
return result;
case SqlDbType.Money:
case SqlDbType.SmallMoney:
targetBuffer.SetToMoney(GetInt64_Unchecked(sink, getters, ordinal));
return result;
case SqlDbType.Real:
targetBuffer.Single = GetSingle_Unchecked(sink, getters, ordinal);
return result;
case SqlDbType.UniqueIdentifier:
targetBuffer.SqlGuid = new SqlGuid(GetGuid_Unchecked(sink, getters, ordinal));
return result;
case SqlDbType.SmallInt:
targetBuffer.Int16 = GetInt16_Unchecked(sink, getters, ordinal);
return result;
case SqlDbType.TinyInt:
targetBuffer.Byte = GetByte_Unchecked(sink, getters, ordinal);
return result;
case SqlDbType.Variant:
metaData = getters.GetVariantType(sink, ordinal);
sink.ProcessMessagesAndThrow();
GetOutputParameterV3Smi(sink, getters, ordinal, metaData, context, targetBuffer);
return result;
case (SqlDbType.SmallInt | SqlDbType.Int):
case (SqlDbType.Text | SqlDbType.Int):
case (SqlDbType.Xml | SqlDbType.Bit):
case (SqlDbType.TinyInt | SqlDbType.Int):
return result;
case SqlDbType.Xml:
targetBuffer.SqlXml = GetSqlXml_Unchecked(sink, getters, ordinal, null);
return result;
case SqlDbType.Udt:
return GetUdt_LengthChecked(sink, getters, ordinal, metaData);
}
return result;
}