自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(0)
  • 资源 (6)
  • 收藏
  • 关注

空空如也

[干货][EMIT]千行代码实现代理式AOP+属性的自动装配 V2.0

千行代码实现代理式AOP+属性的自动装配 V2.0 1、修复属性的植入逻辑 2、优化初始化结果的IL指令

2016-08-03

[干货][EMIT]千行代码实现代理式AOP+属性的自动装配

千行代码实现代理式AOP+属性的自动装配

2016-08-01

Emit实现从URL或者表单中创建对象

Emit实现从URL或者表单中创建对象。 可通过前缀实现创建多对象。 性能高效,实用性高。

2015-03-24

解析CSV格式文件示例源码

C#解析CSV格式文件示例源码,内有详细注释哦

2012-10-26

不用正则,60行代码搞定高效Url重写

private void context_BeginRequest(object sender, EventArgs e) { HttpApplication app = sender as HttpApplication; if (app == null) return; string currentUrl = app.Context.Request.RawUrl; if (currentUrl.EndsWith(URL_SUFFIX, StringComparison.OrdinalIgnoreCase) == false) //后缀不符合的跳过 return; int p = currentUrl.IndexOf(URL_FLAG, StringComparison.OrdinalIgnoreCase); //无参的也跳过 if (p == -1) return; currentUrl = currentUrl.Substring(0, currentUrl.Length - URL_SUFFIX.Length); //去除后缀 string url = string.Format("{0}.aspx", currentUrl.Substring(0, p)); string query = FormmatUrlToQuery(currentUrl.Substring(p + URL_FLAG.Length)); app.Context.RewritePath(url, string.Empty, query); }

2011-08-17

Emit实现AOP示例

纯手工打造Emit实现AOP private static void OverrideMethods(TypeBuilder tb, MethodInfo method) { if (!method.IsPublic|| !method.IsVirtual || IsObjectMethod(method)) return; Type[] paramTypes = GetParameterTypes(method); MethodAttributes attr = MethodAttributes.Public | MethodAttributes.Family | MethodAttributes.HideBySig | MethodAttributes.Virtual; MethodBuilder mb = tb.DefineMethod(method.Name, attr, method.ReturnType, paramTypes); LocalBuilder result = null; ILGenerator il = mb.GetILGenerator(); bool is_void = method.ReturnType != typeof(void); if (is_void == false) result = il.DeclareLocal(method.ReturnType); object[] attrs = method.GetCustomAttributes(typeof(AspectAttribute), false); if (attrs != null) { //初始化所有当前方法用到的参数object[] CreateLocalParameterArr(il, paramTypes); //初始化AspectContext Type ctxType = typeof(AspectContext); ConstructorInfo info = ctxType.GetConstructor(Type.EmptyTypes); var ctx = il.DeclareLocal(ctxType); il.Emit(OpCodes.Newobj, info); il.Emit(OpCodes.Stloc, ctx); //给AspectContext的参数值属性ParameterArgs赋值 var propMethod = ctxType.GetMethod("set_ParameterArgs"); il.Emit(OpCodes.Ldloc, ctx); il.Emit(OpCodes.Ldloc_0); il.Emit(OpCodes.Call, propMethod); int m = attrs.Length; LocalBuilder[] lbs = new LocalBuilder[m]; MethodInfo[] endInvokeMethods = new MethodInfo[m]; //初始化标记的横切对象,并调用横切对象的BeforeInvoke方法 for (int i = 0; i < m; i++) { var tmpType = attrs[i].GetType(); var aspect = il.DeclareLocal(tmpType); ConstructorInfo tmpInfo = tmpType.GetCon

2011-07-14

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除