/// <summary>Returns true if the string represents unknown, otherwise false.</summary> /// <param name="val"> /// The string value to test. /// </param> /// <param name="culture"> /// The culture to test for. /// </param> public static bool IsUnknown(string val, CultureInfo culture) { if (string.IsNullOrEmpty(val)) { return(false); } var c = culture ?? CultureInfo.InvariantCulture; string[] values; lock (locker) { if (!StringValues.TryGetValue(c, out values)) { values = ResourceManager .GetString("Values", c) .Split(';') .Select(v => v.ToUpper(c)) .ToArray(); StringValues[c] = values; } } return (values.Contains(val.ToUpper(c)) || ( !c.Equals(CultureInfo.InvariantCulture) && StringValues[CultureInfo.InvariantCulture].Contains(val.ToUpperInvariant()) )); }
public void OnAfterDeserialize() { StringValues.TryGetValue("CompletionPropeller", out string @out2); if (string.IsNullOrEmpty(@out2)) { return; } CompletionPropeller = JsonUtility.FromJson <BossStatue.Completion>(@out2); }
/// <summary>Returns true if the string represents unknown, otherwise false.</summary> /// <param name="val"> /// The string value to test. /// </param> /// <param name="culture"> /// The culture to test for. /// </param> public static bool IsUnknown(string val, CultureInfo culture) { if (string.IsNullOrEmpty(val)) { return(false); } var c = culture ?? CultureInfo.InvariantCulture; if (!StringValues.TryGetValue(c, out string[] values))
/// <summary> /// Returns <see langword="true"/> if the field was successfully found, and it placed into <paramref name="fieldValue"/>. /// Otherwise it returns <see langword="false"/> and <paramref name="fieldValue"/> is <see langword="null"/> /// </summary> /// <param name="fieldName">bruh</param> /// <param name="fieldValue">bruh</param> /// <returns>Whether the field was successfuly found</returns> public bool TryGetString(string fieldName, out string fieldValue) { // could shrink this down 6 lines, but this is more readable imo :) if (StringValues.TryGetValue(fieldName, out string value)) { fieldValue = value; return(true); } else { fieldValue = null; return(false); } }
public bool TryGetBoolean(string fieldName, out bool fieldValue) { if (StringValues.TryGetValue(fieldName, out string value)) { if (bool.TryParse(value, out bool boolValue)) { fieldValue = boolValue; return(true); } else { fieldValue = false; return(false); } } else { fieldValue = false; return(false); } }