System.IO.Pipes.PipeStream.GetSecAttrs C# (CSharp) Method

GetSecAttrs() private method

private GetSecAttrs ( HandleInheritability inheritability ) : Interop.Kernel32.SECURITY_ATTRIBUTES
inheritability HandleInheritability
return Interop.Kernel32.SECURITY_ATTRIBUTES
        internal unsafe static Interop.Kernel32.SECURITY_ATTRIBUTES GetSecAttrs(HandleInheritability inheritability)
        {
            Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = default(Interop.Kernel32.SECURITY_ATTRIBUTES);
            if ((inheritability & HandleInheritability.Inheritable) != 0)
            {
                secAttrs = new Interop.Kernel32.SECURITY_ATTRIBUTES();
                secAttrs.nLength = (uint)sizeof(Interop.Kernel32.SECURITY_ATTRIBUTES);
                secAttrs.bInheritHandle = Interop.BOOL.TRUE;
            }
            return secAttrs;
        }

Usage Example

        public AnonymousPipeServerStream(PipeDirection direction, HandleInheritability inheritability, int bufferSize, PipeSecurity pipeSecurity) : base(direction, bufferSize)
        {
            object obj2;

            if (direction == PipeDirection.InOut)
            {
                throw new NotSupportedException(System.SR.GetString("NotSupported_AnonymousPipeUnidirectional"));
            }
            if ((inheritability < HandleInheritability.None) || (inheritability > HandleInheritability.Inheritable))
            {
                throw new ArgumentOutOfRangeException("inheritability", System.SR.GetString("ArgumentOutOfRange_HandleInheritabilityNoneOrInheritable"));
            }
            Microsoft.Win32.UnsafeNativeMethods.SECURITY_ATTRIBUTES secAttrs = PipeStream.GetSecAttrs(inheritability, pipeSecurity, out obj2);
            try
            {
                this.Create(direction, secAttrs, bufferSize);
            }
            finally
            {
                if (obj2 != null)
                {
                    ((GCHandle)obj2).Free();
                }
            }
        }
All Usage Examples Of System.IO.Pipes.PipeStream::GetSecAttrs