当前位置: 首页>>代码示例>>C#>>正文


C# ServiceController类代码示例

本文整理汇总了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();
        }
开发者ID:EBassie,项目名称:Potato,代码行数:25,代码来源:TestSignalMessageCallback.cs

示例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.";
        }
    }
开发者ID:just8,项目名称:Open-Source-Automation,代码行数:30,代码来源:MasterPage.master.cs

示例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";
     }
 }
开发者ID:just8,项目名称:Open-Source-Automation,代码行数:32,代码来源:config.aspx.cs

示例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);
 }
开发者ID:nnyamhon,项目名称:corefx,代码行数:8,代码来源:ServiceControllerTests.cs

示例5: OnAfterInstall

 protected override void OnAfterInstall(System.Collections.IDictionary savedState)
 {
     ServiceConfigurator.SetRecoveryOptions(ServiceName());
     using (ServiceController pc = new ServiceController(ServiceName()))
     {
         pc.Start();
     }
 }
开发者ID:jvshahid,项目名称:diego-windows-release,代码行数:8,代码来源:CommonService.cs

示例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);
        }
开发者ID:jakkn,项目名称:nwn2dev-public,代码行数:14,代码来源:NWMasterServer.cs

示例7: TestServiceProxyType

        public void TestServiceProxyType()
        {
            var service = new ServiceController();

            Assert.AreEqual(typeof(ServiceLoaderProxy), service.ServiceLoaderProxyType);

            service.Dispose();
        }
开发者ID:EBassie,项目名称:Potato,代码行数:8,代码来源:TestConstructor.cs

示例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;
        }
开发者ID:bman654,项目名称:ServiceStack,代码行数:11,代码来源:ServiceManager.cs

示例9: TestInitalServiceStateIsStopped

        public void TestInitalServiceStateIsStopped()
        {
            var service = new ServiceController();

            Assert.AreEqual(ServiceStatusType.Stopped, service.Observer.Status);

            service.Dispose();
        }
开发者ID:EBassie,项目名称:Potato,代码行数:8,代码来源:TestConstructor.cs

示例10: TestMonitoringIsEnabled

        public void TestMonitoringIsEnabled()
        {
            var service = new ServiceController();

            Assert.IsTrue(AppDomain.MonitoringIsEnabled);

            service.Dispose();
        }
开发者ID:EBassie,项目名称:Potato,代码行数:8,代码来源:TestConstructor.cs

示例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);
        }
开发者ID:Braunson,项目名称:ServiceStack,代码行数:9,代码来源:ServiceHostTests.cs

示例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));
        }
开发者ID:EvgeniyProtas,项目名称:servicestack,代码行数:9,代码来源:PerfTests.cs

示例13: NewConnection

        public NewConnection()
        {
            InitializeComponent();

            communicator = ServiceController.Communicator;

            serverVariables = new ServerVariables();
            DataContext = serverVariables;
            OnDialogContentRequest += NewConnection_OnDialogContentRequest;
        }
开发者ID:ieuan0928,项目名称:vumva,代码行数:10,代码来源:NewConnection.xaml.cs

示例14: TestJunkMessageReturnsFalse

        public void TestJunkMessageReturnsFalse()
        {
            var service = new ServiceController();

            Assert.IsFalse(service.SignalMessage(new ServiceMessage() {
                Name = "junk"
            }));

            service.Dispose();
        }
开发者ID:EBassie,项目名称:Potato,代码行数:10,代码来源:TestSignalMessage.cs

示例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));
        }
开发者ID:EvgeniyProtas,项目名称:servicestack,代码行数:10,代码来源:PerfTests.cs


注:本文中的ServiceController类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。