using Sog; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SMWebServer { public static class ExComm { public static int Toint32(this string str, int Defaultvalue = 0) { int i; return int.TryParse(str, out i) ? i : Defaultvalue; } public static T ToJson(this string str) where T : new() { try { return JsonConfig.parse(str); } catch (Exception ex) { TraceLog.Debug("ExComm.ToJson err msg {0}", ex.Message); return new T(); } } public static string ToJsonstr(this object obj) { try { return JsonConfig.stringify(obj); } catch (Exception ex) { TraceLog.Debug("ExComm.ToJson err msg {0}", ex.Message); return ""; } } public static long Tolong(this string str, long Defaultvalue = 0) { long i; return long.TryParse(str, out i) ? i : Defaultvalue; } } }