/// <summary> /// Creates a new instance of <see cref="IDriver"/> with the specified arguments, /// and loads it according to the specified <see cref="DriverLoad"/> method. /// </summary> /// <param name="ServiceName">The service name.</param> /// <param name="DosName">The dos name.</param> /// <param name="File">The system file.</param> /// <param name="DriverLoad">The driver load method.</param> public static Driver New(string ServiceName, string DosName, FileInfo File, DriverLoad DriverLoad = DriverLoad.Normal) { if (!Driver.Exists(ServiceName, DosName)) { if (File.Exists == false) { throw new FileNotFoundException("The Driver or system file does not exist."); } } var DriverObject = new Driver(ServiceName, DosName, File, DriverLoad); try { DriverObject.Load(); } catch (Exception) { // .. } return(DriverObject); }
/// <summary> /// Setups the specified driver. /// </summary> /// <param name="ServiceName">Name of the service.</param> /// <param name="SymbolicLink">The symbolic link.</param> /// <param name="DriverFile">The driver file.</param> /// <param name="LoadType">Type of the load.</param> /// <exception cref="InvalidEnumArgumentException">Invalid DriverLoad method specified.</exception> internal void Setup(string ServiceName, string SymbolicLink, FileInfo DriverFile, DriverLoad LoadType = DriverLoad.Normal) { this.ServiceName = ServiceName; this.SymbolicLink = SymbolicLink; this.DriverFile = DriverFile; this.LoadMethod = LoadType; switch (LoadType) { case DriverLoad.Normal: { this.Loader = new ServiceLoad(); break; } case DriverLoad.Dse: { this.Loader = new DseLoad(); break; } case DriverLoad.Tdl: { this.Loader = new TurlaLoad(); break; } default: { throw new InvalidEnumArgumentException("Invalid DriverLoad method specified."); } } }
/// <summary> /// Initializes a new instance of the <see cref="Driver"/> class. /// </summary> /// <param name="ServiceName">Name of the service.</param> /// <param name="SymbolicLink">The sym link.</param> /// <param name="DriverFile">The system file.</param> /// <param name="LoadType">The driver load type.</param> public Driver(string ServiceName, string SymbolicLink, FileInfo DriverFile, DriverLoad LoadType = DriverLoad.Normal) : this() { this.Setup(ServiceName, SymbolicLink, DriverFile, LoadType); }