随笔分类 - 代码收藏
摘要:public static class API { /// <summary> /// 创建有序的 guid。 /// </summary> /// <returns></returns> public static Guid NewSequentialGuid() { Guid result; UuidCreateSequential(out result); return result; } /// ...
阅读全文
摘要:[TestFixture] public class CompareHelperTest { private class C { public String P1 { get; set; } public Int32 P2 { get; set; } } [Test] public void testPropertiesEqual() { C c1 = new C(); c1.P1 = "a"; ...
阅读全文
摘要:/// <summary> /// Time 结构表示一天中的某个时间点,精确到秒。与 DateTime 不同,Time 结构不包含日期部分。 /// </summary> [Serializable] public struct Time : ISerializable, IXmlSerializable { private int _hour; private int _minute; private int _second; /// <summary> /// 从 TimeSpan...
阅读全文
摘要:/// <summary> /// 基于 ProtectedData 实现的加密解密字符串,可以跨windows用户使用,但是不能跨计算机使用 /// </summary> public static class EncryptHelper { public static string Encrypt(string stringToEncrypt) { byte[] toEncrypt = UnicodeEncoding.UTF8.GetBytes(stringToEncrypt); Mem...
阅读全文
摘要:// 代码来自 http://blog.csdn.net/ojekleen/archive/2008/08/01/2754255.aspx // 有修改 public class ThumbnailGenerator { /// <summary> /// 从源图像生成缩略图 /// </summary> /// <param name="source"></param> /// <param ...
阅读全文
摘要:针对数据访问代码的单元测试处在一个尴尬的位置上,如果操作不是针对真实的数据库执行的,就无法捕获数据库特定的错误,比如 sql 语句语法是否正确,操作是否违反了数据库约束,事务是否正确提交。并且,测试之间应该是隔离的,一个测试不能影响另一个测试的数据,就是说,每个测试运行之前都要重建表结构,重新安装测试数据。在一个真实的数据库上执行这些操作会让测试成为老牛破车。所幸的是Sqlite提供了内存数据库,避免磁盘IO可以带来性能提升。内存数据库有一个非常重要的特点:即数据库仅在连接打开的时候存在,一旦连接关闭,数据库随即消失。这正是我们想要的,运行测试的步骤如下:1,在 [TestInitialize
阅读全文
摘要:代码摘自 http://topic.csdn.net/u/20101231/09/039bdd22-3f0a-4bbb-908e-d887b4d7bbfe.html?19933public static class Util{ // <summary> /// 检查身份证信息是否合法 /// 2010-10-13 jorln /// </summary> /// <param name="num">身份证号</param> /// <param name="sex">性别</param&g
阅读全文
摘要:public static class Util{ /// <summary> /// MBD compact method (c) 2004 Alexander Youmashev /// !!IMPORTANT!! /// !确保调用此方法前要压缩的数据库没有打开的连接,为防止万一,应在压缩前进行备份。 /// !!IMPORTANT!! /// </summary> /// <param name="connectionString">到源数据库的连接字符串,源数据库是指要压缩的数据库</param> /// <p
阅读全文
摘要:摘自 http://topic.csdn.net/u/20101231/09/039bdd22-3f0a-4bbb-908e-d887b4d7bbfe.html?19933"^\d+$" //非负整数(正整数 + 0)"^[0-9]*[1-9][0-9]*$" //正整数"^((-\d+)|(0+))$" //非正整数(负整数 + 0)"^-[0-9]*[1-9][0-9]*$" //负整数"^-?\d+$" //整数"^\d+(\.\d+)?$" //非负浮点数(正浮点数
阅读全文
摘要:/*----------------*//*** DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)*/// Declaring valid date character, minimum year and maximum yearvar dtCh= "/";var minYear=1900;var maxYear=2100;function isInteger(s){ var i; for (i = 0; i < s.length; i
阅读全文
摘要:可以在 Medium Trust Level 下运行的配置声明配置节<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" requirePermission="false"/>配置 <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <bytecode-pr
阅读全文
摘要:Process open = new Process();open.StartInfo.FileName = "explorer";open.StartInfo.Arguments = @"/select," + location;open.Start();
阅读全文
摘要:/// <summary> /// Rar 是调用 rar 命令行的工具。 /// </summary> public class Rar { /// <summary> /// /// </summary> /// <param name="rarCommandPath">rar命令行工具在路径,例如:"C:\Program Files\WinRAR\rar.exe"</param> public Rar(string rarCommandPath) { this._RarComm
阅读全文
摘要:<script type="text/javascript"> // // javascript 判断一个数字是不是身份证号 // 代码摘自 http: //topic.csdn.net/u/20110102/22/e79df4e8-7b0a-4c65-9490-1ef39837ff36.html?8841 function isChinaIDCard(StrNo) { StrNo = StrNo.toString() if (StrNo.length == 18) { var a, b, c if (!isInteger(StrNo.substr(0, 17)
阅读全文
摘要:代码从csdn复制,未做测试public static class ChineseNumberUtil{ /// <summary> /// 将中文数字转换成阿拉伯数字 /// </summary> /// <param name="cnNumber"></param> /// <returns></returns> static int ConverToDigit(string cnNumber) { int result = 0; int temp = 0; foreach (char c in c
阅读全文
摘要:using System;using System.Text;using System.IO;using System.Linq;using System.Net;/// <summary>/// 实用工具类。这个类支持以get和post方法读取网页, 支持代理和cookie/// </summary>public class PageLoader{ public string _proxy = null; public string Proxy { get { return _proxy; } set { _proxy = value; } } class Trust
阅读全文
摘要:支持 info.A.B.C 这样的排序表达式 /// <summary> /// 在 linq 查询中使用字符串表达式进行排序 /// </summary> public static class OrderByStringExpressionExtensions { public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string property) { return ApplyOrder<T>(source, property
阅读全文
摘要:namespace ExtensionMethods{ using System; using System.Collections.Generic; using System.Linq; public static class IEnumerableExtensions { /// <summary> /// Invokes a transform function on each element of a sequence and returns the minimum Double value /// if the sequence is not empty; otherwi
阅读全文
摘要:select id from infoid-----------123567810111215(11 行受影响)方法一:select (select max(id)+1 from Info where id<a.id) as beginId,(id-1) as endIdfrom Info awherea.id>(select max(id)+1 from Info where id<a.id)beginId endId----------- -----------4 49 913 14(3 行受影响)方法二:select beginId,(select min(id)-1
阅读全文
摘要:摘自 http://www.cnblogs.com/ejiyuan/archive/2009/07/20/1527224.html[代码]
阅读全文