public static Escape ( IEnumerable strs, bool fullEscape = false, bool escapePercent = false ) : List |
||
strs | IEnumerable | |
fullEscape | bool | |
escapePercent | bool | |
return | List |
public override string ForgeRawLine() { StringBuilder builder = new StringBuilder(); builder.Append(StringEscaper.Escape(URL)); builder.Append(base.ForgeRawLine()); return(builder.ToString()); }
public override string ForgeRawLine() { StringBuilder b = new StringBuilder(); b.Append(","); b.Append(StringEscaper.Escape(Url)); b.Append(base.ForgeRawLine()); return(b.ToString()); }
public bool SetValue(string newValue, bool update, out List <LogInfo> logs) { logs = new List <LogInfo>(1); bool success = false; switch (Type) { case UIControlType.TextLabel: // Text Text = StringEscaper.Escape(newValue); logs.Add(new LogInfo(LogState.Success, $"Interface control [{Key}] set to [{newValue}]")); success = true; break; case UIControlType.TextBox: { // Value UIInfo_TextBox uiInfo = Info.Cast <UIInfo_TextBox>(); uiInfo.Value = StringEscaper.Escape(newValue); logs.Add(new LogInfo(LogState.Success, $"Interface control [{Key}] set to [{newValue}]")); success = true; } break; case UIControlType.NumberBox: { // Value UIInfo_NumberBox uiInfo = Info.Cast <UIInfo_NumberBox>(); // WB082 just write string value in case of error, but PEBakery will throw error if (!NumberHelper.ParseInt32(newValue, out int intVal)) { logs.Add(new LogInfo(LogState.Error, $"[{newValue}] is not a valid integer")); return(false); } if (uiInfo.Min <= intVal && intVal <= uiInfo.Max) { uiInfo.Value = intVal; } else { logs.Add(new LogInfo(LogState.Error, $"[{newValue}] should be inside of [{uiInfo.Min}] ~ [{uiInfo.Max}]")); return(false); } logs.Add(new LogInfo(LogState.Success, $"Interface control [{Key}] set to [{newValue}]")); success = true; } break; case UIControlType.CheckBox: { // Value UIInfo_CheckBox uiInfo = Info.Cast <UIInfo_CheckBox>(); if (newValue.Equals("True", StringComparison.OrdinalIgnoreCase)) { uiInfo.Value = true; logs.Add(new LogInfo(LogState.Success, $"Interface control [{Key}] set to [True]")); success = true; } else if (newValue.Equals("False", StringComparison.OrdinalIgnoreCase)) { uiInfo.Value = false; logs.Add(new LogInfo(LogState.Success, $"Interface control [{Key}] set to [False]")); success = true; } else { // WB082 just write string value in case of error, but PEBakery will throw error logs.Add(new LogInfo(LogState.Error, $"[{newValue}] is not a valid boolean value")); return(false); } } break; case UIControlType.ComboBox: { // Text UIInfo_ComboBox uiInfo = Info.Cast <UIInfo_ComboBox>(); int idx = uiInfo.Items.FindIndex(x => newValue.Equals(StringEscaper.Unescape(x), StringComparison.OrdinalIgnoreCase)); if (idx == -1) { // Invalid index logs.Add(new LogInfo(LogState.Error, $"[{newValue}] was not found in the item list")); return(false); } uiInfo.Index = idx; Text = uiInfo.Items[idx]; logs.Add(new LogInfo(LogState.Success, $"Interface control [{Key}] set to [{Text}]")); success = true; } break; case UIControlType.RadioButton: { UIInfo_RadioButton uiInfo = Info.Cast <UIInfo_RadioButton>(); if (newValue.Equals("True", StringComparison.OrdinalIgnoreCase)) { uiInfo.Selected = true; logs.Add(new LogInfo(LogState.Success, $"Interface control [{Key}] set to [True]")); success = true; } else if (newValue.Equals("False", StringComparison.OrdinalIgnoreCase)) { uiInfo.Selected = false; logs.Add(new LogInfo(LogState.Success, $"Interface control [{Key}] set to [False]")); success = true; } else { // WB082 just write string value, but PEBakery will throw error logs.Add(new LogInfo(LogState.Error, $"[{newValue}] is not a valid boolean value")); return(false); } } break; case UIControlType.FileBox: Text = StringEscaper.Escape(newValue); logs.Add(new LogInfo(LogState.Success, $"Interface Control [{Key}] set to [{newValue}]")); success = true; break; case UIControlType.RadioGroup: { UIInfo_RadioGroup uiInfo = Info.Cast <UIInfo_RadioGroup>(); if (!NumberHelper.ParseInt32(newValue, out int idx)) { logs.Add(new LogInfo(LogState.Error, $"[{newValue}] is not a valid integer")); return(false); } if (0 <= idx && idx < uiInfo.Items.Count) { uiInfo.Selected = idx; } else { // Invalid Index logs.Add(new LogInfo(LogState.Error, $"Index [{newValue}] is invalid")); return(false); } logs.Add(new LogInfo(LogState.Success, $"Interface control [{Key}] set to [{newValue}]")); success = true; } break; } if (success && update) { Update(); } return(success); }