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.pswp.cn/news/260023.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/260023.shtml
英文地址,請注明出處:http://en.pswp.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;。可以在維基百科上了…