private void CompareFormatted(ComparerControlViewModel vm, object parameter) { ErrorMessage = null; string error; string formattedJsonl = JsonFormatter.FormatIfPossible(vm.Json1Content, out error); if (error != null) { ErrorMessage = $"Invalid JSON in \"{vm.Json1Name}\". {error}"; return; } string formattedJson2 = JsonFormatter.FormatIfPossible(vm.Json2Content, out error); if (error != null) { ErrorMessage = $"Invalid JSON in \"{vm.Json2Name}\". {error}"; return; } try { JsonComparer.Compare(formattedJsonl, vm.Json1Name, formattedJson2, vm.Json2Name); } catch (Exception e) { ErrorMessage = $"Failed to compare. {e.Message}"; } }
private bool CanCompare(ComparerControlViewModel vm, object parameter) { return(!string.IsNullOrWhiteSpace(vm.Json1Name) && !string.IsNullOrWhiteSpace(vm.Json1Content) && !string.IsNullOrWhiteSpace(vm.Json2Name) && !string.IsNullOrWhiteSpace(vm.Json2Content)); }
private void Compare(ComparerControlViewModel vm, object parameter) { ErrorMessage = null; try { JsonComparer.Compare(vm.Json1Content, vm.Json1Name, vm.Json2Content, vm.Json2Name); } catch (Exception e) { ErrorMessage = $"Failed to compare. {e.Message}"; } }