1
我試圖找出Afterthought。我想在任何屬性設置器被調用時設置變量HasChanged。我有以下代碼如何用Afterthought實現簡單的Property Abmendment
public class TestUser
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public bool HasChanged { get; set; }
}
public class TestUserAmmendment<T> : Amendment<T, T> where T : TestUser
{
public TestUserAmmendment()
{
Properties
.Where(p => p.PropertyInfo.CanRead
&& p.PropertyInfo.CanWrite
&& p.PropertyInfo.GetSetMethod().IsPublic
&& p.Name != "HasChanged")
.AfterSet(instance.HasChanged = true);
}
}
但是我收到一個編譯器錯誤說The name 'Properties' does not exist in the current context
。我已經從單元測試中複製了代碼,我可以編譯和運行這些代碼。我不確定,但是有誰知道如何使用Afterthought來實現這個簡單的方面?
對不起,這麼厚,但我在哪裏可以得到版本1.0.8?我從這裏下載並編譯了代碼https://github.com/vc3/Afterthought.git,並且.dll的版本仍然顯示爲1.0.6。 – user10479 2012-03-30 14:42:17
我從NuGet獲得了我的副本。 – 2012-03-30 14:45:23
當我在NuGet中的版本信息是1.0.8,並且packages.config中的版本信息是1.0.8,但是,當我點擊References文件夾中的Afterthough.dll時,它說的是版本1.0.6.0,以及仍然不會編譯。 – user10479 2012-03-30 14:55:59