Abstract NamedPipes code for windows

This commit is contained in:
Jim Norman
2006-01-17 23:06:37 +00:00
parent 36b193d3eb
commit 12209176e7
24 changed files with 4354 additions and 0 deletions

View File

@@ -0,0 +1,120 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{E98F1F7E-40B6-44C8-AC66-EC867B141FA1}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "AppModule.InterProcessComm"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "AppModule.InterProcessComm"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = "AppModule.InterProcessComm.xml"
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "IChannelManager.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "IClientChannel.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "IInterProcessConnection.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "InterProcessConnectionState.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "InterProcessIOException.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

View File

@@ -0,0 +1,48 @@
<VisualStudioProject>
<CSHARP LastOpenVersion = "7.10.3077" >
<Build>
<Settings ReferencePath = "" >
<Config
Name = "Debug"
EnableASPDebugging = "false"
EnableASPXDebugging = "false"
EnableUnmanagedDebugging = "false"
EnableSQLServerDebugging = "false"
RemoteDebugEnabled = "false"
RemoteDebugMachine = ""
StartAction = "Project"
StartArguments = ""
StartPage = ""
StartProgram = ""
StartURL = ""
StartWorkingDirectory = ""
StartWithIE = "true"
/>
<Config
Name = "Release"
EnableASPDebugging = "false"
EnableASPXDebugging = "false"
EnableUnmanagedDebugging = "false"
EnableSQLServerDebugging = "false"
RemoteDebugEnabled = "false"
RemoteDebugMachine = ""
StartAction = "Project"
StartArguments = ""
StartPage = ""
StartProgram = ""
StartURL = ""
StartWorkingDirectory = ""
StartWithIE = "true"
/>
</Settings>
</Build>
<OtherProjectSettings
CopyProjectDestinationFolder = ""
CopyProjectUncPath = ""
CopyProjectOption = "0"
ProjectView = "ProjectFiles"
ProjectTrust = "0"
/>
</CSHARP>
</VisualStudioProject>

View File

@@ -0,0 +1,263 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>AppModule.InterProcessComm</name>
</assembly>
<members>
<member name="T:AppModule.InterProcessComm.IChannelManager">
<summary>
Interface, which defines methods for a Channel Manager class.
</summary>
<remarks>
A Channel Manager is responsible for creating and maintaining channels for inter-process communication. The opened channels are meant to be reusable for performance optimization. Each channel needs to procees requests by calling the <see cref="M:AppModule.InterProcessComm.IChannelManager.HandleRequest(System.String)">HandleRequest</see> method of the Channel Manager.
</remarks>
</member>
<member name="M:AppModule.InterProcessComm.IChannelManager.Initialize">
<summary>
Initializes the Channel Manager.
</summary>
</member>
<member name="M:AppModule.InterProcessComm.IChannelManager.Stop">
<summary>
Closes all opened channels and stops the Channel Manager.
</summary>
</member>
<member name="M:AppModule.InterProcessComm.IChannelManager.HandleRequest(System.String)">
<summary>
Handles a request.
</summary>
<remarks>
This method currently caters for text based requests. XML strings can be used in case complex request structures are needed.
</remarks>
<param name="request">The incoming request.</param>
<returns>The resulting response.</returns>
</member>
<member name="M:AppModule.InterProcessComm.IChannelManager.WakeUp">
<summary>
Forces the Channel Manager to exit a sleeping mode and create a new channel.
</summary>
<remarks>
Normally the Channel Manager will create a number of reusable channels, which will handle the incoming reqiests, and go into a sleeping mode. However if the request load is high, the Channel Manager needs to be asked to create additional channels.
</remarks>
</member>
<member name="M:AppModule.InterProcessComm.IChannelManager.RemoveServerChannel(System.Object)">
<summary>
Removes an existing channel.
</summary>
<param name="param">A parameter identifying the channel.</param>
</member>
<member name="P:AppModule.InterProcessComm.IChannelManager.Listen">
<summary>
Indicates whether the Channel Manager is in listening mode.
</summary>
<remarks>
This property is left public so that other classes, like a server channel can start or stop listening based on the Channel Manager mode.
</remarks>
</member>
<member name="T:AppModule.InterProcessComm.IClientChannel">
<summary>
</summary>
</member>
<member name="M:AppModule.InterProcessComm.IClientChannel.HandleRequest(System.String)">
<summary>
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:AppModule.InterProcessComm.IClientChannel.HandleRequest(System.IO.Stream)">
<summary>
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:AppModule.InterProcessComm.IClientChannel.HandleRequest(System.Object)">
<summary>
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:AppModule.InterProcessComm.IClientChannel.Create">
<summary>
</summary>
<returns></returns>
</member>
<member name="T:AppModule.InterProcessComm.IInterProcessConnection">
<summary>
</summary>
</member>
<member name="M:AppModule.InterProcessComm.IInterProcessConnection.Connect">
<summary>
</summary>
</member>
<member name="M:AppModule.InterProcessComm.IInterProcessConnection.Close">
<summary>
</summary>
</member>
<member name="M:AppModule.InterProcessComm.IInterProcessConnection.Read">
<summary>
</summary>
<returns></returns>
</member>
<member name="M:AppModule.InterProcessComm.IInterProcessConnection.ReadBytes">
<summary>
</summary>
<returns></returns>
</member>
<member name="M:AppModule.InterProcessComm.IInterProcessConnection.Write(System.String)">
<summary>
</summary>
<param name="text"></param>
</member>
<member name="M:AppModule.InterProcessComm.IInterProcessConnection.WriteBytes(System.Byte[])">
<summary>
</summary>
<param name="bytes"></param>
</member>
<member name="M:AppModule.InterProcessComm.IInterProcessConnection.GetState">
<summary>
</summary>
<returns></returns>
</member>
<member name="P:AppModule.InterProcessComm.IInterProcessConnection.NativeHandle">
<summary>
</summary>
</member>
<member name="T:AppModule.InterProcessComm.InterProcessConnectionState">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.NotSet">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.Error">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.Creating">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.Created">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.WaitingForClient">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.ConnectedToClient">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.ConnectingToServer">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.ConnectedToServer">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.Reading">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.ReadData">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.Writing">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.WroteData">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.Flushing">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.FlushedData">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.Disconnecting">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.Disconnected">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.Closing">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessConnectionState.Closed">
<summary>
</summary>
</member>
<member name="T:AppModule.InterProcessComm.InterProcessIOException">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessIOException.IsServerAvailable">
<summary>
</summary>
</member>
<member name="F:AppModule.InterProcessComm.InterProcessIOException.ErrorCode">
<summary>
</summary>
</member>
<member name="M:AppModule.InterProcessComm.InterProcessIOException.#ctor(System.String)">
<summary>
</summary>
<param name="text"></param>
</member>
<member name="M:AppModule.InterProcessComm.InterProcessIOException.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)">
<summary>
</summary>
<param name="info"></param>
<param name="context"></param>
</member>
</members>
</doc>

View File

@@ -0,0 +1,55 @@
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("AppModule.InterProcessComm")]
[assembly: AssemblyDescription("Inter Process Communication")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ivan Latunov")]
[assembly: AssemblyProduct("Inter Process Communication")]
[assembly: AssemblyCopyright("Ivan Latunov")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.6.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//

View File

@@ -0,0 +1,63 @@
using System;
namespace AppModule.InterProcessComm {
#region Comments
/// <summary>
/// Interface, which defines methods for a Channel Manager class.
/// </summary>
/// <remarks>
/// A Channel Manager is responsible for creating and maintaining channels for inter-process communication. The opened channels are meant to be reusable for performance optimization. Each channel needs to procees requests by calling the <see cref="AppModule.InterProcessComm.IChannelManager.HandleRequest">HandleRequest</see> method of the Channel Manager.
/// </remarks>
#endregion
public interface IChannelManager {
#region Comments
/// <summary>
/// Initializes the Channel Manager.
/// </summary>
#endregion
void Initialize();
void Start();
#region Comments
/// <summary>
/// Closes all opened channels and stops the Channel Manager.
/// </summary>
#endregion
void Stop();
#region Comments
/// <summary>
/// Handles a request.
/// </summary>
/// <remarks>
/// This method currently caters for text based requests. XML strings can be used in case complex request structures are needed.
/// </remarks>
/// <param name="request">The incoming request.</param>
/// <returns>The resulting response.</returns>
#endregion
string HandleRequest(string request);
#region Comments
/// <summary>
/// Indicates whether the Channel Manager is in listening mode.
/// </summary>
/// <remarks>
/// This property is left public so that other classes, like a server channel can start or stop listening based on the Channel Manager mode.
/// </remarks>
#endregion
bool Listen {get; set;}
#region Comments
/// <summary>
/// Forces the Channel Manager to exit a sleeping mode and create a new channel.
/// </summary>
/// <remarks>
/// Normally the Channel Manager will create a number of reusable channels, which will handle the incoming reqiests, and go into a sleeping mode. However if the request load is high, the Channel Manager needs to be asked to create additional channels.
/// </remarks>
#endregion
void WakeUp();
#region Comments
/// <summary>
/// Removes an existing channel.
/// </summary>
/// <param name="param">A parameter identifying the channel.</param>
#endregion
void RemoveServerChannel(object param);
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.IO;
namespace AppModule.InterProcessComm {
#region Comments
/// <summary>
///
/// </summary>
#endregion
public interface IClientChannel : IDisposable {
#region Comments
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
#endregion
string HandleRequest(string request);
#region Comments
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
#endregion
string HandleRequest(Stream request);
#region Comments
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
#endregion
object HandleRequest(object request);
#region Comments
/// <summary>
///
/// </summary>
/// <returns></returns>
#endregion
IClientChannel Create();
}
}

View File

@@ -0,0 +1,64 @@
using System;
namespace AppModule.InterProcessComm {
#region Comments
/// <summary>
///
/// </summary>
#endregion
public interface IInterProcessConnection : IDisposable {
#region Comments
/// <summary>
///
/// </summary>
#endregion
int NativeHandle{get;}
#region Comments
/// <summary>
///
/// </summary>
#endregion
void Connect();
#region Comments
/// <summary>
///
/// </summary>
#endregion
void Close();
#region Comments
/// <summary>
///
/// </summary>
/// <returns></returns>
#endregion
string Read();
#region Comments
/// <summary>
///
/// </summary>
/// <returns></returns>
#endregion
byte[] ReadBytes();
#region Comments
/// <summary>
///
/// </summary>
/// <param name="text"></param>
#endregion
void Write(string text);
#region Comments
/// <summary>
///
/// </summary>
/// <param name="bytes"></param>
#endregion
void WriteBytes(byte[] bytes);
#region Comments
/// <summary>
///
/// </summary>
/// <returns></returns>
#endregion
InterProcessConnectionState GetState();
}
}

View File

@@ -0,0 +1,119 @@
using System;
namespace AppModule.InterProcessComm {
#region Comments
/// <summary>
///
/// </summary>
#endregion
public enum InterProcessConnectionState {
#region Comments
/// <summary>
///
/// </summary>
#endregion
NotSet = 0,
#region Comments
/// <summary>
///
/// </summary>
#endregion
Error = 1,
#region Comments
/// <summary>
///
/// </summary>
#endregion
Creating = 2,
#region Comments
/// <summary>
///
/// </summary>
#endregion
Created = 3,
#region Comments
/// <summary>
///
/// </summary>
#endregion
WaitingForClient = 4,
#region Comments
/// <summary>
///
/// </summary>
#endregion
ConnectedToClient = 5,
#region Comments
/// <summary>
///
/// </summary>
#endregion
ConnectingToServer = 6,
#region Comments
/// <summary>
///
/// </summary>
#endregion
ConnectedToServer = 7,
#region Comments
/// <summary>
///
/// </summary>
#endregion
Reading = 8,
#region Comments
/// <summary>
///
/// </summary>
#endregion
ReadData = 9,
#region Comments
/// <summary>
///
/// </summary>
#endregion
Writing = 10,
#region Comments
/// <summary>
///
/// </summary>
#endregion
WroteData = 11,
#region Comments
/// <summary>
///
/// </summary>
#endregion
Flushing = 12,
#region Comments
/// <summary>
///
/// </summary>
#endregion
FlushedData = 13,
#region Comments
/// <summary>
///
/// </summary>
#endregion
Disconnecting = 14,
#region Comments
/// <summary>
///
/// </summary>
#endregion
Disconnected = 15,
#region Comments
/// <summary>
///
/// </summary>
#endregion
Closing = 16,
#region Comments
/// <summary>
///
/// </summary>
#endregion
Closed = 17,
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Runtime.Serialization;
namespace AppModule.InterProcessComm {
#region Comments
/// <summary>
///
/// </summary>
#endregion
public class InterProcessIOException : Exception {
#region Comments
/// <summary>
///
/// </summary>
#endregion
public bool IsServerAvailable = true;
#region Comments
/// <summary>
///
/// </summary>
#endregion
public uint ErrorCode = 0;
#region Comments
/// <summary>
///
/// </summary>
/// <param name="text"></param>
#endregion
public InterProcessIOException(String text) : base(text) {
}
#region Comments
/// <summary>
///
/// </summary>
/// <param name="info"></param>
/// <param name="context"></param>
#endregion
protected InterProcessIOException(SerializationInfo info, StreamingContext context) : base(info, context) {
}
}
}