パブリック プロパティ セッター (標準プロパティと自動実装プロパティ) のみをインターセプトするための spring.net のポイントカット定義を知っていますか?
この後、名前 (ID、バージョンなど) でいくつかのプロパティを削除する方法はありますか?
ポイントカットを特定の基本クラス (EntityBase) の子に絞り込むことは可能ですか?
ご覧のとおり、私は spring.net ポイントカットの達人ではありません ^^ しかし、情報が見つかりません。
その背後にあるアイデアは、自動ダーティ フラグを作成することです。以下の例では、データ プロパティ セッターに対してのみ IsDirty = True を設定することを目標としています。
今のところ、Spring 構成ファイルではなくコードで定義を使用していますが、両方のソリューションで問題ないと思います。
既存のコード:
[Serializable]
public class EntityBase
{
public string Id { get; set; }
public long Version { get; set; }
public bool IsDeleted { get; set; }
public bool IsDirty { get; set; }
}
[Serializable]
public class Entity : EntityBase
{
public string Data { get; set; }
}
public class DirtyInterceptor : IMethodInterceptor
{
#region IMethodInterceptor Members
public object Invoke(IMethodInvocation invocation)
{
object returnValue = invocation.Proceed();
((EntityBase)invocation.Target).IsDirty = true;
return returnValue;
}
#endregion
}
...
foreach (object item in keyCache.CachedModel.Values)
{
ProxyFactory factory = new ProxyFactory(item);
factory.AddAdvisor(new DefaultPointcutAdvisor (new SdkRegularExpressionMethodPointcut(???), new DirtyInterceptor()));
T ent = (T)factory.GetProxy();
returnList.Add(ent);
}