示例#1
0
 internal override void ParameterAvailable(SmiParameterMetaData metaData, SmiTypedGetterSetter paramValue, int ordinal)
 {
     if (null == _parent)
     {
         throw SQL.UnexpectedSmiEvent(UnexpectedEventType.ParameterAvailable);
     }
     _parent.ParameterAvailable(metaData, paramValue, ordinal);
 }
        // UDTs and null variants come back via return value, all else is via targetBuffer.
        //  implements SqlClient 1.1-compatible output parameter semantics
        internal static object GetOutputParameterV200Smi(
            SmiEventSink_Default sink,    // event sink for errors
            SmiTypedGetterSetter 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)
                {
                // new types go here
                case SqlDbType.Variant:     // Handle variants specifically for v200, since they could contain v200 types
                    // 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!");
                    GetOutputParameterV200Smi(sink, getters, ordinal, metaData, context, targetBuffer);
                    break;

                case SqlDbType.Date:
                    targetBuffer.SetToDate(GetDateTime_Unchecked(sink, getters, ordinal));
                    break;

                case SqlDbType.DateTime2:
                    targetBuffer.SetToDateTime2(GetDateTime_Unchecked(sink, getters, ordinal), metaData.Scale);
                    break;

                case SqlDbType.Time:
                    targetBuffer.SetToTime(GetTimeSpan_Unchecked(sink, getters, ordinal), metaData.Scale);
                    break;

                case SqlDbType.DateTimeOffset:
                    targetBuffer.SetToDateTimeOffset(GetDateTimeOffset_Unchecked(sink, getters, ordinal), metaData.Scale);
                    break;

                default:
                    result = GetOutputParameterV3Smi(sink, getters, ordinal, metaData, context, targetBuffer);
                    break;
                }
            }

            return(result);
        }