public static VectorClockSyncResultDto <T> FromModel(VectorClockSyncResult <T> model) { return(new VectorClockSyncResultDto <T> { Solution = VectorClockNodeDto <T> .FromModel(model.Solution), Conflict = VectorClockConflictDto <T> .FromModel(model.Conflict), CurrentNode = VectorClockNodeDto <T> .FromModel(model.CurrentNode), }); }
private void NotifySyncServer() { Thread.Sleep(AppState <T> .DelayByMs); using (var http = new HttpClient()) { StringContent json = new StringContent(JsonConvert.SerializeObject(VectorClockNodeDto <T> .FromModel(AppState <T> .Current.VectorClockNode)), Encoding.Default, "application/json"); http.PutAsync($"{syncServerUrl}/sync", json).Result.EnsureSuccessStatusCode(); } }
public static VectorClockConflictDto <T> FromModel(VectorClockConflict <T> model) { if (model == null) { return(null); } return(new VectorClockConflictDto <T> { NodeA = VectorClockNodeDto <T> .FromModel(model.NodeA), NodeB = VectorClockNodeDto <T> .FromModel(model.NodeB), }); }
public override bool TryRegisterNode(VectorClockNode <T> node) { using (var http = new HttpClient()) { StringContent json = new StringContent(JsonConvert.SerializeObject(VectorClockNodeDto <T> .FromModel(node)), Encoding.Default, "application/json"); var response = http.PostAsync($"{Url}sync/register", json).Result; return(response.IsSuccessStatusCode); } }