Hishop.Weixin.Pay/Util/Utils.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
namespace Hishop.Weixin.Pay.Util
{
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using Hishop.Weixin.Pay.Notify;
internal class Utils
{
private static readonly DateTime BaseTime = new DateTime(0x7b2, 1, 1);
private static Dictionary<string, XmlSerializer> parsers = new Dictionary<string, XmlSerializer>();
public static DateTime ConvertSecondsToDateTime(long seconds)
{
return BaseTime.AddSeconds((double) seconds).AddHours(8.0);
}
public static string CreateNoncestr()
{
return DateTime.Now.ToString("fffffff");
}
public static long GetCurrentTimeSeconds()
{
TimeSpan span = (TimeSpan) (DateTime.UtcNow - BaseTime);
return (long) span.TotalSeconds;
}
public static T GetNotifyObject<T>(string xml) where T: NotifyObject
{
Type type = typeof(T);
string fullName = type.FullName;
XmlSerializer serializer = null;
if (!(parsers.TryGetValue(fullName, out serializer) && (serializer != null)))
{
XmlAttributes attributes = new XmlAttributes {
XmlRoot = new XmlRootAttribute("xml")
};
XmlAttributeOverrides overrides = new XmlAttributeOverrides();
overrides.Add(type, attributes);
serializer = new XmlSerializer(type, overrides);
parsers[fullName] = serializer;
}
object obj2 = null;
try
{
using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
{
obj2 = serializer.Deserialize(stream);
}
}
catch (Exception)
{
return default(T);
}
return (obj2 as T);
}
后面还有 23 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
