Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SmiTypedGetterSetter.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiTypedGetterSetter.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SmiEventSink.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SmiEventSink_Default.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink_Default.Common.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Reliability\Common\SqlRetryingEventArgs.cs">
<Link>Microsoft\Data\SqlClient\Reliability\SqlRetryingEventArgs.cs</Link>
</Compile>
Expand Down Expand Up @@ -455,8 +461,6 @@
</EmbeddedResource>
<Compile Include="Microsoft\Data\SqlClient\AAsyncCallContext.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\MetadataUtilsSmi.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiEventSink.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiEventSink_Default.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiMetaDataProperty.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiXetterAccessMap.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SqlDataRecord.cs" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,15 @@
<Compile Include="..\..\src\Microsoft\Data\SqlClient\ColumnEncryptionKeyInfo.cs">
<Link>Microsoft\Data\SqlClient\ColumnEncryptionKeyInfo.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SmiEventSink.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SmiEventSink_Default.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink_Default.Common.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Server\SmiEventSink_Default.netfx.cs">
<Link>Microsoft\Data\SqlClient\Server\SmiEventSink_Default.netfx.cs</Link>
</Compile>
<Compile Include="..\..\src\Microsoft\Data\SqlClient\OnChangedEventHandler.cs">
<Link>Microsoft\Data\SqlClient\OnChangedEventHandler.cs</Link>
</Compile>
Expand Down Expand Up @@ -558,8 +567,6 @@
<Compile Include="Microsoft\Data\SqlClient\Server\SmiConnection.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiContext.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiContextFactory.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiEventSink.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiEventSink_Default.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiEventSink_DeferedProcessing.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiEventStream.cs" />
<Compile Include="Microsoft\Data\SqlClient\Server\SmiExecuteType.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

namespace Microsoft.Data.SqlClient.Server
{

// SqlEventSink is implemented by calling code. In all methods that accept
// a SqlEventSink directly the sink must be able to handle multiple callbacks
// without control returning from the original call.

// Methods that do not accept SmiEventSync are (generally) ProcessEvent on
// the SmiEventStream methods returning a SmiEventStream and methods that
// are certain to never call to the server (most will, for in-proc back end).

// Methods are commented with their corresponding TDS token

// NOTE: Throwing from these methods will not usually produce the desired
// effect -- the managed to native boundary will eat any exceptions,
// and will cause a simple "Something bad happened" exception to be
// thrown in the native to managed boundary...
/// <summary>
/// SqlEventSink is implemented by calling code. In all methods that accept
/// a SqlEventSink directly the sink must be able to handle multiple callbacks
/// without control returning from the original call.
///
/// Methods that do not accept SmiEventSync are (generally) ProcessEvent on
/// the SmiEventStream methods returning a SmiEventStream and methods that
/// are certain to never call to the server (most will, for in-proc back end).
///
/// Methods are commented with their corresponding TDS token
///
/// NOTE: Throwing from these methods will not usually produce the desired
/// effect -- the managed to native boundary will eat any exceptions,
/// and will cause a simple "Something bad happened" exception to be
/// thrown in the native to managed boundary...
/// </summary>
internal abstract class SmiEventSink
{

#region Active methods
#if NETFRAMEWORK

// Called at end of stream whether errors or no
internal abstract void BatchCompleted();
Expand Down Expand Up @@ -80,10 +80,9 @@ internal virtual void RowAvailable(SmiTypedGetterSetter rowData)
// Called when a transaction is started (ENVCHANGE token)
internal abstract void TransactionStarted(long transactionId);

#endregion

#region OBSOLETE METHODS
#region OBSOLETED as of V200 but active in previous version
#region OBSOLETE METHODS
#region OBSOLETED as of V200 but active in previous version
// Called zero or one time when output parameters are available (errors could prevent event from occuring)
internal virtual void ParametersAvailable(SmiParameterMetaData[] metaData, ITypedGettersV3 paramValues)
{
Expand All @@ -108,9 +107,9 @@ internal virtual void RowAvailable(ITypedGettersV3 rowData)
Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
}

#endregion
#endregion

#region OBSOLETED and never shipped (without ObsoleteAttribute)
#region OBSOLETED and never shipped (without ObsoleteAttribute)
// Called when a new row arrives (ROW token)
internal virtual void RowAvailable(ITypedGetters rowData)
{
Expand All @@ -123,8 +122,9 @@ internal virtual void RowAvailable(ITypedGetters rowData)
Microsoft.Data.Common.ADP.InternalError(Microsoft.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod);
}

#endregion
#endregion
#endregion
#endregion

#endif
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,98 @@

namespace Microsoft.Data.SqlClient.Server
{
internal class SmiEventSink_Default : SmiEventSink
internal partial class SmiEventSink_Default : SmiEventSink
{
private SqlErrorCollection _errors;
private SqlErrorCollection _warnings;

internal virtual string ServerVersion => null;

internal SmiEventSink_Default()
{
}

internal bool HasMessages
{
get
{
#if NETFRAMEWORK
SmiEventSink_Default parent = (SmiEventSink_Default)_parent;
if (null != parent)
{
return parent.HasMessages;
}
else
#endif
{
bool result = (null != _errors || null != _warnings);
return result;
}
}
}

virtual internal string ServerVersion
{
get
{
return null;
}
}


protected virtual void DispatchMessages()
protected virtual void DispatchMessages(
#if NETFRAMEWORK
bool ignoreNonFatalMessages
#endif
)
{
// virtual because we want a default implementation in the cases
// where we don't have a connection to process stuff, but we want to
// provide the connection the ability to fire info messages when it
// hooks up.
#if NETFRAMEWORK
SmiEventSink_Default parent = (SmiEventSink_Default)_parent;
if (null != parent)
{
SqlException errors = ProcessMessages(true); // ignore warnings, because there's no place to send them...
parent.DispatchMessages(ignoreNonFatalMessages);
}
else
#endif
{
SqlException errors = ProcessMessages(true
#if NETFRAMEWORK
, ignoreNonFatalMessages
#endif
); // ignore warnings, because there's no place to send them...
if (null != errors)
{
throw errors;
}
}

}

protected SqlException ProcessMessages(bool ignoreWarnings)
protected SqlException ProcessMessages(bool ignoreWarnings
#if NETFRAMEWORK
, bool ignoreNonFatalMessages
#endif
)
{
SqlException result = null;
SqlErrorCollection temp = null; // temp variable to store that which is being thrown - so that local copies can be deleted

if (null != _errors)
{
Debug.Assert(0 != _errors.Count, "empty error collection?"); // must be something in the collection

#if NETFRAMEWORK
if (ignoreNonFatalMessages)
{
temp = new SqlErrorCollection();
foreach (SqlError error in _errors)
{
if (error.Class >= TdsEnums.FATAL_ERROR_CLASS)
{
temp.Add(error);
}
}
if (temp.Count <= 0)
{
temp = null;
}
}
else
#endif
{
if (null != _warnings)
{
Expand Down Expand Up @@ -92,20 +134,16 @@ protected SqlException ProcessMessages(bool ignoreWarnings)
return result;
}


internal void ProcessMessagesAndThrow()
{
#if NETFRAMEWORK
ProcessMessagesAndThrow(false);
#else
if (HasMessages)
{
DispatchMessages();
}
}



internal SmiEventSink_Default()
{
#endif
}
}
}

Loading