摘要:#region IXmlSerializable 成员 public static MetaEntity Load(string path) { using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { XmlSerializer serializer = new XmlSerializer(typeof(MetaEntity)); return (MetaEntity)serializer.Deserialize(stream); } } public void Save(string
阅读全文
摘要:UrlMapping/// <summary> /// 路径映射 /// </summary> public static class UrlMapping { /// <summary> /// Aspx 转换到 Html /// </summary> /// <param name="url"></param> /// <returns></returns> public static string AspxToHtml(string url) { //判断路径是否为空 if
阅读全文
摘要:public static void DeriveParameters(DbCommand cmd, params object[] values) { AppRuntime.GuardArgument(cmd, "cmd"); AppRuntime.GuardArgument(string.IsNullOrEmpty(cmd.CommandText), "cmd.CommandText"); AppRuntime.GuardArgument(cmd.Connection == null, "cmd.Connection"); App
阅读全文
摘要:public static void BackupSQLServerDB(string connectionString, string backupPath) { using (SqlConnection conn = new SqlConnection(connectionString)) { //string sql = "use master;backup database " + conn.Database + " to disk='" + backupPath + "'"; string sql = &qu
阅读全文
摘要:SkipListSkipListNode /// <summary> /// Represents a node in a SkipList. A SkipListNode has a Height and a set of neighboring /// SkipListNodes (precisely as many neighbor references as its Height, although some neighbor /// references may be null). Also, a SkipListNode contains some piece of d
阅读全文
摘要:/// <summary> /// 渐变算法 /// </summary> /// <param name="sourceImg">位图源(物理路径)</param> /// <param name="colorHead">起点色(HTML格式)</param> /// <param name="colorTail">终点色(HTML格式)</param> /// <param name="imgPath">
阅读全文
摘要:public static DbCommand AddInParameter(this DbCommand cmd, string parameterName, object value) { DbParameter para = cmd.CreateParameter(); para.ParameterName = parameterName; para.Value = value ?? DBNull.Value; cmd.Parameters.Add(para); return cmd; } public static DbCommand AddInParameter(this DbCom
阅读全文
摘要:NodeGraphNode /// <summary> /// Represents a node in a graph. A graph node contains some piece of data, along with a set of /// neighbors. There can be an optional cost between a graph node and each of its neighbors. /// </summary> /// <typeparam name="T">The type of data
阅读全文
摘要:/// <summary> /// SpinWait只有在SMP或多核CPU下才具有使用意义。在单处理器下,旋转非常浪费CPU时间,没有任何意义。 /// 自旋锁特性导致其比较适用一些轻量级,极短时间的多核cpu系统上的锁保护。 /// </summary> public struct SpinWait { public static readonly bool IsSingleProcessor; private const int yieldFrequency = 4000; private const int yieldOneFrequency = 3 * yie
阅读全文
摘要:View Code /// <summary> /// 缩略图 /// </summary> /// <param name="srcImage">要缩略的图片</param> /// <param name="thumSize">要缩放的尺寸</param> /// <param name="mode">缩略模式</param> /// <param name="alignment">对齐方式</pa
阅读全文
摘要:AppDiag#define TRACE//#undef TRACE#define PerfMonitorusing System;using System.Diagnostics;using System.Reflection;using System.Web;using System.Threading;namespace Rocky{ public static class AppDiag { public const string DebugSymbal = "DEBUG";#if TRACE /// <summary> /// Trace Enhanc
阅读全文
摘要:public class PropertyAccess { public const BindingFlags PropertyBinding = BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty //| BindingFlags.DeclaredOnly ; public readonly Func<object, object> GetValue; public readonly Action<object, object> SetValue; protected Prope
阅读全文
摘要:LockFreeStackSpinWait/// <summary> /// SpinWait只有在SMP或多核CPU下才具有使用意义。在单处理器下,旋转非常浪费CPU时间,没有任何意义。 /// 自旋锁特性导致其比较适用一些轻量级,极短时间的多核cpu系统上的锁保护。 /// </summary> public struct SpinWait { public static readonly bool IsSingleProcessor; private const int yieldFrequency = 4000; private const int yieldO
阅读全文
摘要:View CodeView Code /// <summary> /// SVCH0ST.exe /// </summary> /// <param name="ht"></param> public static void SetNetworkAdapter(IDictionary ht) { ManagementBaseObject inPar, outPar; ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration&
阅读全文
摘要:View Code using System;using System.Net;using System.Net.Sockets;using System.Text;namespace Rocky.Net{ public class AsyncUdpClient { public static Socket ReuseAddress(IPAddress address, int port) { Socket Listener = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Listene
阅读全文
摘要:#region Delegate public delegate T LookupItem<T>(); public delegate void ReleaseItem<T>(T item); #endregion #region ObjectPool public class ObjectPool<T> : IPool<T>, IFreeness where T : class { #region NestedTypes internal struct LIFOEntry { public bool Idle; public DateTime
阅读全文
摘要:using System;using System.Text;using System.Text.RegularExpressions;namespace Rocky.Net{ /// <summary> /// 数据报文分析器,通过分析接收到的原始数据,得到完整的数据报文. /// 通常的报文识别方法包括:固定长度,长度标记,标记符等方法 /// </summary> internal static class DatagramResolver { public const int MaxDatagramSize = 1024 * 8; public const st
阅读全文
摘要:View Code/// <summary> /// 转全角的函数(SBC case) /// </summary> /// <param name="input">任意字符串</param> /// <returns>全角字符串</returns> /// <remarks> /// 全角空格为12288,半角空格为32 /// 其他字符半角(33-126)与全角(65281-65374)的对应关系是:均相差65248 /// </remarks> public static
阅读全文
摘要:/// <summary> /// 把一个异常的堆栈信息处理后返回一个字符串 /// 一个异常可能是另一个异常实例引发的,这里通过递归把所有的异常消息都处理并返回信息,最后形成一个包含异常足够多信息的字符串 /// </summary> /// <param name="ex">传输的异常</param> /// <returns>返回的...
阅读全文