Exemplo n.º 1
0
        static void Main(string[] args)
        {
            using (var config = new ClientConfig(1))
            {
                config.When <int>()
                .From <MyCommand>()
                .Call <MyHandler>();

                config.Channel <MyChannel>()
                .When <int>()
                .From <MyCommand>()
                .Call <MyHandler>();

                using (var channel = config.Channel <MyChannel>())
                {
                    channel.When <int>()
                    .From <MyCommand>()
                    .Call <MyHandler>();

                    channel.When <int>()
                    .From <MyCommand>()
                    .Call <MyHandler>();

                    using (var inner = channel.Channel <MyChannel>())
                    {
                        inner.When <int>()
                        .From <MyCommand>()
                        .Call <MyHandler>();

                        inner.When <int>()
                        .From <MyCommand>()
                        .Call <MyHandler>();
                    }

                    using (var when = channel.When <int>())
                    {
                        when.From <MyCommand>()
                        .Call <MyHandler>();
                    }
                }

                using (var client = config.Create())
                {
                    using (var connection = client.Connect("127.0.0.1", 4000))
                    {
                        connection.Send(12).To <MyCommand>();
                        Thread.Sleep(-1);
                    }
                }
            }
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            // Initialize Resource Config.
            modelBuilder.Configurations.Add(ResourceConfig.Create());
            modelBuilder.Configurations.Add(ResourceSettingsConfig.Create());
            modelBuilder.Configurations.Add(ResourceClaimConfig.Create());

            // Initialize Client Config.
            modelBuilder.Configurations.Add(ClientConfig.Create());
            modelBuilder.Configurations.Add(ClientKeyConfig.Create());
            modelBuilder.Configurations.Add(ClientResourceAccessConfig.Create());
            modelBuilder.Configurations.Add(ClientResourceAccessClaimConfig.Create());
        }
Exemplo n.º 3
0
        static async Task Main()
        {
            var config = new ClientConfig();

            config.On <int>().In <Command>().Call <Handler>();

            using (var app = config.Create("127.0.0.1", 4000))
            {
                using (var connection = await app.Connect())
                {
                    GC.CollectionCount(0);
                    GC.CollectionCount(1);
                    GC.CollectionCount(2);

                    await connection.Send(1).ToAsync <Command>();

                    Thread.Sleep(-1);
                }
            }
        }