public static string StringConvert(string val, StringConversionType type) { return(type switch { StringConversionType.HalfWidth => val.Normalize(NormalizationForm.FormKC), StringConversionType.FullWidth => string.Concat(val.Select(c => CharDictionary.ContainsKey(c) ? CharDictionary[c] : c)), _ => val });
private Expression CreateStringConversionExpression(MemberExpression propertyExpression, StringConversionType stringConversionType) { var methodName = StringConversionTypeMap[stringConversionType]; return(Expression.Call(propertyExpression, typeof(string).GetMethod(methodName, Type.EmptyTypes))); }
public static string GetStringFromList <T>(List <T> values, string divider = ",", StringConversionType conversionType = StringConversionType.ToString) { string output = string.Empty; for (int i = 0; i < values.Count; i++) { switch (conversionType) { case StringConversionType.ToString: output += values[i].ToString(); break; case StringConversionType.GetType: output += values[i].GetType().ToString(); break; default: output += values[i]; break; } // Only add divider if not on last element if (i < values.Count - 1) { output += divider; } } return(output); }
public static bool TryAsJsonString(this SciterValue sciterValue, out string value, StringConversionType conversionType = StringConversionType.JsonLiteral) { value = null; return(sciterValue?.TryAsJsonStringInternal(value: out value, conversionType: conversionType) == true); }
public static string AsJsonString(this SciterValue sciterValue, StringConversionType conversionType = StringConversionType.JsonLiteral) { return(sciterValue?.AsJsonStringInternal(conversionType: conversionType)); }
public static string StringConvert(string val, StringConversionType type) => type switch {