示例#1
0
 public async Task MountAsync(
     [NotNull] string path,
     ImageMountOptions options
     ) => await this.MountAsync(
     path,
     options,
     CancellationToken.None,
     null);
示例#2
0
 public static extern void DismMountImage(
     [NotNull] string imageFilePath,
     [NotNull] string mountPath,
     uint imageIndex,
     [CanBeNull] string imageName,
     DismImageIdentifier imageIdentifier,
     ImageMountOptions flags,
     [CanBeNull] SafeWaitHandle cancelEvent,
     [CanBeNull] DismProgressCallback progress,
     IntPtr userData
     );
示例#3
0
 public async Task MountAsync(
     [NotNull] string path,
     ImageMountOptions options,
     CancellationToken cancellationToken,
     [CanBeNull] IProgress <DismEventArgs> progress
     )
 {
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     if (File.Exists(path))
     {
         throw new ArgumentException("Path is a file", "path");
     }
     if (Directory.Exists(path) && Directory.GetFileSystemEntries(path).Length != 0)
     {
         throw new ArgumentException("Path refers to a non-empty directory", "path");
     }
     if (!Directory.Exists(path))
     {
         Directory.CreateDirectory(path);
     }
     await Task.Run(() =>
                    NativeMethods.DismMountImage(
                        this._imagePath,
                        path,
                        this._imageIndex,
                        null,
                        DismImageIdentifier.DismImageIndex,
                        options,
                        cancellationToken.WaitHandle.SafeWaitHandle,
                        (current, total, userData) => progress?.Report(new DismEventArgs(current, total)),
                        IntPtr.Zero
                        ));
 }
示例#4
0
 public void Mount(
     [NotNull] string path,
     ImageMountOptions options,
     [CanBeNull] IProgress <DismEventArgs> progress
     ) => Task.Run <Task>(async() => await this.MountAsync(path, options)).Wait();
示例#5
0
 public void Mount(
     [NotNull] string path,
     ImageMountOptions options
     ) => this.Mount(path, options, null);