public void SetInst(List <Type> types, ILogic logicInst) { if (!(logicInst is IClientServerLogic logic)) { return; } _serializator = new TestSerializator(); Storage = new TestCommandStorage(_serializator); var path = logic.ConfigPath; var clientCreator = types.Find(x => x.Namespace == logic.NamespaceCreator && x.Name == "ClientLogicCreator"); var serverCreator = types.Find(x => x.Namespace == logic.NamespaceCreator && x.Name == "ServerLogicCreator"); var data = new ClientServerData { client = clientCreator.GetMethod("Create").Invoke(null, new [] { _serializator, Storage, logic.ClientExternalApi }), server = serverCreator.GetMethod("Create").Invoke(null, new[] { _serializator, logic.ServerExternalApi }), }; var commands = data.client.GetType().GetProperty("Commands").GetValue(data.client); var state = data.client.GetType().GetProperty("State").GetValue(data.client); var config = ConfigUtility.GetData(path); _server.Init(data, _serializator, config); _client.Init(data, Storage, _serializator, config); logic.SetDependencies(commands, state); }
public void CreateClientContext() { var serializator = new TestSerializator(); var command = new TestCommandStorage(serializator); _clientContext = ClientLogicCreator.Create(serializator, command, _externalApi); }
public void CreateServerContext() { var serializator = new TestSerializator(); _serverContext = ServerLogicCreator.Create(serializator, _externalApi); _serverContext.SetStaticData(_config.staticData); _serverContext.SetStateData(_config.defaultClientState, _config.defaultServerState); }
public EmulateLogicAPI() { _config = ConfigUtility.GetData(_path); _externalApi = new SampleExternalAPI(); var serializator = new TestSerializator(); var command = new TestCommandStorage(serializator); _clientContext = ClientLogicCreator.Create(serializator, command, _externalApi); _clientContext.InitData(_config.defaultClientState, _config.staticData); _clientContext.UpdateServerState(_config.defaultServerState); //_emulateContext = ClientLogicCreator.Create(_externalApi); _emulateContext.InitData(_clientContext.State, null); }