using System;
using System.ComponentModel;
using System.Globalization;
-#if NET_2_0
using System.Runtime.InteropServices;
-#endif
using System.ServiceProcess.Design;
using System.Threading;
{
[Designer("System.ServiceProcess.Design.ServiceControllerDesigner, " + Consts.AssemblySystem_Design)]
[MonoTODO ("No unix implementation")]
-#if NET_2_0
[ServiceProcessDescription ("Provides the ability to connect to, query, and manipulate running or stopped Windows services.")]
-#endif
public class ServiceController : Component
{
private string _name;
[ServiceProcessDescription ("Whether this service recognizes the Pause and Continue commands.")]
public bool CanPauseAndContinue {
get {
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
return _impl.CanPauseAndContinue;
}
}
public bool CanShutdown {
get
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
return _impl.CanShutdown;
}
}
public bool CanStop {
get
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
return _impl.CanStop;
}
}
public ServiceController [] DependentServices {
get
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
if (_dependentServices == null)
_dependentServices = _impl.DependentServices;
return _dependentServices;
if (_serviceName == value)
return;
-#if NET_2_0
ValidateServiceName (value);
-#endif
_serviceName = value;
public ServiceController [] ServicesDependedOn {
get
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
if (_servicesDependedOn == null)
_servicesDependedOn = _impl.ServicesDependedOn;
return _servicesDependedOn;
}
}
-#if NET_2_0
[MonoTODO]
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
throw new NotImplementedException ();
}
}
-#endif
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[ServiceProcessDescription ("The type of this service.")]
public ServiceType ServiceType {
get
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
return _impl.ServiceType;
}
}
public ServiceControllerStatus Status {
get
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
return _impl.Status;
}
}
public void Continue ()
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
_impl.Continue ();
}
public void ExecuteCommand (int command)
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
_impl.ExecuteCommand (command);
}
public void Pause ()
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
_impl.Pause ();
}
public void Start (string [] args)
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
_impl.Start (args);
}
public void Stop ()
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
_impl.Stop ();
}
public void WaitForStatus (ServiceControllerStatus desiredStatus, TimeSpan timeout)
{
-#if NET_2_0
ValidateServiceName (ServiceName);
-#endif
DateTime start = DateTime.Now;
while (Status != desiredStatus) {
}
}
-#if NET_2_0
private static void ValidateServiceName (string serviceName)
{
if (serviceName.Length == 0 || serviceName.Length > 80)
"Service name {0} contains invalid characters, is empty"
+ " or is too long (max length = 80).", serviceName));
}
-#endif
private static void ValidateMachineName (string machineName)
{