1 //------------------------------------------------------------------------------
2 // <copyright file="SmiContext.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 // <owner current="true" primary="false">Microsoft</owner>
7 //------------------------------------------------------------------------------
9 namespace Microsoft
.SqlServer
.Server
{
13 using System
.Data
.Sql
;
14 using System
.Data
.SqlTypes
;
15 using System
.Security
.Principal
;
17 // NOTE: connection, transaction and context pipe operations could be
18 // encapsulated in their own classes, and should if they get complex
19 // (transaction is borderline at this point).
20 internal abstract class SmiContext
{
22 internal abstract event EventHandler OutOfScope
;
24 internal abstract SmiConnection ContextConnection { get; }
26 internal abstract long ContextTransactionId { get; }
28 internal abstract System
.Transactions
.Transaction ContextTransaction { get; }
30 internal abstract bool HasContextPipe { get; }
32 internal abstract WindowsIdentity WindowsIdentity { get; }
34 internal abstract SmiRecordBuffer
CreateRecordBuffer (
35 SmiExtendedMetaData
[] columnMetaData
, // Extended metadata because it requires names, udttypename and xmlschemaname ignored
36 SmiEventSink eventSink
39 internal abstract SmiRequestExecutor
CreateRequestExecutor (
41 CommandType commandType
,
42 SmiParameterMetaData
[] parameterMetaData
,
43 SmiEventSink eventSink
48 internal abstract object GetContextValue ( int key
);
50 internal abstract void GetTriggerInfo (
51 SmiEventSink eventSink
,
52 out bool[] columnsUpdated
,
53 out TriggerAction action
,
54 out SqlXml eventInstanceData
57 internal abstract void SendMessageToPipe( string message
, SmiEventSink eventSink
);
59 internal abstract void SendResultsStartToPipe( SmiRecordBuffer recordBuffer
, SmiEventSink eventSink
);
61 internal abstract void SendResultsRowToPipe( SmiRecordBuffer recordBuffer
, SmiEventSink eventSink
);
63 internal abstract void SendResultsEndToPipe( SmiRecordBuffer recordBuffer
, SmiEventSink eventSink
);
65 internal abstract void SetContextValue ( int key
, object value );
67 // Scratch LOB storage region
68 internal virtual SmiStream
GetScratchStream( SmiEventSink sink
) {
71 // Implement body with throw because there are only a couple of ways to get to this code:
72 // 1) Client is calling this method even though the server negotiated for V2- and hasn't implemented V3 yet.
73 // 2) Server didn't implement V3, but negotiated V3+.
74 System
.Data
.Common
.ADP
.InternalError( System
.Data
.Common
.ADP
.InternalErrorCode
.UnimplementedSMIMethod
);