mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
More JSON autocorrecting (#2733)
This commit is contained in:
parent
9a412ea17b
commit
cf45d9c808
@ -137,7 +137,7 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_AlreadyExists, MessageBoxImage.Information);
|
Frontend.ShowMessageBox(Strings.Menu_FastFlagEditor_AlreadyExists, MessageBoxImage.Information);
|
||||||
|
|
||||||
bool refresh = false;
|
bool refresh = false;
|
||||||
|
|
||||||
@ -175,7 +175,14 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
|
|||||||
json = '{' + json;
|
json = '{' + json;
|
||||||
|
|
||||||
if (!json.EndsWith('}'))
|
if (!json.EndsWith('}'))
|
||||||
|
{
|
||||||
|
int lastIndex = json.LastIndexOf('}');
|
||||||
|
|
||||||
|
if (lastIndex == -1)
|
||||||
json += '}';
|
json += '}';
|
||||||
|
else
|
||||||
|
json = json.Substring(0, lastIndex+1);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -193,7 +200,7 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Frontend.ShowMessageBox(
|
Frontend.ShowMessageBox(
|
||||||
String.Format(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidJSON, ex.Message),
|
String.Format(Strings.Menu_FastFlagEditor_InvalidJSON, ex.Message),
|
||||||
MessageBoxImage.Error
|
MessageBoxImage.Error
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -205,7 +212,7 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
|
|||||||
if (list.Count > 16)
|
if (list.Count > 16)
|
||||||
{
|
{
|
||||||
var result = Frontend.ShowMessageBox(
|
var result = Frontend.ShowMessageBox(
|
||||||
Bloxstrap.Resources.Strings.Menu_FastFlagEditor_LargeConfig,
|
Strings.Menu_FastFlagEditor_LargeConfig,
|
||||||
MessageBoxImage.Warning,
|
MessageBoxImage.Warning,
|
||||||
MessageBoxButton.YesNo
|
MessageBoxButton.YesNo
|
||||||
);
|
);
|
||||||
@ -222,7 +229,7 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
|
|||||||
int count = conflictingFlags.Count();
|
int count = conflictingFlags.Count();
|
||||||
|
|
||||||
string message = String.Format(
|
string message = String.Format(
|
||||||
Bloxstrap.Resources.Strings.Menu_FastFlagEditor_ConflictingImport,
|
Strings.Menu_FastFlagEditor_ConflictingImport,
|
||||||
count,
|
count,
|
||||||
String.Join(", ", conflictingFlags.Take(25))
|
String.Join(", ", conflictingFlags.Take(25))
|
||||||
);
|
);
|
||||||
@ -263,16 +270,16 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
|
|||||||
string errorMessage = "";
|
string errorMessage = "";
|
||||||
|
|
||||||
if (!_validPrefixes.Any(name.StartsWith))
|
if (!_validPrefixes.Any(name.StartsWith))
|
||||||
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidPrefix;
|
errorMessage = Strings.Menu_FastFlagEditor_InvalidPrefix;
|
||||||
else if (!name.All(x => char.IsLetterOrDigit(x) || x == '_'))
|
else if (!name.All(x => char.IsLetterOrDigit(x) || x == '_'))
|
||||||
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidCharacter;
|
errorMessage = Strings.Menu_FastFlagEditor_InvalidCharacter;
|
||||||
|
|
||||||
if (name.EndsWith("_PlaceFilter") || name.EndsWith("_DataCenterFilter"))
|
if (name.EndsWith("_PlaceFilter") || name.EndsWith("_DataCenterFilter"))
|
||||||
errorMessage = !ValidateFilter(name, value) ? Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidPlaceFilter : "";
|
errorMessage = !ValidateFilter(name, value) ? Strings.Menu_FastFlagEditor_InvalidPlaceFilter : "";
|
||||||
else if ((name.StartsWith("FInt") || name.StartsWith("DFInt")) && !Int32.TryParse(value, out _))
|
else if ((name.StartsWith("FInt") || name.StartsWith("DFInt")) && !Int32.TryParse(value, out _))
|
||||||
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidNumberValue;
|
errorMessage = Strings.Menu_FastFlagEditor_InvalidNumberValue;
|
||||||
else if ((name.StartsWith("FFlag") || name.StartsWith("DFFlag")) && lowerValue != "true" && lowerValue != "false")
|
else if ((name.StartsWith("FFlag") || name.StartsWith("DFFlag")) && lowerValue != "true" && lowerValue != "false")
|
||||||
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidBoolValue;
|
errorMessage = Strings.Menu_FastFlagEditor_InvalidBoolValue;
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(errorMessage))
|
if (!String.IsNullOrEmpty(errorMessage))
|
||||||
{
|
{
|
||||||
@ -319,7 +326,7 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
|
|||||||
|
|
||||||
if (App.FastFlags.GetValue(newName) is not null)
|
if (App.FastFlags.GetValue(newName) is not null)
|
||||||
{
|
{
|
||||||
Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_AlreadyExists, MessageBoxImage.Information);
|
Frontend.ShowMessageBox(Strings.Menu_FastFlagEditor_AlreadyExists, MessageBoxImage.Information);
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
textbox.Text = oldName;
|
textbox.Text = oldName;
|
||||||
return;
|
return;
|
||||||
@ -387,7 +394,7 @@ namespace Bloxstrap.UI.Elements.Settings.Pages
|
|||||||
{
|
{
|
||||||
string json = JsonSerializer.Serialize(App.FastFlags.Prop, new JsonSerializerOptions { WriteIndented = true });
|
string json = JsonSerializer.Serialize(App.FastFlags.Prop, new JsonSerializerOptions { WriteIndented = true });
|
||||||
Clipboard.SetDataObject(json);
|
Clipboard.SetDataObject(json);
|
||||||
Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_JsonCopiedToClipboard, MessageBoxImage.Information);
|
Frontend.ShowMessageBox(Strings.Menu_FastFlagEditor_JsonCopiedToClipboard, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user