public ISynchronizedEntity ConvertToAcmanEntity(IRemoteEntity remoteEntity, Type t) { var properties = GetSyncedProperties(t); var entity = Activator.CreateInstance(t) as ISynchronizedEntity; entity.NeedUpdateRemoteIds = true; entity.EndSystemRecordId = new Guid(remoteEntity.Data["Id"].ToString()); foreach (var prop in properties) { var remoteEntityColumnNameAttr = prop.GetCustomAttribute <RemoteEntityColumnName>(); var remoteEntityColumnName = remoteEntityColumnNameAttr.Name; if (!remoteEntity.Data.ContainsKey(remoteEntityColumnName)) { continue; } var columnValue = remoteEntity.Data[remoteEntityColumnName]; if (columnValue != null) { if (!string.IsNullOrEmpty(remoteEntityColumnNameAttr.MapKey)) { var acmanColumnValue = GetMappedColumnValue(remoteEntityColumnNameAttr.MapKey, columnValue); if (acmanColumnValue != null) { prop.SetValue(entity, acmanColumnValue); } } else { var propType = prop.PropertyType; if (propType.GetInterface("ISynchronizedEntity") == null) { var typeInfo = propType.GetTypeInfo(); if (typeInfo == typeof(DateTime?) || typeInfo == typeof(DateTime)) { prop.SetValue( entity, DateTime .Parse(columnValue.ToString(), null, DateTimeStyles.RoundtripKind) .ToLocalTime() ); } else { prop.SetValue(entity, columnValue); } } else { var entityIdProp = t.GetProperty(prop.Name + "Id"); entityIdProp.SetValue(entity, new Guid(columnValue.ToString())); } } } } return(entity); }
public void StartClient(string pid, string client_url, int msec_per_round, int num_players) { Console.WriteLine("Client started on " + client_url); string path = "..\\..\\..\\Client\\bin\\Debug\\Client.exe"; Console.WriteLine(path); string args = client_url; Process p = StartProgram(path, args); pid_process_dict.Add(pid, p); IRemoteEntity client = Activator.GetObject(typeof(IRemoteClient), client_url) as IRemoteEntity; pid_instance_dict.Add(pid, client); }
public string LocalState(string pid, int round_id) { Console.WriteLine("Localstate on pid -> " + pid); String localstate = "localstate not found"; IRemoteEntity e = null; pid_instance_dict.TryGetValue(pid, out e); if (e != null) { localstate = e.LocalState(pid, round_id); } Console.WriteLine(localstate); return(localstate); }