namespace System; internal static class StringExtensions { public static string ReplaceTypeSimple(this string typeSimple) { typeSimple = typeSimple .Replace("", "") .Replace("", "") .Replace("", "") .Replace("", "") .Replace("", "") .Replace("IRemoteStreamContent", "Blob") .Replace("{string:string}", "Dictionary") .Replace("{number:string}", "Dictionary") .Replace("{string:number}", "Dictionary") .Replace("{string:object}", "Dictionary"); if (typeSimple.StartsWith("[") && typeSimple.EndsWith("]")) { typeSimple = typeSimple.ReplaceFirst("[", "").RemovePostFix("]", ""); typeSimple = typeSimple.Replace(typeSimple, $"{typeSimple}[]"); } return typeSimple; } public static string ReplaceFlutterType(this string type) { type = type .Replace("{System.String:System.String}", "Map") .Replace("{System.Int32:System.String}", "Map") .Replace("{System.Int64:System.String}", "Map") .Replace("{System.String:System.Int32}", "Map") .Replace("{System.String:System.Int64}", "Map") .Replace("{System.String:System.Object}", "Map") .Replace("System.String", "String") .Replace("System.Guid", "String") .Replace("System.Int32", "num") .Replace("System.Int64", "num") .Replace("System.DateTime", "DateTime") .Replace("System.Boolean", "bool") .Replace("System.Object", "dynamic") .Replace("IRemoteStreamContent", "Blob"); if (type.StartsWith("[") && type.EndsWith("]")) { if (type.LastIndexOf('.') >= 0) { type = type[(type.LastIndexOf('.') + 1)..]; } type = type.RemovePreFix("[", "<").RemovePostFix("]", ">"); type = "List<" + type + ">"; } else { if (type.LastIndexOf('.') >= 0) { type = type[(type.LastIndexOf('.') + 1)..]; } } return type; } public static string ReplaceFlutterTypeSimple(this string typeSimple) { typeSimple = typeSimple .Replace("?", "") .Replace("", "") .Replace("", "") .Replace("", "") .Replace("", "") .Replace("", "") .Replace("IRemoteStreamContent", "Blob") .Replace("{string:string}", "Map") .Replace("{number:string}", "Map") .Replace("{string:number}", "Map") .Replace("{string:object}", "Map"); if (typeSimple.StartsWith("[") && typeSimple.EndsWith("]")) { typeSimple = typeSimple.RemovePreFix("[", "<").RemovePostFix("]", ">"); typeSimple = "List<" + typeSimple + ">"; } return typeSimple; } public static string MiddleString(this string sourse, string startstr, string endstr) { var result = string.Empty; int startindex, endindex; startindex = sourse.IndexOf(startstr); if (startindex == -1) { return result; } var tmpstr = sourse.Substring(startindex + startstr.Length - 1); endindex = tmpstr.IndexOf(endstr); if (endindex == -1) { return result; } result = tmpstr.Remove(endindex + 1); return result; } }