• ToTimestamp.cs 将Datetime转换成时间戳,10位,秒
    netnr 2018-11-03 4
    /// <summary>
    /// 将Datetime转换成时间戳,10位,秒
    /// </summary>
    /// <param name="datetime"></param>
    /// <returns></returns>
    public static long ToTimestamp(this DateTime datetime)
    {
        return (datetime.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
    }
  • ToEncode-ToDecode.cs 编码、解码
    netnr 2018-11-03 3
    /// <summary>
    /// 编码
    /// </summary>
    /// <param name="uri"></param>
    /// <param name="charset"></param>
    /// <returns></returns>
    public static string ToEncode(this string uri, string charset = "utf-8")
    {
        string URL_ALLOWED_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
  • ToDataTable-ToModel.cs 实体转表、表转实体
    netnr 2018-11-03 4
    /// <summary>
    /// 实体转表
    /// </summary>
    /// <typeparam name="T">泛型</typeparam>
    /// <param name="list">对象</param>
    /// <returns></returns>
    public static DataTable ToDataTable<T>(this IList<T> list)
    {
        Type elementType = typeof(T);
        var t = new DataTable();
  • RequesToModel.cs 反射参数为实体
    netnr 2018-09-26 5
    /// <summary>
    /// 反射参数为实体
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="model"></param>
    /// <param name="request"></param>
    /// <returns></returns>
    public static T RequesToModel<T>(this T model, HttpRequest request = null)
    {
        if (request == null)
  • ToDataTable.cs 实体转表
    netnr 2018-09-26 5
    /// <summary>
    /// 实体转为表
    /// </summary>
    /// <typeparam name="T">泛型</typeparam>
    /// <param name="list">对象</param>
    /// <returns></returns>
    public static DataTable ToDataTable<T>(this IList<T> list)
    {
        Type elementType = typeof(T);
        var t = new DataTable();
  • OfJson.cs JSON 字符串转义
    netnr 2018-09-26 6
    /// <summary>
    /// 字符串 JSON转义
    /// </summary>
    /// <param name="s"></param>
    /// <returns></returns>
    public static string OfJson(this string s)
    {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.Length; i++)
        {