NamedPipeServerStream.Windows.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Microsoft.Win32.SafeHandles;
  2. using System.Diagnostics;
  3. using System.Runtime.InteropServices;
  4. using System.Security.AccessControl;
  5. using System.Security.Permissions;
  6. using System.Security.Principal;
  7. namespace System.IO.Pipes
  8. {
  9. public sealed partial class NamedPipeServerStream
  10. {
  11. public NamedPipeServerStream (string pipeName, PipeDirection direction, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize, PipeSecurity pipeSecurity)
  12. : this (pipeName, direction, maxNumberOfServerInstances, transmissionMode, options, inBufferSize, outBufferSize, HandleInheritability.None)
  13. {
  14. }
  15. public NamedPipeServerStream (string pipeName, PipeDirection direction, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize, PipeSecurity pipeSecurity, HandleInheritability inheritability)
  16. : this (pipeName, direction, maxNumberOfServerInstances, transmissionMode, options, inBufferSize, outBufferSize, inheritability)
  17. {
  18. }
  19. public NamedPipeServerStream (string pipeName, PipeDirection direction, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize, PipeSecurity pipeSecurity, HandleInheritability inheritability, PipeAccessRights additionalAccessRights)
  20. : base (direction, transmissionMode, outBufferSize)
  21. {
  22. if (pipeName == null) {
  23. throw new ArgumentNullException (nameof(pipeName));
  24. }
  25. if (pipeName.Length == 0){
  26. throw new ArgumentException (SR.Argument_NeedNonemptyPipeName);
  27. }
  28. if ((options & ~(PipeOptions.WriteThrough | PipeOptions.Asynchronous)) != 0) {
  29. throw new ArgumentOutOfRangeException (nameof(options), SR.ArgumentOutOfRange_OptionsInvalid);
  30. }
  31. if (inBufferSize < 0) {
  32. throw new ArgumentOutOfRangeException (nameof(inBufferSize), SR.ArgumentOutOfRange_NeedNonNegNum);
  33. }
  34. if ((maxNumberOfServerInstances < 1 || maxNumberOfServerInstances > 254) && (maxNumberOfServerInstances != MaxAllowedServerInstances)) {
  35. throw new ArgumentOutOfRangeException (nameof(maxNumberOfServerInstances), SR.ArgumentOutOfRange_MaxNumServerInstances);
  36. }
  37. if (inheritability < HandleInheritability.None || inheritability > HandleInheritability.Inheritable) {
  38. throw new ArgumentOutOfRangeException (nameof(inheritability), SR.ArgumentOutOfRange_HandleInheritabilityNoneOrInheritable);
  39. }
  40. if ((additionalAccessRights & ~(PipeAccessRights.ChangePermissions | PipeAccessRights.TakeOwnership | PipeAccessRights.AccessSystemSecurity)) != 0) {
  41. throw new ArgumentOutOfRangeException (nameof(additionalAccessRights), SR.ArgumentOutOfRange_AdditionalAccessLimited);
  42. }
  43. Create (pipeName, direction, maxNumberOfServerInstances, transmissionMode, options, inBufferSize, outBufferSize, pipeSecurity, inheritability, additionalAccessRights);
  44. }
  45. }
  46. }