Exemple #1
0
 internal Win32ServiceHost(string serviceName, IWin32ServiceStateMachine stateMachine, INativeInterop nativeInterop)
 {
     _serviceName   = serviceName ?? throw new ArgumentNullException(nameof(serviceName));
     _stateMachine  = stateMachine ?? throw new ArgumentNullException(nameof(stateMachine));
     _nativeInterop = nativeInterop ?? throw new ArgumentNullException(nameof(nativeInterop));
     _serviceMainFunctionDelegate   = ServiceMainFunction;
     _serviceControlHandlerDelegate = HandleServiceControlCommand;
 }
        internal Win32ServiceHost([NotNull] string serviceName, [NotNull] IWin32ServiceStateMachine stateMachine, [NotNull] INativeInterop nativeInterop)
        {
            this.serviceName   = serviceName ?? throw new System.ArgumentNullException(nameof(serviceName));
            this.stateMachine  = stateMachine ?? throw new System.ArgumentNullException(nameof(stateMachine));
            this.nativeInterop = nativeInterop ?? throw new System.ArgumentNullException(nameof(nativeInterop));

            serviceMainFunctionDelegate   = ServiceMainFunction;
            serviceControlHandlerDelegate = HandleServiceControlCommand;
        }
        internal Win32ServiceHost([NotNull] IWin32Service service, [NotNull] INativeInterop nativeInterop)
        {
            serviceName        = service.ServiceName;
            this.stateMachine  = (service == null) ? throw new ArgumentNullException(nameof(service)) : new SimpleServiceStateMachine(service);
            this.nativeInterop = nativeInterop ?? throw new ArgumentNullException(nameof(nativeInterop));

            serviceMainFunctionDelegate   = ServiceMainFunction;
            serviceControlHandlerDelegate = HandleServiceControlCommand;
        }
Exemple #4
0
        internal static ServiceControlManager Connect(INativeInterop nativeInterop, string machineName, string databaseName, ServiceControlManagerAccessRights desiredAccessRights)
        {
            var mgr = nativeInterop.OpenSCManagerW(machineName, databaseName, desiredAccessRights);

            mgr.NativeInterop = nativeInterop;

            if (mgr.IsInvalid)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            return(mgr);
        }
        internal Win32ServiceHost([NotNull] IPausableWin32Service service, [NotNull] INativeInterop nativeInterop)
        {
            if (service == null)
            {
                throw new System.ArgumentNullException(nameof(service));
            }

            this.nativeInterop = nativeInterop ?? throw new System.ArgumentNullException(nameof(nativeInterop));
            serviceName        = service.ServiceName;
            stateMachine       = new PausableServiceStateMachine(service);

            serviceMainFunctionDelegate   = ServiceMainFunction;
            serviceControlHandlerDelegate = HandleServiceControlCommand;
        }
        internal Win32ServiceHost(IWin32Service service, INativeInterop nativeInterop)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }
            if (nativeInterop == null)
            {
                throw new ArgumentNullException(nameof(nativeInterop));
            }

            serviceName        = service.ServiceName;
            stateMachine       = new SimpleServiceStateMachine(service);
            this.nativeInterop = nativeInterop;

            serviceMainFunctionDelegate   = ServiceMainFunction;
            serviceControlHandlerDelegate = HandleServiceControlCommand;
        }
Exemple #7
0
        private static void Initialize()
        {
            if (_impl != null)
            {
                return;
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                _impl = new WinInterop();
                return;
            }
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                _impl = new OsxInterop();
                return;
            }

            //Not currently implemented
            throw new PlatformNotSupportedException();
        }
        internal Win32ServiceHost(string serviceName, IWin32ServiceStateMachine stateMachine, INativeInterop nativeInterop)
        {
            if (serviceName == null)
            {
                throw new ArgumentNullException(nameof(serviceName));
            }
            if (stateMachine == null)
            {
                throw new ArgumentNullException(nameof(stateMachine));
            }
            if (nativeInterop == null)
            {
                throw new ArgumentNullException(nameof(nativeInterop));
            }

            this.serviceName   = serviceName;
            this.stateMachine  = stateMachine;
            this.nativeInterop = nativeInterop;

            serviceMainFunctionDelegate   = ServiceMainFunction;
            serviceControlHandlerDelegate = HandleServiceControlCommand;
        }
Exemple #9
0
 internal Win32ServiceManager(string machineName, string databaseName, INativeInterop nativeInterop)
 {
     this.machineName   = machineName;
     this.databaseName  = databaseName;
     this.nativeInterop = nativeInterop;
 }
Exemple #10
0
 internal Win32ServiceManager(string machineName, string databaseName, INativeInterop nativeInterop)
 {
     _machineName   = machineName;
     _databaseName  = databaseName;
     _nativeInterop = nativeInterop;
 }