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


C# IServer.Start方法代码示例

本文整理汇总了C#中IServer.Start方法的典型用法代码示例。如果您正苦于以下问题:C# IServer.Start方法的具体用法?C# IServer.Start怎么用?C# IServer.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServer的用法示例。


在下文中一共展示了IServer.Start方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

        public void Start()
        {
            // validate settings and fill in any defaults
              if (string.IsNullOrEmpty(Settings.BasePath))
            Settings.BasePath = Environment.CurrentDirectory;

              var handler = CreateHandlerCore();
              _server = CreateServerCore(handler);

              _server.Start();
        }
开发者ID:chakrit,项目名称:fu-sharp,代码行数:11,代码来源:AppBase.cs

示例2: Run

        public void Run(string[] args, IServer server, IClient client)
        {
            try
            {
                TypeApp typeApp = (args[0] == "-s") ? TypeApp.Server : (args[0] == "-c") ? TypeApp.Client : TypeApp.None;

                IPAddress ipAdress;
                IPEndPoint ipEndPoint;

                switch (typeApp)
                {
                    case TypeApp.Client:
                        ipAdress = IPAddress.Parse(args[1]);
                        ipEndPoint = new IPEndPoint(ipAdress, int.Parse(args[2]));
                        client.ipEndPoint = ipEndPoint;
                        client.Start();
                        break;

                    case TypeApp.Server:
                        ipAdress = IPAddress.Any;
                        ipEndPoint = new IPEndPoint(ipAdress, int.Parse(args[1]));
                        server.ipEndPoint = ipEndPoint;
                        server.Start();
                        Console.ReadKey(true);
                        server.Stop();
                        break;

                    case TypeApp.None:
                        throw new Exception("Не указан тип приложения (-c или -s)");
                }

            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("Неверные параметры");
            }
            catch (Exception e)
            {
                Console.WriteLine("Ошибка: {0}", e.Message);
                System.Diagnostics.Debug.WriteLine(e.StackTrace);
            }
        }
开发者ID:vlsuKovalewVladimir,项目名称:modern-computer-technology,代码行数:42,代码来源:RunLabs.cs

示例3: Start

        public void Start(CommandLineArguments args)
        {
            _args = null;
            if (_view != null)
            {
                _view.ClearError();
            }

            try
            {
                ServiceFactory.Rules.ValidateArgs(args);
            }
            catch (CassiniException ex)
            {
                if (_view != null)
                {
                    _view.SetError(ex.Field, ex.Message);
                    return;
                }
                throw;
            }

            if (string.IsNullOrEmpty(args.ApplicationPath) || !Directory.Exists(args.ApplicationPath))
            {
                if (_view != null)
                {
                    _view.SetError(ErrorField.ApplicationPath, "Invalid Application Path");
                    return;
                }
                throw new CassiniException("Invalid Application Path", ErrorField.ApplicationPath);
            }

            // prepare arguments
            IPAddress ip = ServiceFactory.Rules.ParseIP(args.IPMode, args.IPv6, args.IPAddress);

            if (_view != null)
            {
                _view.IPAddress = ip.ToString();
            }

            ushort port = args.Port;
            if (args.PortMode == PortMode.FirstAvailable)
            {
                port = ServiceFactory.Rules.GetAvailablePort(args.PortRangeStart, args.PortRangeEnd, ip, true);
            }

            if (_view != null)
            {
                _view.Port = port;
            }

            if (_view != null)
            {
                _view.HostName = args.HostName;
            }

            _server = ServiceFactory.CreateServer(new ServerArguments
                                                      {
                                                          Port = port,
                                                          VirtualPath = args.VirtualPath,
                                                          ApplicationPath = args.ApplicationPath,
                                                          IPAddress = ip,
                                                          Hostname = args.HostName,
                                                          TimeOut = args.TimeOut
                                                      });

            WireServerEvents();

            if (args.AddHost)
            {
                ServiceFactory.Rules.AddHostEntry(_server.IPAddress.ToString(), _server.HostName);
            }

            try
            {

                _server.Start();
                _args = args;

                if (_view != null)
                {
                    _view.RootUrl = _server.RootUrl;
                    _view.RunState = RunState.Running;
                }
            }
            catch (Exception ex)
            {
                if (_view != null)
                {
                    _view.SetError(ErrorField.None, ex.Message);
                }

                Stop();
            }
        }
开发者ID:Evolutionary-Networking-Designs,项目名称:CassiniDev,代码行数:95,代码来源:Presenter.cs

示例4: StartDummyApplication

 private static void StartDummyApplication(IServer server)
 {
     server.Start(new DummyApplication(context => TaskUtilities.CompletedTask));
 }
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:4,代码来源:KestrelServerTests.cs

示例5: ServerOnPerformRestartServer

 private static void ServerOnPerformRestartServer(IServer server)
 {
     // TODO
     server.Stop();
     Console.WriteLine("Waiting 5 seconds before restarting");
     System.Threading.Thread.Sleep(5000);
     server.Start();
 }
开发者ID:SinaC,项目名称:TetriNET2,代码行数:8,代码来源:Program.cs


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