mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
111 lines
3.7 KiB
C#
111 lines
3.7 KiB
C#
//-----------------------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//-----------------------------------------------------------------------------
|
|
namespace System.ServiceModel.ComIntegration
|
|
{
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Runtime;
|
|
using System.Runtime.InteropServices;
|
|
using System.ServiceModel.Diagnostics;
|
|
using System.Threading;
|
|
|
|
class ComPlusSynchronizationContext : SynchronizationContext
|
|
{
|
|
IServiceActivity activity;
|
|
bool postSynchronous;
|
|
|
|
public ComPlusSynchronizationContext(IServiceActivity activity,
|
|
bool postSynchronous)
|
|
{
|
|
this.activity = activity;
|
|
this.postSynchronous = postSynchronous;
|
|
}
|
|
|
|
public override void Send(SendOrPostCallback d, Object state)
|
|
{
|
|
Fx.Assert("Send should never be called");
|
|
}
|
|
|
|
public override void Post(SendOrPostCallback d, Object state)
|
|
{
|
|
ComPlusActivityTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationEnteringActivity,
|
|
SR.TraceCodeComIntegrationEnteringActivity);
|
|
|
|
ServiceCall call = new ServiceCall(d, state);
|
|
if (this.postSynchronous)
|
|
{
|
|
this.activity.SynchronousCall(call);
|
|
}
|
|
else
|
|
{
|
|
this.activity.AsynchronousCall(call);
|
|
}
|
|
ComPlusActivityTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationLeftActivity,
|
|
SR.TraceCodeComIntegrationLeftActivity);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
while (Marshal.ReleaseComObject(this.activity) > 0);
|
|
}
|
|
|
|
class ServiceCall : IServiceCall
|
|
{
|
|
SendOrPostCallback callback;
|
|
Object state;
|
|
|
|
public ServiceCall(SendOrPostCallback callback,
|
|
Object state)
|
|
{
|
|
this.callback = callback;
|
|
this.state = state;
|
|
}
|
|
|
|
|
|
|
|
public void OnCall()
|
|
{
|
|
ServiceModelActivity activity = null;
|
|
try
|
|
{
|
|
Guid guidLogicalThreadID = Guid.Empty;
|
|
|
|
if (DiagnosticUtility.ShouldUseActivity)
|
|
{
|
|
IComThreadingInfo comThreadingInfo;
|
|
comThreadingInfo = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(ComPlusActivityTrace.IID_IComThreadingInfo);
|
|
|
|
if (comThreadingInfo != null)
|
|
{
|
|
|
|
comThreadingInfo.GetCurrentLogicalThreadId(out guidLogicalThreadID);
|
|
|
|
activity = ServiceModelActivity.CreateBoundedActivity(guidLogicalThreadID);
|
|
}
|
|
ServiceModelActivity.Start(activity, SR.GetString(SR.TransferringToComplus, guidLogicalThreadID.ToString()), ActivityType.TransferToComPlus);
|
|
}
|
|
ComPlusActivityTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationExecutingCall, SR.TraceCodeComIntegrationExecutingCall);
|
|
|
|
this.callback(this.state);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
if (Fx.IsFatal(e))
|
|
throw;
|
|
|
|
DiagnosticUtility.InvokeFinalHandler(e);
|
|
}
|
|
finally
|
|
{
|
|
if (activity != null)
|
|
{
|
|
activity.Dispose();
|
|
activity = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|