System.IO.UnmanagedMemoryStream.Initialize C# (CSharp) Method

Initialize() private method

private Initialize ( byte pointer, long length, long capacity, FileAccess access, bool skipSecurityCheck ) : void
pointer byte
length long
capacity long
access FileAccess
skipSecurityCheck bool
return void
        internal unsafe void Initialize(byte* pointer, long length, long capacity, FileAccess access, bool skipSecurityCheck)
        {
            if (pointer == null)
                throw new ArgumentNullException(nameof(pointer));
            if (length < 0 || capacity < 0)
                throw new ArgumentOutOfRangeException((length < 0) ? nameof(length): nameof(capacity), SR.ArgumentOutOfRange_NeedNonNegNum);
            if (length > capacity)
                throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_LengthGreaterThanCapacity);
            Contract.EndContractBlock();
            // Check for wraparound.
            if (((byte*)((long)pointer + capacity)) < pointer)
                throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_UnmanagedMemStreamWrapAround);
            if (access < FileAccess.Read || access > FileAccess.ReadWrite)
                throw new ArgumentOutOfRangeException(nameof(access), SR.ArgumentOutOfRange_Enum);
            if (_isOpen)
                throw new InvalidOperationException(SR.InvalidOperation_CalledTwice);

            _mem = pointer;
            _length = length;
            _capacity = capacity;
            _access = access;
            _isOpen = true;
        }

Same methods

UnmanagedMemoryStream::Initialize ( byte pointer, long length, long capacity, FileAccess access ) : void