Example #1
0
        public Host(params string[] arguments)
        {
            Settings = new MemstateSettings(arguments);

            var modelType = Type.GetType(Settings.Model);

            _startMethod = GetType()
                           .GetMethods(BindingFlags)
                           .Where(m => m.Name == "Start" && m.IsGenericMethod && m.GetGenericArguments().Length == 1)
                           .Select(m => m.MakeGenericMethod(modelType))
                           .First();

            _stopMethod = GetType()
                          .GetMethods(BindingFlags)
                          .Where(m => m.Name == "Stop" && m.IsGenericMethod && m.GetGenericArguments().Length == 1)
                          .Select(m => m.MakeGenericMethod(modelType))
                          .First();

            var modelCreator = Settings.CreateModelCreator();

            var model = CreateModel(modelType, modelCreator);

            _server = CreateServer(Settings, model);
        }