public static WindowServiceInfo Create(string serviceName, string servicePath, string serviceFriendlyName, bool validateFailThrows = false) { var info = new WindowServiceInfo() { ServiceName = serviceName, ServicePath = servicePath, ServiceFriendlyName = serviceFriendlyName }; if (validateFailThrows) { var success = Validate(info, out var message); if (!success) { throw new ArgumentException(message); } } return(info); }
public static bool Validate(WindowServiceInfo info, out string message) { if (info == null) { message = "info should not be null"; return(false); } if (string.IsNullOrWhiteSpace(info.ServiceName)) { message = "ServiceName should not be null or empty"; return(false); } if (string.IsNullOrWhiteSpace(info.ServicePath)) { message = "ServicePath should not be null or empty"; return(false); } message = "OK"; return(true); }
public ServiceController(WindowServiceInfo info) { ServiceInfo = info ?? throw new ArgumentNullException(nameof(info)); }
public static ServiceController Create(WindowServiceInfo info) { return(new ServiceController(info)); }