Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@175 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
22 changed files with 894 additions and 0 deletions
@ -0,0 +1,85 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.Remoting.Channels; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Runtime.Remoting.Messaging; |
||||||
|
using System.IO; |
||||||
|
using System.Threading; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
class InvokeOnSTAClientChannelSink : BaseChannelSinkWithProperties, IClientFormatterSink |
||||||
|
{ |
||||||
|
IClientFormatterSink nextSink; |
||||||
|
|
||||||
|
public InvokeOnSTAClientChannelSink(IClientFormatterSink nextSink) |
||||||
|
{ |
||||||
|
this.nextSink = nextSink; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// IClientChannelSink Members
|
||||||
|
|
||||||
|
void IClientChannelSink.AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream) |
||||||
|
{ |
||||||
|
nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream); |
||||||
|
} |
||||||
|
|
||||||
|
void IClientChannelSink.AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream) |
||||||
|
{ |
||||||
|
nextSink.AsyncProcessResponse(sinkStack, state, headers, stream); |
||||||
|
} |
||||||
|
|
||||||
|
Stream IClientChannelSink.GetRequestStream(IMessage msg, ITransportHeaders headers) |
||||||
|
{ |
||||||
|
return nextSink.GetRequestStream(msg, headers); |
||||||
|
} |
||||||
|
|
||||||
|
IClientChannelSink IClientChannelSink.NextChannelSink { |
||||||
|
get { |
||||||
|
return nextSink; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void IClientChannelSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, out ITransportHeaders responseHeaders, out Stream responseStream) |
||||||
|
{ |
||||||
|
nextSink.ProcessMessage(msg, requestHeaders, requestStream, out responseHeaders, out responseStream); |
||||||
|
} |
||||||
|
|
||||||
|
// IMessageSink Members
|
||||||
|
|
||||||
|
IMessageCtrl IMessageSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink) |
||||||
|
{ |
||||||
|
return nextSink.AsyncProcessMessage(msg, replySink); |
||||||
|
} |
||||||
|
|
||||||
|
IMessageSink IMessageSink.NextSink { |
||||||
|
get { |
||||||
|
return nextSink; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
IMessage IMessageSink.SyncProcessMessage(IMessage msg) |
||||||
|
{ |
||||||
|
IMessage response = null; |
||||||
|
Thread thread = new Thread(new ThreadStart(delegate { |
||||||
|
response = nextSink.SyncProcessMessage(msg); |
||||||
|
})); |
||||||
|
|
||||||
|
thread.Start(); |
||||||
|
|
||||||
|
while (thread.IsAlive) Application.DoEvents(); |
||||||
|
|
||||||
|
return response; |
||||||
|
} |
||||||
|
|
||||||
|
// IChannelSinkBase Members
|
||||||
|
|
||||||
|
System.Collections.IDictionary IChannelSinkBase.Properties { |
||||||
|
get { |
||||||
|
return this.Properties; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.Remoting.Channels; |
||||||
|
using System.Collections; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
class InvokeOnSTAClientChannelSinkProvider: IClientChannelSinkProvider |
||||||
|
{ |
||||||
|
private IClientChannelSinkProvider nextProvider; |
||||||
|
|
||||||
|
public InvokeOnSTAClientChannelSinkProvider(IDictionary properties, ICollection providerData) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
IClientChannelSink IClientChannelSinkProvider.CreateSink(IChannelSender channel, string url, object remoteChannelData) |
||||||
|
{ |
||||||
|
IClientChannelSink nextSink = nextProvider.CreateSink(channel, url, remoteChannelData); |
||||||
|
IClientChannelSink thisSink = new InvokeOnSTAClientChannelSink(nextSink as IClientFormatterSink); |
||||||
|
return thisSink; |
||||||
|
} |
||||||
|
|
||||||
|
IClientChannelSinkProvider IClientChannelSinkProvider.Next { |
||||||
|
get { |
||||||
|
return nextProvider; |
||||||
|
} |
||||||
|
set { |
||||||
|
nextProvider = value; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,62 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.Remoting.Channels; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Runtime.Remoting.Messaging; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
class InvokeOnSTAServerChannelSink: BaseChannelSinkWithProperties, IServerChannelSink |
||||||
|
{ |
||||||
|
IServerChannelSink nextSink; |
||||||
|
|
||||||
|
public InvokeOnSTAServerChannelSink(IServerChannelSink nextSink) |
||||||
|
{ |
||||||
|
this.nextSink = nextSink; |
||||||
|
} |
||||||
|
|
||||||
|
void IServerChannelSink.AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, object state, System.Runtime.Remoting.Messaging.IMessage msg, ITransportHeaders headers, System.IO.Stream stream) |
||||||
|
{ |
||||||
|
nextSink.AsyncProcessResponse(sinkStack, state, msg, headers, stream); |
||||||
|
} |
||||||
|
|
||||||
|
System.IO.Stream IServerChannelSink.GetResponseStream(IServerResponseChannelSinkStack sinkStack, object state, System.Runtime.Remoting.Messaging.IMessage msg, ITransportHeaders headers) |
||||||
|
{ |
||||||
|
return nextSink.GetResponseStream(sinkStack, state, msg, headers); |
||||||
|
} |
||||||
|
|
||||||
|
IServerChannelSink IServerChannelSink.NextChannelSink { |
||||||
|
get { |
||||||
|
return nextSink; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ServerProcessing IServerChannelSink.ProcessMessage(IServerChannelSinkStack sinkStack, System.Runtime.Remoting.Messaging.IMessage requestMsg, ITransportHeaders requestHeaders, System.IO.Stream requestStream, out System.Runtime.Remoting.Messaging.IMessage responseMsg, out ITransportHeaders responseHeaders, out System.IO.Stream responseStream) |
||||||
|
{ |
||||||
|
if (Application.OpenForms.Count > 0) { |
||||||
|
IMessage outResponseMsg = null; |
||||||
|
ITransportHeaders outResponseHeaders = null; |
||||||
|
Stream outResponseStream = null; |
||||||
|
ServerProcessing returnValue = ServerProcessing.Complete; |
||||||
|
Application.OpenForms[0].Invoke(new EventHandler(delegate |
||||||
|
{ |
||||||
|
returnValue = nextSink.ProcessMessage(sinkStack, requestMsg, requestHeaders, requestStream, out outResponseMsg, out outResponseHeaders, out outResponseStream); |
||||||
|
})); |
||||||
|
responseMsg = outResponseMsg; |
||||||
|
responseHeaders = outResponseHeaders; |
||||||
|
responseStream = outResponseStream; |
||||||
|
return returnValue; |
||||||
|
} else { |
||||||
|
return nextSink.ProcessMessage(sinkStack, requestMsg, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
System.Collections.IDictionary IChannelSinkBase.Properties { |
||||||
|
get { |
||||||
|
return this.Properties; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,37 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.Remoting.Channels; |
||||||
|
using System.Collections; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
class InvokeOnSTAServerChannelSinkProvider: IServerChannelSinkProvider |
||||||
|
{ |
||||||
|
private IServerChannelSinkProvider nextProvider; |
||||||
|
|
||||||
|
public InvokeOnSTAServerChannelSinkProvider(IDictionary properties, ICollection providerData) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
IServerChannelSink IServerChannelSinkProvider.CreateSink(IChannelReceiver channel) |
||||||
|
{ |
||||||
|
IServerChannelSink nextSink = nextProvider.CreateSink(channel); |
||||||
|
IServerChannelSink thisSink = new InvokeOnSTAServerChannelSink(nextSink); |
||||||
|
return thisSink; |
||||||
|
} |
||||||
|
|
||||||
|
void IServerChannelSinkProvider.GetChannelData(IChannelDataStore channelData) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
IServerChannelSinkProvider IServerChannelSinkProvider.Next { |
||||||
|
get { |
||||||
|
return nextProvider; |
||||||
|
} |
||||||
|
set { |
||||||
|
nextProvider = value; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Library</OutputType> |
||||||
|
<RootNamespace>InvokeOnSTASink</RootNamespace> |
||||||
|
<AssemblyName>InvokeOnSTASink</AssemblyName> |
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||||
|
<ProjectGuid>{068578FE-412A-48DC-B90C-B7D2B8593DB4}</ProjectGuid> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||||
|
<Optimize>false</Optimize> |
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||||
|
<OutputPath>bin\Release\</OutputPath> |
||||||
|
<Optimize>true</Optimize> |
||||||
|
<DefineConstants>TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Reference Include="System" /> |
||||||
|
<Reference Include="System.Xml" /> |
||||||
|
<Reference Include="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
||||||
|
<Reference Include="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="InvokeOnSTAClientChannelSink.cs" /> |
||||||
|
<Compile Include="InvokeOnSTAClientChannelSinkProvider.cs" /> |
||||||
|
<Compile Include="InvokeOnSTAServerChannelSink.cs" /> |
||||||
|
<Compile Include="InvokeOnSTAServerChannelSinkProvider.cs" /> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
||||||
|
</Project> |
||||||
@ -0,0 +1,71 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
public class EventForwarder:MarshalByRefObject |
||||||
|
{ |
||||||
|
Delegate realEvent; |
||||||
|
|
||||||
|
public EventForwarder(Delegate realEvent) |
||||||
|
{ |
||||||
|
this.realEvent = realEvent; |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent0() |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] {}); |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent1(object p1) |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] { p1}); |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent2(object p1, object p2) |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] { p1, p2}); |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent3(object p1, object p2, object p3) |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] { p1, p2, p3}); |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent4(object p1, object p2, object p3, object p4) |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] { p1, p2, p3, p4}); |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent5(object p1, object p2, object p3, object p4, object p5) |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] { p1, p2, p3, p4, p5}); |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent6(object p1, object p2, object p3, object p4, object p5, object p6) |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] { p1, p2, p3, p4, p5, p6}); |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent7(object p1, object p2, object p3, object p4, object p5, object p6, object p7) |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] { p1, p2, p3, p4, p5, p6, p7}); |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent8(object p1, object p2, object p3, object p4, object p5, object p6, object p7, object p8) |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] { p1, p2, p3, p4, p5, p6, p7, p8}); |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent9(object p1, object p2, object p3, object p4, object p5, object p6, object p7, object p8, object p9) |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] { p1, p2, p3, p4, p5, p6, p7, p8, p9}); |
||||||
|
} |
||||||
|
|
||||||
|
public void ForwardEvent10(object p1, object p2, object p3, object p4, object p5, object p6, object p7, object p8, object p9, object p10) |
||||||
|
{ |
||||||
|
realEvent.DynamicInvoke(new object[] { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10}); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,87 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.Remoting.Channels; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Runtime.Remoting.Messaging; |
||||||
|
using System.IO; |
||||||
|
using System.Threading; |
||||||
|
using System.Reflection; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
class PrivateEventHandlersClientChannelSink : BaseChannelSinkWithProperties, IClientFormatterSink |
||||||
|
{ |
||||||
|
IClientFormatterSink nextSink; |
||||||
|
|
||||||
|
public PrivateEventHandlersClientChannelSink(IClientFormatterSink nextSink) |
||||||
|
{ |
||||||
|
this.nextSink = nextSink; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// IClientChannelSink Members
|
||||||
|
|
||||||
|
void IClientChannelSink.AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg, ITransportHeaders headers, Stream stream) |
||||||
|
{ |
||||||
|
nextSink.AsyncProcessRequest(sinkStack, msg, headers, stream); |
||||||
|
} |
||||||
|
|
||||||
|
void IClientChannelSink.AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream) |
||||||
|
{ |
||||||
|
nextSink.AsyncProcessResponse(sinkStack, state, headers, stream); |
||||||
|
} |
||||||
|
|
||||||
|
Stream IClientChannelSink.GetRequestStream(IMessage msg, ITransportHeaders headers) |
||||||
|
{ |
||||||
|
return nextSink.GetRequestStream(msg, headers); |
||||||
|
} |
||||||
|
|
||||||
|
IClientChannelSink IClientChannelSink.NextChannelSink { |
||||||
|
get { |
||||||
|
return nextSink; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void IClientChannelSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, out ITransportHeaders responseHeaders, out Stream responseStream) |
||||||
|
{ |
||||||
|
nextSink.ProcessMessage(msg, requestHeaders, requestStream, out responseHeaders, out responseStream); |
||||||
|
} |
||||||
|
|
||||||
|
// IMessageSink Members
|
||||||
|
|
||||||
|
IMessageCtrl IMessageSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink) |
||||||
|
{ |
||||||
|
return nextSink.AsyncProcessMessage(msg, replySink); |
||||||
|
} |
||||||
|
|
||||||
|
IMessageSink IMessageSink.NextSink { |
||||||
|
get { |
||||||
|
return nextSink; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
IMessage IMessageSink.SyncProcessMessage(IMessage msg) |
||||||
|
{ |
||||||
|
MethodCall methodCall = new MethodCall(msg); |
||||||
|
if (methodCall.ArgCount > 0 && methodCall.Args[0] is Delegate) { |
||||||
|
Delegate realDelegate = methodCall.Args[0] as Delegate; |
||||||
|
Type type = realDelegate.GetType(); |
||||||
|
EventForwarder eventForwarder = new EventForwarder(realDelegate); |
||||||
|
MethodInfo proxyMethod = typeof(EventForwarder).GetMethod("ForwardEvent" + realDelegate.Method.GetParameters().Length); |
||||||
|
Delegate proxyDelegate = Delegate.CreateDelegate(type, eventForwarder, proxyMethod); |
||||||
|
methodCall.Args[0] = proxyDelegate; |
||||||
|
} |
||||||
|
|
||||||
|
return nextSink.SyncProcessMessage(methodCall); |
||||||
|
} |
||||||
|
|
||||||
|
// IChannelSinkBase Members
|
||||||
|
|
||||||
|
System.Collections.IDictionary IChannelSinkBase.Properties { |
||||||
|
get { |
||||||
|
return this.Properties; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.Remoting.Channels; |
||||||
|
using System.Collections; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
class PrivateEventHandlersClientChannelSinkProvider: IClientChannelSinkProvider |
||||||
|
{ |
||||||
|
private IClientChannelSinkProvider nextProvider; |
||||||
|
|
||||||
|
public PrivateEventHandlersClientChannelSinkProvider(IDictionary properties, ICollection providerData) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
IClientChannelSink IClientChannelSinkProvider.CreateSink(IChannelSender channel, string url, object remoteChannelData) |
||||||
|
{ |
||||||
|
IClientChannelSink nextSink = nextProvider.CreateSink(channel, url, remoteChannelData); |
||||||
|
IClientChannelSink thisSink = new PrivateEventHandlersClientChannelSink(nextSink as IClientFormatterSink); |
||||||
|
return thisSink; |
||||||
|
} |
||||||
|
|
||||||
|
IClientChannelSinkProvider IClientChannelSinkProvider.Next { |
||||||
|
get { |
||||||
|
return nextProvider; |
||||||
|
} |
||||||
|
set { |
||||||
|
nextProvider = value; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Library</OutputType> |
||||||
|
<RootNamespace>PrivateEventHandlersSink</RootNamespace> |
||||||
|
<AssemblyName>PrivateEventHandlersSink</AssemblyName> |
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||||
|
<ProjectGuid>{6AF77F6A-775A-45DF-97B8-AAD76CD4023B}</ProjectGuid> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||||
|
<Optimize>false</Optimize> |
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||||
|
<OutputPath>bin\Release\</OutputPath> |
||||||
|
<Optimize>true</Optimize> |
||||||
|
<DefineConstants>TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Reference Include="System" /> |
||||||
|
<Reference Include="System.Xml" /> |
||||||
|
<Reference Include="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="EventForwarder.cs" /> |
||||||
|
<Compile Include="PrivateEventHandlersClientChannelSink.cs" /> |
||||||
|
<Compile Include="PrivateEventHandlersClientChannelSinkProvider.cs" /> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
||||||
|
</Project> |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||||
|
# SharpDevelop 2.0.0.1 |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InvokeOnSTASink", "InvokeOnSTASink\InvokeOnSTASink.csproj", "{068578FE-412A-48DC-B90C-B7D2B8593DB4}" |
||||||
|
EndProject |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrivateEventHandlersSink", "PrivateEventHandlersSink\PrivateEventHandlersSink.csproj", "{6AF77F6A-775A-45DF-97B8-AAD76CD4023B}" |
||||||
|
EndProject |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestClient", "TestClient\TestClient.csproj", "{2DDD7699-76DC-492D-85A6-BB3B5CBB5FC3}" |
||||||
|
EndProject |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestCommonTypes", "TestCommonTypes\TestCommonTypes.csproj", "{C2A2838E-E87F-47C3-9440-556875E1BB5E}" |
||||||
|
EndProject |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestServer", "TestServer\TestServer.csproj", "{1EE49A1D-7098-4B75-B174-B36C803EA9EB}" |
||||||
|
EndProject |
||||||
|
Global |
||||||
|
EndGlobal |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8" ?> |
||||||
|
<configuration> |
||||||
|
<system.runtime.remoting> |
||||||
|
<application> |
||||||
|
<client> |
||||||
|
<wellknown |
||||||
|
url="http://localhost:8686/ChatServer.rem" |
||||||
|
type="CustomSinks.ChatServer, TestCommonTypes" |
||||||
|
/> |
||||||
|
</client> |
||||||
|
<channels> |
||||||
|
<channel ref="http" port="0"> |
||||||
|
<clientProviders> |
||||||
|
<provider type="CustomSinks.PrivateEventHandlersClientChannelSinkProvider, PrivateEventHandlersSink" |
||||||
|
customSinkType="CustomSinks.PrivateEventHandlersClientChannelSink, PrivateEventHandlersSink" /> |
||||||
|
<provider type="CustomSinks.InvokeOnSTAClientChannelSinkProvider, InvokeOnSTASink" |
||||||
|
customSinkType="CustomSinks.InvokeOnSTAClientChannelSink, InvokeOnSTASink" /> |
||||||
|
<formatter ref="soap" typeFilterLevel="Full"/> |
||||||
|
</clientProviders> |
||||||
|
<serverProviders> |
||||||
|
<formatter ref="soap" typeFilterLevel="Full"/> |
||||||
|
<provider type="CustomSinks.InvokeOnSTAServerChannelSinkProvider, InvokeOnSTASink" |
||||||
|
customSinkType="CustomSinks.InvokeOnSTAServerChannelSink, InvokeOnSTASink" /> |
||||||
|
</serverProviders> |
||||||
|
</channel> |
||||||
|
</channels> |
||||||
|
</application> |
||||||
|
</system.runtime.remoting> |
||||||
|
</configuration> |
||||||
@ -0,0 +1,88 @@ |
|||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
partial class FormClient |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null; |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing) |
||||||
|
{ |
||||||
|
if (disposing && (components != null)) |
||||||
|
{ |
||||||
|
components.Dispose(); |
||||||
|
} |
||||||
|
base.Dispose(disposing); |
||||||
|
} |
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent() |
||||||
|
{ |
||||||
|
this.buttonSend = new System.Windows.Forms.Button(); |
||||||
|
this.textBoxInput = new System.Windows.Forms.TextBox(); |
||||||
|
this.richTextBoxChat = new System.Windows.Forms.RichTextBox(); |
||||||
|
this.SuspendLayout(); |
||||||
|
//
|
||||||
|
// buttonSend
|
||||||
|
//
|
||||||
|
this.buttonSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.buttonSend.Location = new System.Drawing.Point(184, 158); |
||||||
|
this.buttonSend.Name = "buttonSend"; |
||||||
|
this.buttonSend.Size = new System.Drawing.Size(75, 23); |
||||||
|
this.buttonSend.TabIndex = 0; |
||||||
|
this.buttonSend.Text = "Send"; |
||||||
|
this.buttonSend.Click += new System.EventHandler(this.buttonSend_Click); |
||||||
|
//
|
||||||
|
// textBoxInput
|
||||||
|
//
|
||||||
|
this.textBoxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.textBoxInput.Location = new System.Drawing.Point(2, 158); |
||||||
|
this.textBoxInput.Name = "textBoxInput"; |
||||||
|
this.textBoxInput.Size = new System.Drawing.Size(176, 26); |
||||||
|
this.textBoxInput.TabIndex = 1; |
||||||
|
//
|
||||||
|
// richTextBoxChat
|
||||||
|
//
|
||||||
|
this.richTextBoxChat.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
||||||
|
| System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.richTextBoxChat.Location = new System.Drawing.Point(2, 2); |
||||||
|
this.richTextBoxChat.Name = "richTextBoxChat"; |
||||||
|
this.richTextBoxChat.Size = new System.Drawing.Size(257, 150); |
||||||
|
this.richTextBoxChat.TabIndex = 2; |
||||||
|
this.richTextBoxChat.Text = ""; |
||||||
|
//
|
||||||
|
// FormClient
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); |
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||||
|
this.ClientSize = new System.Drawing.Size(262, 188); |
||||||
|
this.Controls.Add(this.richTextBoxChat); |
||||||
|
this.Controls.Add(this.textBoxInput); |
||||||
|
this.Controls.Add(this.buttonSend); |
||||||
|
this.Name = "FormClient"; |
||||||
|
this.Text = "Client"; |
||||||
|
this.ResumeLayout(false); |
||||||
|
this.PerformLayout(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button buttonSend; |
||||||
|
private System.Windows.Forms.TextBox textBoxInput; |
||||||
|
private System.Windows.Forms.RichTextBox richTextBoxChat; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
@ -0,0 +1,32 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Drawing; |
||||||
|
using System.Text; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Runtime.Remoting; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
public partial class FormClient : Form |
||||||
|
{ |
||||||
|
ChatServer chatServer; |
||||||
|
|
||||||
|
public FormClient() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
RemotingConfiguration.Configure("Client.exe.config"); |
||||||
|
chatServer = new ChatServer(); |
||||||
|
chatServer.NewMessage += |
||||||
|
delegate(object sender, TextMessageEventArgs args) |
||||||
|
{ |
||||||
|
richTextBoxChat.AppendText(args.Message + "\r\n"); |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
private void buttonSend_Click(object sender, EventArgs e) |
||||||
|
{ |
||||||
|
chatServer.SendMessage(textBoxInput.Text); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Runtime.Remoting; |
||||||
|
using System.Threading; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
static class Program |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread] |
||||||
|
static void Main() |
||||||
|
{ |
||||||
|
Thread.CurrentThread.Name = "Client (STA)"; |
||||||
|
|
||||||
|
Application.EnableVisualStyles(); |
||||||
|
Application.Run(new FormClient()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>WinExe</OutputType> |
||||||
|
<RootNamespace>TestClient</RootNamespace> |
||||||
|
<AssemblyName>TestClient</AssemblyName> |
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||||
|
<ProjectGuid>{2DDD7699-76DC-492D-85A6-BB3B5CBB5FC3}</ProjectGuid> |
||||||
|
<StartupObject /> |
||||||
|
<ApplicationIcon /> |
||||||
|
<Win32Resource /> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||||
|
<Optimize>false</Optimize> |
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||||
|
<OutputPath>bin\Release\</OutputPath> |
||||||
|
<Optimize>true</Optimize> |
||||||
|
<DefineConstants>TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Reference Include="System" /> |
||||||
|
<Reference Include="System.Xml" /> |
||||||
|
<Reference Include="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
||||||
|
<Reference Include="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
||||||
|
<Reference Include="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="FormClient.cs" /> |
||||||
|
<Compile Include="FormClient.Designer.cs" /> |
||||||
|
<Compile Include="Program.cs" /> |
||||||
|
<None Include="Client.exe.config"> |
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||||
|
</None> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="..\TestCommonTypes\TestCommonTypes.csproj"> |
||||||
|
<Project>{C2A2838E-E87F-47C3-9440-556875E1BB5E}</Project> |
||||||
|
<Name>TestCommonTypes</Name> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="..\PrivateEventHandlersSink\PrivateEventHandlersSink.csproj"> |
||||||
|
<Project>{6AF77F6A-775A-45DF-97B8-AAD76CD4023B}</Project> |
||||||
|
<Name>PrivateEventHandlersSink</Name> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="..\InvokeOnSTASink\InvokeOnSTASink.csproj"> |
||||||
|
<Project>{068578FE-412A-48DC-B90C-B7D2B8593DB4}</Project> |
||||||
|
<Name>InvokeOnSTASink</Name> |
||||||
|
</ProjectReference> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
||||||
|
</Project> |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
public class ChatServer: MarshalByRefObject |
||||||
|
{ |
||||||
|
public event TextMessageEventHandler NewMessage; |
||||||
|
|
||||||
|
public void SendMessage(string message) |
||||||
|
{ |
||||||
|
Console.WriteLine("Message received:" + message); |
||||||
|
if (NewMessage != null) { |
||||||
|
NewMessage(this, new TextMessageEventArgs(message)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Library</OutputType> |
||||||
|
<RootNamespace>TestCommonTypes</RootNamespace> |
||||||
|
<AssemblyName>TestCommonTypes</AssemblyName> |
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||||
|
<ProjectGuid>{C2A2838E-E87F-47C3-9440-556875E1BB5E}</ProjectGuid> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||||
|
<Optimize>false</Optimize> |
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||||
|
<OutputPath>bin\Release\</OutputPath> |
||||||
|
<Optimize>true</Optimize> |
||||||
|
<DefineConstants>TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Reference Include="System" /> |
||||||
|
<Reference Include="System.Xml" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="ChatServer.cs" /> |
||||||
|
<Compile Include="TextMessageEventArgs.cs" /> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
||||||
|
</Project> |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
public delegate void TextMessageEventHandler (object sender, TextMessageEventArgs args); |
||||||
|
|
||||||
|
[Serializable] |
||||||
|
public class TextMessageEventArgs : EventArgs |
||||||
|
{ |
||||||
|
string message; |
||||||
|
|
||||||
|
public TextMessageEventArgs(string message) |
||||||
|
{ |
||||||
|
this.message = message; |
||||||
|
} |
||||||
|
|
||||||
|
public string Message { |
||||||
|
get { |
||||||
|
return message; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Runtime.Remoting; |
||||||
|
using System.Threading; |
||||||
|
|
||||||
|
namespace CustomSinks |
||||||
|
{ |
||||||
|
static class Program |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread] |
||||||
|
static void Main() |
||||||
|
{ |
||||||
|
Thread.CurrentThread.Name = "Server (STA)"; |
||||||
|
|
||||||
|
RemotingConfiguration.Configure("Server.exe.config"); |
||||||
|
|
||||||
|
Console.WriteLine("Chat server started. Press ENTER to exit."); |
||||||
|
Console.ReadLine(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8" ?> |
||||||
|
<configuration> |
||||||
|
<system.runtime.remoting> |
||||||
|
<application> |
||||||
|
<service> |
||||||
|
<wellknown |
||||||
|
mode="Singleton" |
||||||
|
type="CustomSinks.ChatServer, TestCommonTypes" |
||||||
|
objectUri="ChatServer.rem" |
||||||
|
/> |
||||||
|
</service> |
||||||
|
<channels> |
||||||
|
<channel ref="http" port="8686"> |
||||||
|
<clientProviders> |
||||||
|
<provider type="CustomSinks.PrivateEventHandlersClientChannelSinkProvider, PrivateEventHandlersSink" |
||||||
|
customSinkType="CustomSinks.PrivateEventHandlersClientChannelSink, PrivateEventHandlersSink" /> |
||||||
|
<provider type="CustomSinks.InvokeOnSTAClientChannelSinkProvider, InvokeOnSTASink" |
||||||
|
customSinkType="CustomSinks.InvokeOnSTAClientChannelSink, InvokeOnSTASink" /> |
||||||
|
<formatter ref="soap" typeFilterLevel="Full"/> |
||||||
|
</clientProviders> |
||||||
|
<serverProviders> |
||||||
|
<formatter ref="soap" typeFilterLevel="Full"/> |
||||||
|
<provider type="CustomSinks.InvokeOnSTAServerChannelSinkProvider, InvokeOnSTASink" |
||||||
|
customSinkType="CustomSinks.InvokeOnSTAServerChannelSink, InvokeOnSTASink" /> |
||||||
|
</serverProviders> |
||||||
|
</channel> |
||||||
|
</channels> |
||||||
|
</application> |
||||||
|
</system.runtime.remoting> |
||||||
|
</configuration> |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Exe</OutputType> |
||||||
|
<RootNamespace>TestServer</RootNamespace> |
||||||
|
<AssemblyName>TestServer</AssemblyName> |
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||||
|
<ProjectGuid>{1EE49A1D-7098-4B75-B174-B36C803EA9EB}</ProjectGuid> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||||
|
<Optimize>false</Optimize> |
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||||
|
<OutputPath>bin\Release\</OutputPath> |
||||||
|
<Optimize>true</Optimize> |
||||||
|
<DefineConstants>TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Reference Include="System" /> |
||||||
|
<Reference Include="System.Xml" /> |
||||||
|
<Reference Include="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="Program.cs" /> |
||||||
|
<None Include="Server.exe.config"> |
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||||
|
</None> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="..\TestCommonTypes\TestCommonTypes.csproj"> |
||||||
|
<Project>{C2A2838E-E87F-47C3-9440-556875E1BB5E}</Project> |
||||||
|
<Name>TestCommonTypes</Name> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="..\PrivateEventHandlersSink\PrivateEventHandlersSink.csproj"> |
||||||
|
<Project>{6AF77F6A-775A-45DF-97B8-AAD76CD4023B}</Project> |
||||||
|
<Name>PrivateEventHandlersSink</Name> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="..\InvokeOnSTASink\InvokeOnSTASink.csproj"> |
||||||
|
<Project>{068578FE-412A-48DC-B90C-B7D2B8593DB4}</Project> |
||||||
|
<Name>InvokeOnSTASink</Name> |
||||||
|
</ProjectReference> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
||||||
|
</Project> |
||||||
Loading…
Reference in new issue