Advertisement
Guest User

WindowsImage.cs

a guest
Dec 21st, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using JCotton.DismSharp.Interop;
  7.  
  8. namespace JCotton.DismSharp {
  9.     public class WindowsImage : IDisposable {
  10.         private ImageType _imageType;
  11.         private uint _imageIndex;
  12.         private string _imageName;
  13.         private string _imageDescription;
  14.         private ulong _imageSize;
  15.         private WindowsImageArchitecture _architecture;
  16.         private string _productName;
  17.         private string _editionId;
  18.         private string _installationType;
  19.         private string _hal;
  20.         private string _productType;
  21.         private string _productSuite;
  22.         private Version _version;
  23.         private uint _spBuild;
  24.         private uint _spLevel;
  25.         private ImageBootable _bootable;
  26.         private string _systemRoot;
  27.         private Collection<string> _languages;
  28.         private uint _defaultLanguageIndex;
  29.         private WimCustomizedInfo _customizedInfo;
  30.  
  31.         public ImageType ImageType => this._imageType;
  32.         public uint ImageIndex => this._imageIndex;
  33.         public string ImageName => this._imageName;
  34.         public string ImageDescription => this._imageDescription;
  35.         public ulong ImageSize => this._imageSize;
  36.         public WindowsImageArchitecture Architecture => this._architecture;
  37.         public string ProductName => this._productName;
  38.         public string EditionId => this._editionId;
  39.         public string InstallationType => this._installationType;
  40.         public string Hal => this._hal;
  41.         public string ProductType => this._productType;
  42.         public string ProductSuite => this._productSuite;
  43.         public Version Version => this._version;
  44.         public uint SpBuild => this._spBuild;
  45.         public uint SpLevel => this._spLevel;
  46.         public ImageBootable Bootable => this._bootable;
  47.         public string SystemRoot => this._systemRoot;
  48.         public IReadOnlyList<string> Languages => this._languages;
  49.         public string DefaultLanguage => this._languages[(int)this._defaultLanguageIndex];
  50.         public WimCustomizedInfo CustomizedInfo => this._customizedInfo;
  51.  
  52.         public WindowsImage(DismImageInfo info) {
  53.             this._imageType = info.ImageType;
  54.             this._imageIndex = info.ImageIndex;
  55.             this._imageName = info.ImageName;
  56.             this._imageDescription = info.ImageDescription;
  57.             this._imageSize = info.ImageSize;
  58.             this._architecture = info.Architecture;
  59.             this._productName = info.ProductName;
  60.             this._productSuite = info.ProductSuite;
  61.             this._version = new Version(
  62.                 (int)info.MajorVersion,
  63.                 (int)info.MinorVersion,
  64.                 (int)info.Build
  65.                 );
  66.             this._spBuild = info.SpBuild;
  67.             this._spLevel = info.SpLevel;
  68.             this._bootable = info.Bootable;
  69.             this._systemRoot = info.SystemRoot;
  70.             this._languages = new Collection<string>(
  71.                 Utilites.PtrToArray<DismString>(
  72.                     info.Language,
  73.                     info.LanguageCount
  74.                     )
  75.                     .Select(l => l.Value)
  76.                     .ToList()
  77.                 );
  78.             this._defaultLanguageIndex = info.DefaultLanguageIndex;
  79.             this._customizedInfo = info.CustomizedInfo == IntPtr.Zero
  80.                 ? null
  81.                 : new WimCustomizedInfo(
  82.                     Marshal.PtrToStructure<DismWimCustomizedInfo>(info.CustomizedInfo)
  83.                     );
  84.         }
  85.  
  86.         ~WindowsImage() {
  87.             this.Dispose(false);
  88.         }
  89.  
  90.         public void Dispose() {
  91.             this.Dispose(true);
  92.             GC.SuppressFinalize(this);
  93.         }
  94.  
  95.         private void Dispose(bool disposing) {
  96.             throw new NotImplementedException();
  97.         }
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement