public static MessageStatus ByteRangeLock(
            long FileOffset,
            long Length,
            bool ExclusiveLock,
            bool failImmediately,
            bool isOpenNotEqual
            )
        {
            if (gStreamType == StreamType.DirectoryStream)
            {
                Helper.CaptureRequirement(904, @"[In Server Requests a Byte-Range Lock]Pseudocode for the operation is as follows:
                    If Open.Stream.StreamType is DirectoryStream, return STATUS_INVALID_PARAMETER, as byte range locks are not permitted on directories.");
                return MessageStatus.INVALID_PARAMETER;
            }

            if (gLockOffset >= 0 &&
                gLockLength > 0 &&
                FileOffset > gLockOffset &&
                (FileOffset + Length) > (gLockOffset + gLockLength) && // Lock range conflict
                gLockIsExclusive &&
                !isOpenNotEqual)
            {
                if (failImmediately)
                {
                    Requirement.Capture(@"[2.1.5.7 Server Requests a Byte-Range Lock, Pseudocode for the operation is as follows:]
                        The object store MUST check for byte range lock conflicts by using the algorithm described in section 2.1.4.10,
                        with ByteOffset set to FileOffset, Length set to Length, IsExclusive set to ExclusiveLock, LockIntent set to TRUE, and Open set to Open.
                        If a conflict is detected, then:
                            If a conflict is detected, then:If FailImmediately is TRUE, the operation MUST be failed with STATUS_LOCK_NOT_GRANTED.");
                    return MessageStatus.LOCK_NOT_GRANTED;
                }
                else
                {
                    //call 3.1.5.19
                    if (!sequenceIORequest.Contains(IORequest.ByteRangeLock))
                    {
                        sequenceIORequest.Add(IORequest.ByteRangeLock);
                        CancelinganOperation(IORequest.ByteRangeLock);
                    }
                }
            }

            //Initialize a new ByteRangeLock
            ByteRangeLock byteRangeLock = new ByteRangeLock();
            byteRangeLock.IsExclusive = ExclusiveLock;
            byteRangeLock.LockLength = Length;
            byteRangeLock.LockOffset = FileOffset;

            gLockIsExclusive = ExclusiveLock;
            gLockOffset = FileOffset;
            gLockLength = Length;

            ByteRangeLockList.Add(byteRangeLock);

            Helper.CaptureRequirement(903, @"[In Server Requests a Byte-Range Lock]On completion, the object store MUST return:Status:
                An NTSTATUS code that specifies the result.");
            Helper.CaptureRequirement(919, @"[In Server Requests a Byte-Range Lock,,Pseudocode for the operation is as follows:
                if the operation succeeds]Complete this operation with STATUS_SUCCESS.");
            return MessageStatus.SUCCESS;
        }
        public static MessageStatus ByteRangeUnlock()
        {
            long FileOffset = gLockOffset;
            long Length = gLockLength;

            if (gStreamType == StreamType.DirectoryStream)
            {
                return MessageStatus.INVALID_PARAMETER;
            }

            //true: if lockToRemove is empty
            ByteRangeLock LockToRemove = new ByteRangeLock();
            bool isFoundLockToRemove = false;
            if (ByteRangeLockList != null || ByteRangeLockList.Count > 0)
                foreach (ByteRangeLock item in ByteRangeLockList)
                {
                    if (item.LockOffset == FileOffset &&
                        item.LockLength == Length)
                    {
                        LockToRemove = item;
                        isFoundLockToRemove = true;
                    }
                }

            //Capture requirement
            if (isFoundLockToRemove)
            {
                ByteRangeLockList.Clear();
                Helper.CaptureRequirement(1248, @"[In Server Requests an Unlock of a Byte-Range]On completion, the object store MUST return:[Status].");
                Helper.CaptureRequirement(942, @"[In Server Requests an Unlock of a Byte-Range,Pseudocode for the operation is as follows:]
                    If LockToRemove is not NULL:Complete this operation with STATUS_SUCCESS.");
                return MessageStatus.SUCCESS;
            }
            else
            {
                Helper.CaptureRequirement(1248, @"[In Server Requests an Unlock of a Byte-Range]On completion, the object store MUST return:[Status].");
                Helper.CaptureRequirement(943, @"[In Server Requests an Unlock of a Byte-Range,Pseudocode for the operation is as follows:
                    else If LockToRemove is NULL:]Complete this operation with STATUS_RANGE_NOT_LOCKED.");
                return MessageStatus.RANGE_NOT_LOCKED;
            }
        }