- 博客(46)
- 收藏
- 关注
原创 C# 中的扩展方法
1.是否有子元素public static bool HasElements(this ICollection items){ return items != null && items.Count > 0;}2.IsBetweenpublic static bool IsBetween(this T value, T low, T high) wher
2015-07-01 17:40:01
333
转载 SQL中使用WITH CTE
递归CTE最少包含两个查询(也被称为成员)。第一个查询为定点成员,定点成员只是一个返回有效表的查询,用于递归的基础或定位点。第二个查询被称为递归成员,使该查询称为递归成员的是对CTE名称的递归引用是触发。在逻辑上可以将CTE名称的内部应用理解为前一个查询的结果集。;WITH CTE AS ( SELECT * FROM Channel a WHERE 条件 UNION ALL
2015-03-05 11:27:27
923
转载 boost中的mutex与lock
基本用法:HANDLE g_mutex = NULL; void test() { ::WaitForSingleObject(g_mutex, INFINITE); //do something... ReleaseMutex(g_mutex); } 封装:class MyMutex { public: MyMutex()
2014-12-17 15:18:39
882
转载 [置顶] 完成端口(CompletionPort)详解 - 手把手教你玩转网络编程系列之三
手把手叫你玩转网络编程系列之三 完成端口(Completion Port)详解 ----- By PiggyXP(小猪)前 言 本系列里完成端口的代码在两年前就已经写好了,但是由于许久没有写东西了,不知该如何提笔,
2014-12-09 18:04:36
582
转载 WM_NOTIFY和ON_NOTIFY macro及OnNotify虚函数
WM_NOTIFY是子控件用来向父窗体发送信息的消息,其参数一般以NMHDR结构来封装,例如 NMHDR nmh; memset(&nmh,0,sizeof(NMHDR)); nmh.hwndFrom = GetSafeHwnd(); nmh.idFrom = GetDlgCtrlID();
2014-11-26 13:40:55
439
原创 JS集锦
1 .$(".tt-item .cf>li").each(function () { if ($('a', this).hasClass("current")) { var indexr0 = $(".tt-item .cf>li").index(this); saveTabIndexa
2014-11-10 10:14:37
302
转载 String.Format in JavaScript
JavaScript String.Format // This is the function. String.prototype.format = function (args) { var str = this; return str.replace(String.prototype.format.regex, function(item) { var
2014-11-10 09:24:10
306
转载 模板在EventHandler 和EventArgs的应用
1.public class ItemEventArgs : EventArgs{ public ItemEventArgs(T item) { Item = item; } public T Item { get; protected set; }}
2014-11-07 15:26:37
292
转载 Generic Thread Start
// ParameterizedThreadStart.cspublic delegate void ParameterizedThreadStart(T value); // ParameterizedThread.csusing System.Threading; public class ParameterizedThread{ private Parameterize
2014-11-07 14:46:46
398
转载 Using C# 2.0 Generics to achieve a reusable Singleton pattern
一般代码: public sealed class Singleton { Singleton() { } public static Singleton Instance { get { return Singleto
2014-11-07 14:15:14
268
翻译 用"dynamic" 使 PInvoke 更简单
代码:dynamic user32 = new DynamicDllImport("user32.dll", callingConvention : CallingConvention.Winapi);user32.MessageBox(0, "Hello World", "Platform Invoke Sample", 0);
2014-11-07 09:31:19
247
翻译 同步更新缓存数据
标准的缓存机制,开发者需要填充它然后它自动无效后内容过期。在随后的方法缓存机制将自动填充以及自动失效。从编码器的角度来看,你将有权使用模式来检索数据并提供一种方法,当其寿命。换句话说,机制转换为一个抽象方法的抽象类的下面:
2014-11-06 13:16:26
339
翻译 数据缓存
数据从一个存储库获得完全可以从性能的角度来看一个“重”的任务,尤其是当数据库位于远t应用服务器(例如,Web服务调用,调用,远程处理等)或一些特定的数据是经常访问。因此,为了减少数据检索工作量及时间,你可以使用一个缓存功能。
2014-11-06 10:04:31
326
转载 Sqlite使用事务插入数据
using System.Data;using System.Data.Common;using System.Data.SQLite;// 创建数据库文件File.Delete("test1.db3");SQLiteConnection.CreateFile("test1.db3");DbProviderFactory factory = SQLiteFactory.Instan
2014-11-04 16:53:36
1116
转载 var 与 dynamic的不同
vardynamicIntroduced in C# 3.0Introduced in C# 4.0Statically typed – This means the type of variable declared is decided by the compiler at compile time.Dynamical
2014-11-04 11:35:35
324
转载 .Net and C# release history
.Net Version Release history.Net VersionRelease DateToolFeature1.02002Visual Studio .NetFirst release of .net1.12003Visual Studio 2003Suppor
2014-11-04 11:16:50
387
翻译 Func用法
What is Func?Func in short is parameterized delegate. In C#, a delegate instance points towards a method. When a caller invokes the delegate, it calls its target method. This way, the caller i
2014-11-04 09:29:07
1801
翻译 Emit with a human face
IntroductionThe System.Reflection.Emit namespace provides classes to create dynamic assemblies at runtime. It allows compilers and tools to emit MSIL, execute it and store it to a disk. Although
2014-11-03 10:21:39
399
翻译 创建自定义用户登录 ( MVC 4 Razor)
原文地址:http://www.codeproject.com/Articles/482546/Creating-a-custom-user-login-form-with-NET-Csharp
2014-11-03 09:28:45
574
翻译 代替Activator.CreateInstance
我发现 that the quickest way to instantiate an object with a default constructor through Reflection is by using the DynamicMethod class. Below is a helper class I wrote to easily instantiate an objec
2014-11-03 09:07:32
451
翻译 ExportAttribute, ImportAttribute, CompositionContainer and MEF in ASP.NET MVC 3
Introduction
2014-11-02 22:04:48
1686
转载 C# Lazy<T>(转)
1. Lazy 概述我们也许会遇到这样一种情况,我们有一个大家伙(大对象)需要创建,那么这个对象的创建时需要较长的时间,同时也需要在托管堆上分配较多的空间。那么在.NET Framework 4 中提供了这样一个很聪明的方式:Lazy(我们可以称之为懒对象)。当然,在之前,很多人也曾对其进行过自己的实现。那么我们在这里就可以把 Lazy 的作用总结为一句话,按需延迟加载。
2014-11-02 21:21:09
406
原创 SQL集锦
select ROW_NUMBER() over(order by id asc) as 'rowNumber', * from table1 生成带序号的集合2:再查询该集合的 第 1 到第 5条数据 select * from (select ROW_NUMBER() over(order by id asc) as 'rowNumber', *
2014-10-31 11:23:27
242
原创 SQLite连接字符串
Data Source=filename;Version=3;Pooling=False;Max Pool Size=100;
2014-10-30 09:01:46
1675
翻译 Using SQLMetal code generator tool for LINQ to SQL
SQLMetal这是一个代码生成工具由微软基于LINQ的发展援助。该工具只建立编码和映射,您就不必手工。除非你有Visual Studio 2008集成开发环境。即使是这样的一个拖放表和其他数据库对象的LINQ to SQL环境。在一个开发团队工作时,由DBA或其它开发商数据库的变化将需要纳入你的开发环境。你将需要删除并重新创建每个数据库对象的LINQ每次更改SQL环境。不用说,这将成为执
2014-10-29 16:15:45
423
转载 无边窗体在任务栏上的系统菜单
我们可能会用到一个没有边框的窗体,因为这样我们可以在整个窗体上自由的绘制。然后我们也会发现一个讨厌的问题,这个时候在任务栏上鼠标右键点不出那可爱的系统菜单了。这样会不好,会使得用户感觉到没有道理,为什么别的窗口都有系统菜单,而只有我们的窗体没有系统菜单呢? 其实如果我们使用VC建立MFC程序的时候,我们可以把窗体的“Title Bar”设置为False,这样MFC的窗口就是无标题的,然而
2014-10-29 14:42:56
460
原创 js调用winform公共方法
1.给form加上[System.Runtime.InteropServices.ComVisible(true)]
2014-10-24 09:44:14
441
原创 设计模式
Creational PatternsFactory - This pattern is used to create concrete class instances without specifying the exact class type. Abstract Factory - This pattern is used to create concrete class
2014-10-22 14:45:03
231
翻译 JavaScript patterns simplified--javascript模式
Adapter Design Pattern in C#介绍
2014-10-22 13:28:03
325
转载 将Log4net的配置配置到的独立文件中
在独立的配置文件中只需要修改几个地方就能完成:1. 新建一个配置文件,log4net.config配置方法同成web.config或app.config一致;2.如果windows应用程序请把配置文件设为:复制到输出目录 修改方法:在log4net.config上右击-->属性--->把"复制到输出目录" 值改为true; 3.在要用到log4的地方命名空间上边加上:[as
2014-10-20 11:36:25
287
原创 Log4net.config配置文件
<!-- .NET application configuration file This file must have the exact same name as your application with .config appended to it. For example if your applicatio
2014-10-20 11:13:28
530
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人