Example #1
0
        private static void Run(Func <ReactiveClientContext, Task> action)
        {
            var platform = default(IReactivePlatform);

            try
            {
                platform = new TcpReactivePlatform();

                try
                {
                    var clientProvider = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
                    var serverProvider = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider {
                        TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
                    };
                    var props = new System.Collections.Hashtable
                    {
                        { "port", 0 },
                        { "name", System.Guid.NewGuid().ToString() },
                        { "typeFilterLevel", System.Runtime.Serialization.Formatters.TypeFilterLevel.Full }
                    };
                    System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new System.Runtime.Remoting.Channels.Tcp.TcpChannel(props, clientProvider, serverProvider), ensureSecurity: false);

                    platform.StartAsync(CancellationToken.None).Wait();
                    Console.WriteLine("Running demo with the TCP platform.");
                }
#pragma warning disable CA1031 // Do not catch general exception types. (Demo code.)
                catch
                {
                    try { platform.StopAsync(CancellationToken.None).Wait(); }
                    catch { }

                    platform = new InMemoryReactivePlatform();
                    platform.StartAsync(CancellationToken.None).Wait();
                    Console.WriteLine("Running demo with the in-memory platform.");
                }
#pragma warning restore CA1031

                new ReactivePlatformDeployer(platform, new Deployable.CoreDeployable()).Deploy();

                action(platform.CreateClient().Context).Wait();
            }
            finally
            {
                platform?.Dispose();
            }
        }
 public ReactiveServiceConnectionEnvironment()
 {
     _platform = new InMemoryReactivePlatform <QueryCoordinatorServiceConnection, ConfiguredQueryEvaluatorServiceConnection>();
     _platform.StartAsync(CancellationToken.None).Wait();
     new ReactivePlatformDeployer(_platform, new Deployable.CoreDeployable()).Deploy();
 }