本文整理汇总了C#中ServiceController类的典型用法代码示例。如果您正苦于以下问题:C# ServiceController类的具体用法?C# ServiceController怎么用?C# ServiceController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceController类属于命名空间,在下文中一共展示了ServiceController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMergeMessageWithParametersCallsMerge
public void TestMergeMessageWithParametersCallsMerge()
{
var merged = false;
var service = new ServiceController() {
Settings = {
ServiceUpdateCore = false
},
Packages = new MockServicePackageManager() {
PackageInstalled = (sender, uri, packageId) => { merged = true; }
}
};
service.SignalMessage(new ServiceMessage() {
Name = "merge",
Arguments = new Dictionary<string, string>() {
{ "uri", "localhost" },
{ "packageid", "id" }
}
});
Assert.IsTrue(merged);
service.Dispose();
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Headers["User-Agent"] != null && (Request.Browser["IsMobileDevice"] == "true" || Request.UserAgent.ToUpper().Contains("MIDP") || Request.UserAgent.ToUpper().Contains("CLDC") || Request.UserAgent.ToLower().Contains("iphone") || Request.UserAgent.ToLower().Contains("avant") || Request.UserAgent.ToLower().Contains("nokia") || Request.UserAgent.ToLower().Contains("pda") || Request.UserAgent.ToLower().Contains("moto") || Request.UserAgent.ToLower().Contains("windows ce") || Request.UserAgent.ToLower().Contains("hand") || Request.UserAgent.ToLower().Contains("mobi") || Request.UserAgent.ToUpper().Contains("HTC") || Request.UserAgent.ToLower().Contains("sony") || Request.UserAgent.ToLower().Contains("panasonic") || Request.UserAgent.ToLower().Contains("blackberry") || Request.UserAgent.ToLower().Contains("240x320") || Request.UserAgent.ToLower().Contains("voda")))
{
Response.Redirect("mobile/index.aspx");
}
OSAEObjectCollection screens = OSAEObjectManager.GetObjectsByType("SCREEN");
this.SetSessionTimeout();
foreach (OSAEObject s in screens)
{
HtmlGenericControl li = new HtmlGenericControl("li");
ddlScreens.Controls.Add(li);
HtmlGenericControl anchor = new HtmlGenericControl("a");
anchor.Attributes.Add("href", "screens.aspx?id="+s.Name);
anchor.InnerText = s.Name;
li.Controls.Add(anchor);
}
ServiceController sc = new ServiceController("OSAE");
if (sc.Status != ServiceControllerStatus.Running)
{
cog.ImageUrl = "~/Images/cog_red.png";
cog.ToolTip = "OSA service is not running.";
}
}
示例3: CheckServiceStatus
private void CheckServiceStatus()
{
try
{
ServiceController sc = new ServiceController("OSAE");
switch (sc.Status)
{
case ServiceControllerStatus.Running:
serviceLabel.Text = "Running";
break;
case ServiceControllerStatus.Stopped:
serviceLabel.Text = "Stopped";
break;
case ServiceControllerStatus.Paused:
serviceLabel.Text = "Paused";
break;
case ServiceControllerStatus.StopPending:
serviceLabel.Text = "Stopping";
break;
case ServiceControllerStatus.StartPending:
serviceLabel.Text = "Starting";
break;
default:
serviceLabel.Text = "Status Changing";
break;
}
}
catch (Exception exc)
{
serviceLabel.Text = "Could not find service";
}
}
示例4: ConstructWithServiceName
public void ConstructWithServiceName()
{
var controller = new ServiceController(_testService.TestServiceName);
Assert.Equal(_testService.TestServiceName, controller.ServiceName);
Assert.Equal(_testService.TestServiceDisplayName, controller.DisplayName);
Assert.Equal(_testService.TestMachineName, controller.MachineName);
Assert.Equal(ServiceType.Win32OwnProcess, controller.ServiceType);
}
示例5: OnAfterInstall
protected override void OnAfterInstall(System.Collections.IDictionary savedState)
{
ServiceConfigurator.SetRecoveryOptions(ServiceName());
using (ServiceController pc = new ServiceController(ServiceName()))
{
pc.Start();
}
}
示例6: NWMasterServer
/// <summary>
/// Instantiate a new master server instance.
/// </summary>
/// <param name="ServiceObject">Optionally supplies the associated
/// service instance, else null if the program is not running in
/// service mode.</param>
public NWMasterServer(ServiceController ServiceObject)
{
this.ServiceObject = ServiceObject;
QueryCombineTimer = new System.Timers.Timer(QUERY_COMBINE_INTERVAL);
QueryCombineTimer.AutoReset = false;
QueryCombineTimer.Elapsed += new ElapsedEventHandler(QueryCombineTimer_Elapsed);
}
示例7: TestServiceProxyType
public void TestServiceProxyType()
{
var service = new ServiceController();
Assert.AreEqual(typeof(ServiceLoaderProxy), service.ServiceLoaderProxyType);
service.Dispose();
}
示例8: ServiceManager
/// <summary>
/// Inject alternative container and strategy for resolving Service Types
/// </summary>
public ServiceManager(Container container, ServiceController serviceController)
{
if (serviceController == null)
throw new ArgumentNullException("serviceController");
this.Container = container ?? new Container();
this.ServiceController = serviceController;
}
示例9: TestInitalServiceStateIsStopped
public void TestInitalServiceStateIsStopped()
{
var service = new ServiceController();
Assert.AreEqual(ServiceStatusType.Stopped, service.Observer.Status);
service.Dispose();
}
示例10: TestMonitoringIsEnabled
public void TestMonitoringIsEnabled()
{
var service = new ServiceController();
Assert.IsTrue(AppDomain.MonitoringIsEnabled);
service.Dispose();
}
示例11: Can_execute_BasicService
public void Can_execute_BasicService()
{
var serviceController = new ServiceController();
serviceController.Register(() => new BasicService());
var result = serviceController.Execute(new BasicRequest()) as BasicRequestResponse;
Assert.That(result, Is.Not.Null);
}
示例12: With_ServiceStackFunq
public void With_ServiceStackFunq()
{
var serviceController = new ServiceController();
serviceController.Register(() => new BasicService());
var request = new BasicRequest();
Console.WriteLine("With_TypedArguments(): {0}", Measure(() => serviceController.Execute(request), Times));
}
示例13: NewConnection
public NewConnection()
{
InitializeComponent();
communicator = ServiceController.Communicator;
serverVariables = new ServerVariables();
DataContext = serverVariables;
OnDialogContentRequest += NewConnection_OnDialogContentRequest;
}
示例14: TestJunkMessageReturnsFalse
public void TestJunkMessageReturnsFalse()
{
var service = new ServiceController();
Assert.IsFalse(service.SignalMessage(new ServiceMessage() {
Name = "junk"
}));
service.Dispose();
}
示例15: With_Expressions
public void With_Expressions()
{
var requestType = typeof(BasicRequest);
var serviceController = new ServiceController();
serviceController.Register(requestType, typeof(BasicService));
var request = new BasicRequest();
Console.WriteLine("With_Expressions(): {0}", Measure(() => serviceController.Execute(request), Times));
}