扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
#region Binary Serializers public static System.IO.MemoryStream SerializeBinary(object request) { System.Runtime.Serialization.Formatters.Binary.BinaryFormatter serializer = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.MemoryStream memStream = new System.IO.MemoryStream(); serializer.Serialize(memStream, request); return memStream; } public static object DeSerializeBinary(System.IO.MemoryStream memStream) { memStream.Position=0; System.Runtime.Serialization.Formatters.Binary.BinaryFormatter deserializer = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); object newobj = deserializer.Deserialize(memStream); memStream.Close(); return newobj; } #endregion #region XML Serializers public static System.IO.MemoryStream SerializeSOAP(object request) { System.Runtime.Serialization.Formatters.Soap.SoapFormatter serializer = new System.Runtime.Serialization.Formatters.Soap.SoapFormatter(); System.IO.MemoryStream memStream = new System.IO.MemoryStream(); serializer.Serialize(memStream, request); return memStream; } public static object DeSerializeSOAP(System.IO.MemoryStream memStream) { object sr; System.Runtime.Serialization.Formatters.Soap.SoapFormatter deserializer = new System.Runtime.Serialization.Formatters.Soap.SoapFormatter(); memStream.Position=0; sr = deserializer.Deserialize(memStream); memStream.Close(); return sr; } #endregion |
using System; namespace FifteenSeconds { /// /// 允许我们提出一个计划 /// [Serializable()] public class Schedule { protected System.DateTime start; protected System.DateTime end; //每次间隔增加的毫秒数 protected long interval; public System.DateTime Start {get{return start;}set{start=value;}} public System.DateTime End {get{return end;}set{end=value;}} public long Interval {get{return interval;}set{interval=value;}} public Schedule(System.DateTime Start, System.DateTime End, long Interval) { start=Start; end=End; interval=Interval; } //返回下次运行的时间;如果计划已经结束,则返回结束时间 public System.DateTime NextRunTime { get { System.TimeSpan ts = new System.TimeSpan(end.Ticks-System.DateTime.Now.Ticks); if(ts.Milliseconds>0) { //运行时间还没有结束 return System.DateTime.Now.AddMilliseconds(interval); } else { return end; } } } } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者