Afterthought 原来是这样的啊。。。。

image

 

 

$(ProjectDir)Libs\Afterthought\Afterthought.Amender.exe "$(TargetPath)" "$(TargetDir)EntityFramework.Patterns.dll"

我实际上分析代码好久,也没整明白它是怎么运行的,看一下官方文档明白了,原来。。。

 

Next, add the following as a post build step to your project to call the Afterthought Amender executable:

$(SolutionDir)packages\Afterthought.1.0.8\tools\Afterthought.Amender.exe "$(TargetPath)"

Please note that the \Afterthought.1.0.8\ portion of the path should reflect the version of Afterthought that you are using. You can also use the Amender build task in your project, but this requires manually editing the project to add this task. Since NuGet currently does not support modifying the project file directly in this way, Afterthought does not automatically configure itself to run for referenced projects.

If you instead chose to go the source route, simply configure your target project to call Afterthought.Amender.exe referencing the compiled output of the `Afterthought.Amender' project. Also, you can debug the amendment process by configuring the 'Afterthought.Amender' project to amend your target assembly and run this project in debug mode.

原来在事件后期执行这样的一个操作。

根据我们一直的习惯,直接在代码中解决问题的,但是这个工具是先编译通过,然后通过一个EXE程序来修改程序集,以达到效果。

然后修改的程序集你再用ILSpay看,会发现,

原始代码:

 
    [Auditable]
    public class AuditableEntity
    {
        public int Id { get; set; }
        public string Color { get; set; }
    }

 

Afterthought 以后,从ILSpay看到的代码,这一刻一切都明了了。。

using EntityFramework.Patterns.Extensions;
using System;
namespace EntityFramework.Patterns.Tests
{
    [Archivable]
    public class ArchivableEntity : IArchivable
    {
        string <DeletedBy>k__BackingField;
        DateTime? <Deleted>k__BackingField;
        public int Id
        {
            get;
            set;
        }
        public float Value
        {
            get;
            set;
        }
        public string DeletedBy
        {
            get
            {
                return this.<DeletedBy>k__BackingField;
            }
            set
            {
                this.<DeletedBy>k__BackingField = value;
            }
        }
        public DateTime? Deleted
        {
            get
            {
                return this.<Deleted>k__BackingField;
            }
            set
            {
                this.<Deleted>k__BackingField = value;
            }
        }
    }
}

 

 

然后,再看

[AttributeUsage(AttributeTargets.Assembly)]
  public class AmendAttribute : Attribute, IAmendmentAttribute
  {
      IEnumerable<ITypeAmendment> IAmendmentAttribute.GetAmendments(Type target)
      {
          if (target.GetCustomAttributes(typeof(AuditableAttribute), true).Length > 0)
          {
              ConstructorInfo constructorInfo = typeof (AuditableAmender<>).MakeGenericType(target).GetConstructor(Type.EmptyTypes);
              if (constructorInfo != null)
                  yield return (ITypeAmendment) constructorInfo.Invoke(new object[0]);
          }
          if (target.GetCustomAttributes(typeof(ArchivableAttribute), true).Length > 0)
          {
              ConstructorInfo constructorInfo = typeof(ArchivableAmender<>).MakeGenericType(target).GetConstructor(Type.EmptyTypes);
              if (constructorInfo != null)
                  yield return (ITypeAmendment)constructorInfo.Invoke(new object[0]);
          }
      }
  }

 

再看,

[assembly: Amend]

 

这家伙,通过在编译完成后,修改了程序,只要实现了IAmendmentAttribute , 那个exe 就知道了。随后一个字,更改dll文件啊,。。。,它就改了。 所以 也就是上个文件中 [pure] 也就有用了, maybe .net framework 了。

所以debug的时候,跟不到断点也是正常的了。因为你的程序已经对应的不是原来的代码了。

用一句歌词说: 我还是原来的我。 但程序集已经不是原来的程序集了。

当然,我说的断点是

  public class AmendAttribute : Attribute, IAmendmentAttribute

中的断点。

转载于:https://www.cnblogs.com/zbw911/archive/2013/02/06/2907651.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/260023.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

查询

增加文本1. create database test删除文本2. drop database test3. create table info( code int primary key, name varchar(20) not null)auto_increment 自增长列foreign key(列名) references 主表名(列名) 外键关系4. drop table infoCRUD:增加语法1.insert into 表…

android 监听界面变化,Android之页面有变化用onWindowFocusChanged来监听权限是否开启...

1 问题我们需要在Activity里面监听网络变化、热点是否开启和关闭、GPS服务是否开启、位置权限是否开启等一些列行为。2 思路方法一&#xff1a;如果是需要启动activity进行权限申请&#xff0c;我们可以用如下组合模式var intent Intent(Settings.ACTION_LOCATION_SOURCE_SETT…

逐步优化求解最大子序列和

求解最大子序列和 tag&#xff1a; 数据结构与算法 最大子序列和问题&#xff1a; 给定序列A1, A2&#xff0c;... AN&#xff0c; 求最大的子序列和。 例如 &#xff1a;   对于序列4, -3, 5, -2, -1, 2, 6, -2&#xff0c; 最大序列和为11&#xff08;4 -3 5 - 2 - 1 2 …

POJ 1228 —— “稳定”凸包

POJ 1228 Grandpas Estate 这是个好题目&#xff0c;同时也是个不和谐的题目&#xff08;不和谐原因是题目出的存在漏洞&#xff0c;数据弱&#xff0c;而且有些条件没给清楚&#xff0c;为了一个SB错误无限WA之后&#xff0c;终于AC&#xff09; 题意就废了我好长时间&#xf…

pythonflaskmock数据_Flask实现简单Mock Server

Mock Server充当的角色&#xff1a;Mock server在实际项目中的意义就相当于数据库。将我想要的数据返回给我就行&#xff0c;我并不关心你怎么逻辑处理的。一般的应用程序请求方式是GET和POST。Flask自带的request使用:request.url获取当前的请求url全路径地址&#xff0c;requ…

在Application_Error事件中获取当前的Action和Control

ASP.NET MVC程序处理异常时&#xff0c;方法有很多&#xff0c;网上也有列举了6种&#xff0c;下面是使用全局处理在Global.asax文件的Application_Error事件中实现。既然是ASP.NET MVC,我需要捕捉到Controller和Action名称。怎样实现可以参考下面代码&#xff1a; 程序运行结果…

android 真机 sqlite3,在android真机上使用sqlite3

#zijun#2013.10.29#QQ:223663737在android真机上使用sqlite3前期准备:1:保证手机已经ROOT操作步骤:1 : 打开CMD2 : 进入android linuxadb shell3 :切换到root权限su - root4 : 修改system目录为可读写权限mount -oremount,rw -t yaffs2 /dev/block/mtdblock3 /system5 :拷贝文件…

【ORACLE技术嘉年华PPT】MySQL压力测试经验

这是2013.11.18在第三届ORACLE技术嘉年华上的主题演讲PPT。点击这里&#xff1a;本地下载PPT。--------------------------------------分割线--------------------------------------知数堂 &#xff08;http://zhishuedu.com&#xff09;培训是由资深MySQL专家叶金荣、吴炳锡…

EditText 空指针问题

今天在Android中碰到了这样一个问题&#xff0c;其实应该很少人会碰到&#xff0c;因为只有像我这种奇葩才会犯这种错误。 但既然解决了&#xff0c;我就想在这里跟大家分享一下&#xff0c;毕竟它困扰了我一个白天啊。。。不多说了&#xff0c;看下面。。。 其实问题很简单&am…

ios跨线程通知_iOS多线程开发(三)---Run Loop(一)

Run LoopRun Loop就是一个事件处理的循环&#xff0c;用来不停的调动工作以及处理输入事件。使用Run Loop的目的就是节省CPU效率&#xff0c;线程在有工作的时候忙于工作&#xff0c;而没工作的时候处于休眠状态。一&#xff0c;Run Loop剖析Structure of a Run Loop and its s…

android播放flv,Android:从url播放flv视频流

我目前有一个应用程序&#xff0c;它可以记录视频并将其上传到我的服务器。在上传视频之后&#xff0c;应用程序会获得一个响应&#xff0c;该响应包含指向该文件的flv流的URL。Android&#xff1a;从url播放flv视频流当我尝试在android默认视频播放器(视频)中打开流时什么也没…

1.关于浏览器

一、认识主流浏览器 Chrome谷歌浏览器Safari苹果浏览器Firefox火狐浏览器Opera欧朋浏览器 二、浏览器内核是什么&#xff1f; 三、五大浏览器&#xff0c;四大内核 四、前端做网页开发用什么浏览器&#xff1f; Chrome谷歌浏览器。

About me [my way]

就要除夕了。假日的到来&#xff0c;心情瞬间就闲适了下来。早早上了床&#xff0c;看看电脑还有30%的电&#xff0c;想到一些事情&#xff0c;顺带纪录一下吧。 今年坚持上班到了除夕的前一天&#xff0c;爸妈来工作的城市陪我过年了。感谢他们。前几天就已经看帖子有说仍在上…

明天要中秋节了,先来到简单“类”的题目

2-1 Point类的定义 Time Limit: 1000MS Memory limit: 65536K 题目描述 通过本题目的练习可以掌握类与对象的定义&#xff1b; 设计一个点类Time&#xff0c;它具有私有数据成员x(横坐标)、y(纵坐标)&#xff1b;公有成员函数&#xff1a;SetPoint(int,int)用于设置点对象的值&…

实时数据交换平台 - BottledWater-pg with confluent

标签 PostgreSQL , Bottled Water , Kafka , Confluent , IoT 背景 想必大家都在图书馆借过书&#xff0c;小时候有好看的书也会在小伙伴之间传阅。 借书和数据泵有点类似&#xff0c;一份数据通过数据泵实时的分享给订阅者。 例如在IoT的场景中&#xff0c;有流式分析的需求&a…

科技鸿蒙系统一千章,第一千六百零七章 鸿蒙紫气,成圣之机 (上)

文学迷 > 玄幻魔法 > 天命神相 > 第一千六百零七章 鸿蒙紫气&#xff0c;成圣之机 (上)第一千六百零七章 鸿蒙紫气&#xff0c;成圣之机功德金身只要达到了八十一重天&#xff0c;大圆满的境界&#xff0c;实力堪混元大罗级别的圣人&#xff0c;这听起来确实是一件吊炸…

js reduce实现中间件_js数组高阶方法reduce经典用法代码分享

以下是个人在工作中收藏总结的一些关于javascript数组方法reduce的相关代码片段&#xff0c;后续遇到其他使用这个函数的场景&#xff0c;将会陆续添加&#xff0c;这里作为备忘。javascript数组那么多方法&#xff0c;为什么我要单挑reduce方法&#xff0c;一个原因是我对这个…

struts2的s:iterator 标签 详解

struts2的s&#xff1a;iterator 可以遍历 数据栈里面的任何数组&#xff0c;集合等等 以下几个简单的demo&#xff1a;s:iterator 标签有3个属性&#xff1a; value&#xff1a;被迭代的集合 id &#xff1a;指定集合里面的元素的id status 迭代元素的索引1:jsp…

Protocol Buffers的应用

1. Protocol Buffers的介绍 Protocol buffers are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then …

编程提高:一天一道编程题

1.文本操作 逆转字符串——输入一个字符串&#xff0c;将其逆转并输出。 拉丁猪文字游戏——这是一个英语语言游戏。基本规则是将一个英语单词的第一个辅音音素的字母移动到词尾并且加上后缀-ay&#xff08;譬如“banana”会变成“anana-bay”&#xff09;。可以在维基百科上了…