You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.2 KiB
50 lines
1.2 KiB
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<T>(this string str) where T : new()
|
|
{
|
|
try
|
|
{
|
|
return JsonConfig.parse<T>(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;
|
|
}
|
|
|
|
}
|
|
}
|
|
|