Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public ServiceController(WindowServiceInfo info)
 {
     ServiceInfo = info ?? throw new ArgumentNullException(nameof(info));
 }
Exemplo n.º 4
0
 public static ServiceController Create(WindowServiceInfo info)
 {
     return(new ServiceController(info));
 }