本文整理汇总了C#中PipeDirection类的典型用法代码示例。如果您正苦于以下问题:C# PipeDirection类的具体用法?C# PipeDirection怎么用?C# PipeDirection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PipeDirection类属于命名空间,在下文中一共展示了PipeDirection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: NamedPipeServerStream
private NamedPipeServerStream(String pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
: base(direction, transmissionMode, outBufferSize)
{
if (pipeName == null)
{
throw new ArgumentNullException("pipeName");
}
if (pipeName.Length == 0)
{
throw new ArgumentException(SR.Argument_NeedNonemptyPipeName);
}
if ((options & ~(PipeOptions.WriteThrough | PipeOptions.Asynchronous)) != 0)
{
throw new ArgumentOutOfRangeException("options", SR.ArgumentOutOfRange_OptionsInvalid);
}
if (inBufferSize < 0)
{
throw new ArgumentOutOfRangeException("inBufferSize", SR.ArgumentOutOfRange_NeedNonNegNum);
}
ValidateMaxNumberOfServerInstances(maxNumberOfServerInstances);
// inheritability will always be None since this private constructor is only called from other constructors from which
// inheritability is always set to None. Desktop has a public constructor to allow setting it to something else, but Core
// doesnt.
if (inheritability < HandleInheritability.None || inheritability > HandleInheritability.Inheritable)
{
throw new ArgumentOutOfRangeException("inheritability", SR.ArgumentOutOfRange_HandleInheritabilityNoneOrInheritable);
}
Create(pipeName, direction, maxNumberOfServerInstances, transmissionMode,
options, inBufferSize, outBufferSize, inheritability);
}
开发者ID:jmhardison,项目名称:corefx,代码行数:33,代码来源:NamedPipeServerStream.cs
示例2: Create
private void Create(string pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
{
Debug.Assert(pipeName != null && pipeName.Length != 0, "fullPipeName is null or empty");
Debug.Assert(direction >= PipeDirection.In && direction <= PipeDirection.InOut, "invalid pipe direction");
Debug.Assert(inBufferSize >= 0, "inBufferSize is negative");
Debug.Assert(outBufferSize >= 0, "outBufferSize is negative");
Debug.Assert((maxNumberOfServerInstances >= 1) || (maxNumberOfServerInstances == MaxAllowedServerInstances), "maxNumberOfServerInstances is invalid");
Debug.Assert(transmissionMode >= PipeTransmissionMode.Byte && transmissionMode <= PipeTransmissionMode.Message, "transmissionMode is out of range");
if (transmissionMode == PipeTransmissionMode.Message)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_MessageTransmissionMode);
}
// NOTE: We don't have a good way to enforce maxNumberOfServerInstances, and don't currently try.
// It's a Windows-specific concept.
_path = GetPipePath(".", pipeName);
_direction = direction;
_options = options;
_inBufferSize = inBufferSize;
_outBufferSize = outBufferSize;
_inheritability = inheritability;
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:26,代码来源:NamedPipeServerStream.Unix.cs
示例3: AnonymousPipeClientStream
public AnonymousPipeClientStream(PipeDirection direction, String pipeHandleAsString)
: base(direction, 0)
{
if (direction == PipeDirection.InOut)
{
throw new NotSupportedException(SR.NotSupported_AnonymousPipeUnidirectional);
}
if (pipeHandleAsString == null)
{
throw new ArgumentNullException("pipeHandleAsString");
}
// Initialize SafePipeHandle from String and check if it's valid. First see if it's parseable
long result = 0;
bool parseable = long.TryParse(pipeHandleAsString, out result);
if (!parseable)
{
throw new ArgumentException(SR.Argument_InvalidHandle, "pipeHandleAsString");
}
// next check whether the handle is invalid
SafePipeHandle safePipeHandle = new SafePipeHandle((IntPtr)result, true);
if (safePipeHandle.IsInvalid)
{
throw new ArgumentException(SR.Argument_InvalidHandle, "pipeHandleAsString");
}
Init(direction, safePipeHandle);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:29,代码来源:AnonymousPipeClientStream.cs
示例4: AnonymousPipeServerStream
public AnonymousPipeServerStream(PipeDirection direction, SafePipeHandle serverSafePipeHandle, SafePipeHandle clientSafePipeHandle)
: base(direction, 0)
{
if (direction == PipeDirection.InOut)
{
throw new NotSupportedException(SR.NotSupported_AnonymousPipeUnidirectional);
}
if (serverSafePipeHandle == null)
{
throw new ArgumentNullException("serverSafePipeHandle");
}
if (clientSafePipeHandle == null)
{
throw new ArgumentNullException("clientSafePipeHandle");
}
if (serverSafePipeHandle.IsInvalid)
{
throw new ArgumentException(SR.Argument_InvalidHandle, "serverSafePipeHandle");
}
if (clientSafePipeHandle.IsInvalid)
{
throw new ArgumentException(SR.Argument_InvalidHandle, "clientSafePipeHandle");
}
ValidateHandleIsPipe(serverSafePipeHandle);
ValidateHandleIsPipe(clientSafePipeHandle);
InitializeHandle(serverSafePipeHandle, true, false);
_clientHandle = clientSafePipeHandle;
_clientHandleExposed = true;
State = PipeState.Connected;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:32,代码来源:AnonymousPipeServerStream.cs
示例5: NullServerName_Throws_ArgumentNullException
public static void NullServerName_Throws_ArgumentNullException(PipeDirection direction)
{
Assert.Throws<ArgumentNullException>("serverName", () => new NamedPipeClientStream(null, "client1"));
Assert.Throws<ArgumentNullException>("serverName", () => new NamedPipeClientStream(null, "client1", direction));
Assert.Throws<ArgumentNullException>("serverName", () => new NamedPipeClientStream(null, "client1", direction, PipeOptions.None));
Assert.Throws<ArgumentNullException>("serverName", () => new NamedPipeClientStream(null, "client1", direction, PipeOptions.None, TokenImpersonationLevel.None));
}
开发者ID:GreenDamTan,项目名称:corefx,代码行数:7,代码来源:NamedPipeTest.CreateClient.cs
示例6: EmptyStringServerName_Throws_ArgumentException
public static void EmptyStringServerName_Throws_ArgumentException(PipeDirection direction)
{
Assert.Throws<ArgumentException>(() => new NamedPipeClientStream("", "client1"));
Assert.Throws<ArgumentException>(() => new NamedPipeClientStream("", "client1", direction));
Assert.Throws<ArgumentException>(() => new NamedPipeClientStream("", "client1", direction, PipeOptions.None));
Assert.Throws<ArgumentException>(() => new NamedPipeClientStream("", "client1", direction, PipeOptions.None, TokenImpersonationLevel.None));
}
开发者ID:GreenDamTan,项目名称:corefx,代码行数:7,代码来源:NamedPipeTest.CreateClient.cs
示例7: Init
private void Init(PipeDirection direction, PipeTransmissionMode transmissionMode, int outBufferSize)
{
Debug.Assert(direction >= PipeDirection.In && direction <= PipeDirection.InOut, "invalid pipe direction");
Debug.Assert(transmissionMode >= PipeTransmissionMode.Byte && transmissionMode <= PipeTransmissionMode.Message, "transmissionMode is out of range");
Debug.Assert(outBufferSize >= 0, "outBufferSize is negative");
// always defaults to this until overridden
_readMode = transmissionMode;
_transmissionMode = transmissionMode;
_pipeDirection = direction;
if ((_pipeDirection & PipeDirection.In) != 0)
{
_canRead = true;
}
if ((_pipeDirection & PipeDirection.Out) != 0)
{
_canWrite = true;
}
_outBufferSize = outBufferSize;
// This should always default to true
_isMessageComplete = true;
_state = PipeState.WaitingToConnect;
_streamAsyncHelper = new StreamAsyncHelper(this);
}
开发者ID:jsalvadorp,项目名称:corefx,代码行数:29,代码来源:PipeStream.cs
示例8: NamedPipeServerStream
private NamedPipeServerStream(String pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
: base(direction, transmissionMode, outBufferSize)
{
if (pipeName == null)
{
throw new ArgumentNullException("pipeName");
}
if (pipeName.Length == 0)
{
throw new ArgumentException(SR.Argument_NeedNonemptyPipeName);
}
if ((options & ~(PipeOptions.WriteThrough | PipeOptions.Asynchronous)) != 0)
{
throw new ArgumentOutOfRangeException("options", SR.ArgumentOutOfRange_OptionsInvalid);
}
if (inBufferSize < 0)
{
throw new ArgumentOutOfRangeException("inBufferSize", SR.ArgumentOutOfRange_NeedNonNegNum);
}
// win32 allows fixed values of 1-254 or 255 to mean max allowed by system. We expose 255 as -1 (unlimited)
// through the MaxAllowedServerInstances constant. This is consistent e.g. with -1 as infinite timeout, etc
if ((maxNumberOfServerInstances < 1 || maxNumberOfServerInstances > 254) && (maxNumberOfServerInstances != MaxAllowedServerInstances))
{
throw new ArgumentOutOfRangeException("maxNumberOfServerInstances", SR.ArgumentOutOfRange_MaxNumServerInstances);
}
if (inheritability < HandleInheritability.None || inheritability > HandleInheritability.Inheritable)
{
throw new ArgumentOutOfRangeException("inheritability", SR.ArgumentOutOfRange_HandleInheritabilityNoneOrInheritable);
}
Create(pipeName, direction, maxNumberOfServerInstances, transmissionMode,
options, inBufferSize, outBufferSize, inheritability);
}
开发者ID:niaomingjian,项目名称:corefx,代码行数:35,代码来源:NamedPipeServerStream.cs
示例9: Create
private void Create(PipeDirection direction, HandleInheritability inheritability, int bufferSize)
{
Debug.Assert(direction != PipeDirection.InOut, "Anonymous pipe direction shouldn't be InOut");
// Ignore bufferSize. It's optional, and the fcntl F_SETPIPE_SZ for changing it is Linux specific.
// Use pipe or pipe2 to create our anonymous pipe
int[] fds = new int[2];
unsafe
{
fixed (int* fdsptr = fds)
{
CreatePipe(inheritability, fdsptr);
}
}
// Create SafePipeHandles for each end of the pipe. Which ends goes with server and which goes with
// client depends on the direction of the pipe.
SafePipeHandle serverHandle = new SafePipeHandle(
(IntPtr)fds[direction == PipeDirection.In ? Interop.libc.ReadEndOfPipe : Interop.libc.WriteEndOfPipe],
ownsHandle: true);
SafePipeHandle clientHandle = new SafePipeHandle(
(IntPtr)fds[direction == PipeDirection.In ? Interop.libc.WriteEndOfPipe : Interop.libc.ReadEndOfPipe],
ownsHandle: true);
// We're connected. Finish initialization using the newly created handles.
InitializeHandle(serverHandle, isExposed: false, isAsync: false);
_clientHandle = clientHandle;
State = PipeState.Connected;
}
开发者ID:jsalvadorp,项目名称:corefx,代码行数:29,代码来源:AnonymousPipeServerStream.Unix.cs
示例10: StartClient
protected static void StartClient(PipeDirection direction, SafePipeHandle clientPipeHandle)
{
using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(direction, clientPipeHandle))
{
DoStreamOperations(client);
}
}
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:AnonymousPipeTestBase.cs
示例11: AnonymousPipeServerStream
public AnonymousPipeServerStream(PipeDirection direction, SafePipeHandle serverSafePipeHandle, SafePipeHandle clientSafePipeHandle) : base(direction, 0)
{
if (direction == PipeDirection.InOut)
{
throw new NotSupportedException(System.SR.GetString("NotSupported_AnonymousPipeUnidirectional"));
}
if (serverSafePipeHandle == null)
{
throw new ArgumentNullException("serverSafePipeHandle");
}
if (clientSafePipeHandle == null)
{
throw new ArgumentNullException("clientSafePipeHandle");
}
if (serverSafePipeHandle.IsInvalid)
{
throw new ArgumentException(System.SR.GetString("Argument_InvalidHandle"), "serverSafePipeHandle");
}
if (clientSafePipeHandle.IsInvalid)
{
throw new ArgumentException(System.SR.GetString("Argument_InvalidHandle"), "clientSafePipeHandle");
}
if (Microsoft.Win32.UnsafeNativeMethods.GetFileType(serverSafePipeHandle) != 3)
{
throw new IOException(System.SR.GetString("IO_IO_InvalidPipeHandle"));
}
if (Microsoft.Win32.UnsafeNativeMethods.GetFileType(clientSafePipeHandle) != 3)
{
throw new IOException(System.SR.GetString("IO_IO_InvalidPipeHandle"));
}
base.InitializeHandle(serverSafePipeHandle, true, false);
this.m_clientHandle = clientSafePipeHandle;
this.m_clientHandleExposed = true;
base.State = PipeState.Connected;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:35,代码来源:AnonymousPipeServerStream.cs
示例12: Create
private void Create(PipeDirection direction, HandleInheritability inheritability, int bufferSize)
{
Debug.Assert(direction != PipeDirection.InOut, "Anonymous pipe direction shouldn't be InOut");
Debug.Assert(bufferSize >= 0, "bufferSize is negative");
throw NotImplemented.ByDesign; // TODO: Implement this
}
开发者ID:gitter-badger,项目名称:corefx,代码行数:7,代码来源:AnonymousPipeServerStream.Unix.cs
示例13: Create
private void Create(string pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize,
HandleInheritability inheritability)
{
Debug.Assert(pipeName != null && pipeName.Length != 0, "fullPipeName is null or empty");
Debug.Assert(direction >= PipeDirection.In && direction <= PipeDirection.InOut, "invalid pipe direction");
Debug.Assert(inBufferSize >= 0, "inBufferSize is negative");
Debug.Assert(outBufferSize >= 0, "outBufferSize is negative");
Debug.Assert((maxNumberOfServerInstances >= 1) || (maxNumberOfServerInstances == MaxAllowedServerInstances), "maxNumberOfServerInstances is invalid");
Debug.Assert(transmissionMode >= PipeTransmissionMode.Byte && transmissionMode <= PipeTransmissionMode.Message, "transmissionMode is out of range");
if (transmissionMode == PipeTransmissionMode.Message)
{
throw new PlatformNotSupportedException();
}
// NOTE: We don't have a good way to enforce maxNumberOfServerInstances, and don't currently try.
// It's a Windows-specific concept.
// Make sure the FIFO exists, but don't open it until WaitForConnection is called.
_path = GetPipePath(".", pipeName);
while (true)
{
int result = Interop.libc.mkfifo(_path, (int)Interop.libc.Permissions.S_IRWXU);
if (result == 0)
{
// The FIFO was successfully created - note that although we create the FIFO here, we don't
// ever delete it. If we remove the FIFO we could invalidate other servers that also use it.
// See #2764 for further discussion.
break;
}
Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo();
if (errorInfo.Error == Interop.Error.EINTR)
{
// interrupted; try again
continue;
}
else if (errorInfo.Error == Interop.Error.EEXIST)
{
// FIFO already exists; nothing more to do
break;
}
else
{
// something else; fail
throw Interop.GetExceptionForIoErrno(errorInfo, _path);
}
}
// Store the rest of the creation arguments. They'll be used when we open the connection
// in WaitForConnection.
_direction = direction;
_options = options;
_inBufferSize = inBufferSize;
_outBufferSize = outBufferSize;
_inheritability = inheritability;
}
开发者ID:jmhardison,项目名称:corefx,代码行数:58,代码来源:NamedPipeServerStream.Unix.cs
示例14: Init
private void Init(PipeDirection direction, SafePipeHandle safePipeHandle)
{
if (Microsoft.Win32.UnsafeNativeMethods.GetFileType(safePipeHandle) != 3)
{
throw new IOException(System.SR.GetString("IO_IO_InvalidPipeHandle"));
}
base.InitializeHandle(safePipeHandle, true, false);
base.State = PipeState.Connected;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:AnonymousPipeClientStream.cs
示例15: ReservedPipeName_Throws_ArgumentOutOfRangeException
public static void ReservedPipeName_Throws_ArgumentOutOfRangeException(PipeDirection direction)
{
const string reservedName = "anonymous";
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeServerStream(reservedName));
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeServerStream(reservedName, direction));
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeServerStream(reservedName, direction, 1));
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeServerStream(reservedName, direction, 1, PipeTransmissionMode.Byte));
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeServerStream(reservedName, direction, 1, PipeTransmissionMode.Byte, PipeOptions.None));
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeServerStream(reservedName, direction, 1, PipeTransmissionMode.Byte, PipeOptions.None, 0, 0));}
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:NamedPipeTest.CreateServer.cs
示例16: ZeroLengthPipeName_Throws_ArgumentException
public static void ZeroLengthPipeName_Throws_ArgumentException(PipeDirection direction)
{
Assert.Throws<ArgumentException>(() => new NamedPipeServerStream(""));
Assert.Throws<ArgumentException>(() => new NamedPipeServerStream("", direction));
Assert.Throws<ArgumentException>(() => new NamedPipeServerStream("", direction, 2));
Assert.Throws<ArgumentException>(() => new NamedPipeServerStream("", direction, 3, PipeTransmissionMode.Byte));
Assert.Throws<ArgumentException>(() => new NamedPipeServerStream("", direction, 3, PipeTransmissionMode.Byte, PipeOptions.None));
Assert.Throws<ArgumentException>(() => new NamedPipeServerStream("", direction, 3, PipeTransmissionMode.Byte, PipeOptions.None, 0, 0));
}
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:NamedPipeTest.CreateServer.cs
示例17: NullPipeName_Throws_ArgumentNullException
public static void NullPipeName_Throws_ArgumentNullException(PipeDirection direction)
{
Assert.Throws<ArgumentNullException>("pipeName", () => new NamedPipeServerStream(null));
Assert.Throws<ArgumentNullException>("pipeName", () => new NamedPipeServerStream(null, direction));
Assert.Throws<ArgumentNullException>("pipeName", () => new NamedPipeServerStream(null, direction, 2));
Assert.Throws<ArgumentNullException>("pipeName", () => new NamedPipeServerStream(null, direction, 3, PipeTransmissionMode.Byte));
Assert.Throws<ArgumentNullException>("pipeName", () => new NamedPipeServerStream(null, direction, 3, PipeTransmissionMode.Byte, PipeOptions.None));
Assert.Throws<ArgumentNullException>("pipeName", () => new NamedPipeServerStream(null, direction, 3, PipeTransmissionMode.Byte, PipeOptions.None, 0, 0));
}
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:NamedPipeTest.CreateServer.cs
示例18: StartClient
public static void StartClient(PipeDirection direction, SafePipeHandle clientPipeHandle)
{
using (AnonymousPipeClientStream client = new AnonymousPipeClientStream(direction, clientPipeHandle))
{
DoStreamOperations(client);
}
// If you don't see this message that means that this task crashed.
Console.WriteLine("*** Client operations suceedeed. ***");
}
开发者ID:gitter-badger,项目名称:corefx,代码行数:9,代码来源:AnonymousPipesSimpleTest.cs
示例19: Init
private void Init(PipeDirection direction, SafePipeHandle safePipeHandle)
{
Debug.Assert(direction != PipeDirection.InOut, "anonymous pipes are unidirectional, caller should have verified before calling Init");
Debug.Assert(safePipeHandle != null && !safePipeHandle.IsInvalid, "safePipeHandle must be valid");
ValidateHandleIsPipe(safePipeHandle);
InitializeHandle(safePipeHandle, true, false);
State = PipeState.Connected;
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:AnonymousPipeClientStream.cs
示例20: ReservedPipeName_Throws_ArgumentOutOfRangeException
public static void ReservedPipeName_Throws_ArgumentOutOfRangeException(PipeDirection direction)
{
const string serverName = ".";
const string reservedName = "anonymous";
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeClientStream(reservedName));
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeClientStream(serverName, reservedName));
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeClientStream(serverName, reservedName, direction));
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeClientStream(serverName, reservedName, direction, PipeOptions.None));
Assert.Throws<ArgumentOutOfRangeException>("pipeName", () => new NamedPipeClientStream(serverName, reservedName, direction, PipeOptions.None, TokenImpersonationLevel.Impersonation));
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:NamedPipeTest.CreateClient.cs
注:本文中的PipeDirection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论