import typing, clr
from System import IDisposable
from Microsoft.Win32.SafeHandles import SafeMemoryMappedFileHandle, SafeMemoryMappedViewHandle
from System.IO import FileMode, FileStream, HandleInheritability, UnmanagedMemoryAccessor, UnmanagedMemoryStream

class MemoryMappedFile(IDisposable):
    @property
    def SafeMemoryMappedFileHandle(self) -> SafeMemoryMappedFileHandle: ...
    def Dispose(self) -> None: ...
    # Skipped CreateFromFile due to it being static, abstract and generic.

    CreateFromFile : CreateFromFile_MethodGroup
    class CreateFromFile_MethodGroup:
        @typing.overload
        def __call__(self, path: str) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, path: str, mode: FileMode) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, path: str, mode: FileMode, mapName: str) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, path: str, mode: FileMode, mapName: str, capacity: int) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, path: str, mode: FileMode, mapName: str, capacity: int, access: MemoryMappedFileAccess) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, fileStream: FileStream, mapName: str, capacity: int, access: MemoryMappedFileAccess, inheritability: HandleInheritability, leaveOpen: bool) -> MemoryMappedFile:...

    # Skipped CreateNew due to it being static, abstract and generic.

    CreateNew : CreateNew_MethodGroup
    class CreateNew_MethodGroup:
        @typing.overload
        def __call__(self, mapName: str, capacity: int) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, mapName: str, capacity: int, access: MemoryMappedFileAccess) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, mapName: str, capacity: int, access: MemoryMappedFileAccess, options: MemoryMappedFileOptions, inheritability: HandleInheritability) -> MemoryMappedFile:...

    # Skipped CreateOrOpen due to it being static, abstract and generic.

    CreateOrOpen : CreateOrOpen_MethodGroup
    class CreateOrOpen_MethodGroup:
        @typing.overload
        def __call__(self, mapName: str, capacity: int) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, mapName: str, capacity: int, access: MemoryMappedFileAccess) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, mapName: str, capacity: int, access: MemoryMappedFileAccess, options: MemoryMappedFileOptions, inheritability: HandleInheritability) -> MemoryMappedFile:...

    # Skipped CreateViewAccessor due to it being static, abstract and generic.

    CreateViewAccessor : CreateViewAccessor_MethodGroup
    class CreateViewAccessor_MethodGroup:
        @typing.overload
        def __call__(self) -> MemoryMappedViewAccessor:...
        @typing.overload
        def __call__(self, offset: int, size: int) -> MemoryMappedViewAccessor:...
        @typing.overload
        def __call__(self, offset: int, size: int, access: MemoryMappedFileAccess) -> MemoryMappedViewAccessor:...

    # Skipped CreateViewStream due to it being static, abstract and generic.

    CreateViewStream : CreateViewStream_MethodGroup
    class CreateViewStream_MethodGroup:
        @typing.overload
        def __call__(self) -> MemoryMappedViewStream:...
        @typing.overload
        def __call__(self, offset: int, size: int) -> MemoryMappedViewStream:...
        @typing.overload
        def __call__(self, offset: int, size: int, access: MemoryMappedFileAccess) -> MemoryMappedViewStream:...

    # Skipped OpenExisting due to it being static, abstract and generic.

    OpenExisting : OpenExisting_MethodGroup
    class OpenExisting_MethodGroup:
        @typing.overload
        def __call__(self, mapName: str) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, mapName: str, desiredAccessRights: MemoryMappedFileRights) -> MemoryMappedFile:...
        @typing.overload
        def __call__(self, mapName: str, desiredAccessRights: MemoryMappedFileRights, inheritability: HandleInheritability) -> MemoryMappedFile:...



class MemoryMappedFileAccess(typing.SupportsInt):
    @typing.overload
    def __init__(self, value : int) -> None: ...
    @typing.overload
    def __init__(self, value : int, force_if_true: bool) -> None: ...
    def __int__(self) -> int: ...
    
    # Values:
    ReadWrite : MemoryMappedFileAccess # 0
    Read : MemoryMappedFileAccess # 1
    Write : MemoryMappedFileAccess # 2
    CopyOnWrite : MemoryMappedFileAccess # 3
    ReadExecute : MemoryMappedFileAccess # 4
    ReadWriteExecute : MemoryMappedFileAccess # 5


class MemoryMappedFileOptions(typing.SupportsInt):
    @typing.overload
    def __init__(self, value : int) -> None: ...
    @typing.overload
    def __init__(self, value : int, force_if_true: bool) -> None: ...
    def __int__(self) -> int: ...
    
    # Values:
    None_ : MemoryMappedFileOptions # 0
    DelayAllocatePages : MemoryMappedFileOptions # 67108864


class MemoryMappedFileRights(typing.SupportsInt):
    @typing.overload
    def __init__(self, value : int) -> None: ...
    @typing.overload
    def __init__(self, value : int, force_if_true: bool) -> None: ...
    def __int__(self) -> int: ...
    
    # Values:
    CopyOnWrite : MemoryMappedFileRights # 1
    Write : MemoryMappedFileRights # 2
    Read : MemoryMappedFileRights # 4
    ReadWrite : MemoryMappedFileRights # 6
    Execute : MemoryMappedFileRights # 8
    ReadExecute : MemoryMappedFileRights # 12
    ReadWriteExecute : MemoryMappedFileRights # 14
    Delete : MemoryMappedFileRights # 65536
    ReadPermissions : MemoryMappedFileRights # 131072
    ChangePermissions : MemoryMappedFileRights # 262144
    TakeOwnership : MemoryMappedFileRights # 524288
    FullControl : MemoryMappedFileRights # 983055
    AccessSystemSecurity : MemoryMappedFileRights # 16777216


class MemoryMappedViewAccessor(UnmanagedMemoryAccessor):
    @property
    def CanRead(self) -> bool: ...
    @property
    def CanWrite(self) -> bool: ...
    @property
    def Capacity(self) -> int: ...
    @property
    def PointerOffset(self) -> int: ...
    @property
    def SafeMemoryMappedViewHandle(self) -> SafeMemoryMappedViewHandle: ...
    def Flush(self) -> None: ...


class MemoryMappedViewStream(UnmanagedMemoryStream):
    @property
    def CanRead(self) -> bool: ...
    @property
    def CanSeek(self) -> bool: ...
    @property
    def CanTimeout(self) -> bool: ...
    @property
    def CanWrite(self) -> bool: ...
    @property
    def Capacity(self) -> int: ...
    @property
    def Length(self) -> int: ...
    @property
    def PointerOffset(self) -> int: ...
    @property
    def Position(self) -> int: ...
    @Position.setter
    def Position(self, value: int) -> int: ...
    @property
    def PositionPointer(self) -> clr.Reference[int]: ...
    @PositionPointer.setter
    def PositionPointer(self, value: clr.Reference[int]) -> clr.Reference[int]: ...
    @property
    def ReadTimeout(self) -> int: ...
    @ReadTimeout.setter
    def ReadTimeout(self, value: int) -> int: ...
    @property
    def SafeMemoryMappedViewHandle(self) -> SafeMemoryMappedViewHandle: ...
    @property
    def WriteTimeout(self) -> int: ...
    @WriteTimeout.setter
    def WriteTimeout(self, value: int) -> int: ...
    def Flush(self) -> None: ...
    def SetLength(self, value: int) -> None: ...

