Пример #1
0
        public static ISiloHost BuildSiloHost()
        {
            var ddd = new MySql.Data.MySqlClient.MySqlCommand();

            var config = new ClusterConfiguration();

            config.StandardLoad();

            var builder = new SiloHostBuilder();

            //builder.LoadClusterConfiguration()
            builder.UseConfiguration(config)
            .ConfigureLogging(logging => logging.AddLog4Net("log4net.config"))
            .ConfigureServices((context, svr) =>
            {
                //同理客户端(ClientBuilder),服务端,也是自己有一个ServiceCollection容器对象
                //此处注入,处理的是针对Grain实现类的依赖注入;
                svr.AddScoped <IMessageService, MessageService>();
            })
            .ConfigureApplicationParts(parts =>
            {
                //此处需要添加Grain实现类程序集
                parts.AddApplicationPart(typeof(DemoService).Assembly).WithReferences();
            })
            .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = "my-first-cluster";
                options.ServiceId = "MyAwesomeOrleansService";
            });

            return(builder.Build());
        }
Пример #2
0
        public void SiloHostBuilder_NullConfigurationTest()
        {
            var builder = new SiloHostBuilder().ConfigureDefaults()
                          .ConfigureServices(RemoveConfigValidatorsAndSetAddress);

            Assert.Throws <ArgumentNullException>(() => builder.UseConfiguration(null));
        }
Пример #3
0
        public void SiloHostBuilder_NullConfigurationTest()
        {
            var builder = new SiloHostBuilder().ConfigureOrleans()
                          .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().AddFromAppDomain())
                          .ConfigureServices(RemoveConfigValidators);

            Assert.Throws <ArgumentNullException>(() => builder.UseConfiguration(null));
        }