コード例 #1
0
        public override void Execute(UserSettings settings)
        {
            if (!(settings.Binding is BasicHttpBinding))
            {
                SysConsole.WriteErrorLine($"Supports {nameof(BasicHttpBinding)} only.");
                return;
            }

            switch (settings.AppSide)
            {
            case AppSide.Client:
                var clients = QuestionManager.Choose(
                    new[]
                {
                    1,
                    2,
                    3
                },
                    (o) => o.ToString(),
                    "Choose clients count");

                // Creates callback processors
                for (int i = 0; i < clients; i++)
                {
                    // proxy client
                    var client = CreateClient <IMyService>(settings);

                    // client thread
                    Task.Factory.StartNew(InitClient, client);
                }

                SysConsole.PressAnyKey();
                SysConsole.WriteLine(null, 2);
                break;

            case AppSide.Server:
                CreateServiceHost <IMyService, MyService>(settings).Open();
                QuestionManager.AwaitingClientConnections();
                break;
            }
        }