示例#1
0
文件: Program.cs 项目: Hem/SimpleNet
        static void Main(string[] args)
        {
            var appId = Guid.NewGuid();

            var callback = new DefaultDiagnosticsServicesCallback();

            callback.MessageReceived += delegate(LogMessageDto message)
            {
                Console.WriteLine("Received {0}: {2:d}: {1}", message.LogLevel, message.LogText, message.LogDateTime);
            };

            var serviceAddress =
                Container.GetExportedValue <IWcfServiceAddress>(DiagnosticsAddressProvider.DIAGNOSTICS_SERVICE_ADDRESS);


            var sampleService = Container.GetExportedValue <SampleServiceProxy>();

            var duplexCcasAdapter = new DuplexDiagnosticServiceAdapter(serviceAddress, callback);

            var inLoop = true;


            Console.Clear();

            Console.WriteLine(
                @"Please press
                    C: Connect to Duplex Messaging Service
                    R: Read data from Service
                    Q: Quit
                    ");


            while (inLoop)
            {
                Console.WriteLine("-------------------------------------------");

                var key = Console.ReadKey();

                switch (key.KeyChar.ToString().ToUpperInvariant())
                {
                case "C":
                    try
                    {
                        Console.WriteLine("Establishing Duplex Connection");

                        duplexCcasAdapter.Connect(appId, "Debug", "secret");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Failed! Please try again (takes 2 tries at times) ");
                    }

                    break;

                case "R":
                    Console.WriteLine(sampleService.GetServiceName());
                    break;

                case "Q":
                    inLoop = false;
                    break;
                }
            }


            Console.ReadLine();
        }
示例#2
0
文件: Program.cs 项目: Hem/SimpleNet
        static void Main(string[] args)
        {
            var appId = Guid.NewGuid();

            var callback = new DefaultDiagnosticsServicesCallback();
            callback.MessageReceived += delegate(LogMessageDto message)
            {
                Console.WriteLine("Received {0}: {2:d}: {1}", message.LogLevel, message.LogText, message.LogDateTime);
            };

            var serviceAddress =
                Container.GetExportedValue<IWcfServiceAddress>(DiagnosticsAddressProvider.DIAGNOSTICS_SERVICE_ADDRESS);

            var sampleService = Container.GetExportedValue<SampleServiceProxy>();

            var duplexCcasAdapter = new DuplexDiagnosticServiceAdapter(serviceAddress, callback);

            var inLoop = true;

            Console.Clear();

            Console.WriteLine(
                @"Please press
                    C: Connect to Duplex Messaging Service
                    R: Read data from Service
                    Q: Quit
                    ");

            while (inLoop)
            {
                Console.WriteLine("-------------------------------------------");

                var key = Console.ReadKey();

                switch (key.KeyChar.ToString().ToUpperInvariant())
                {
                    case "C":
                        try
                        {
                            Console.WriteLine("Establishing Duplex Connection");

                            duplexCcasAdapter.Connect(appId, "Debug", "secret");
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Failed! Please try again (takes 2 tries at times) ");
                        }

                        break;
                    case "R":
                        Console.WriteLine(sampleService.GetServiceName());
                        break;
                    case "Q":
                        inLoop = false;
                        break;

                }

            }

            Console.ReadLine();
        }