Thank you in advance for your help! (Yes, there is a question below)
I am using Unity 3.x Intersed to perform AOP pre and database connections and transaction activities. Database interceptor is always instantaneously and transaction interceptor via interactive interceptor is based on custom attachment matching array. I have properties that are being set in my TransactionAttribute:
[transaction (IsolationLevel.ReadUncommitted, NoRollbackFor = new [] {typeof (TestException)}) As an example I am using my unit test. I want them to enter my transaction callhandler class. I have seen the examples I have seen
on transactionAttribute = input.MethodBase.GetCustomAttribute & LT; TransactionAttribute & gt; (wrong); There is a way to reach it, even then my transaction void is zero. My conclusion is that interception proxy class is being examined for custom entry, not for original concrete instance.
For this, my job is to reflect back the level of class from all sides, what is the right way to get it and get a custom attribute from there.
var methods = input aim. GetType () .GetMethods (). Where (M => m.Name == input.MethodBase.Name). Where (M = & gt; M. GetCustomAttribute & lt; TransactionAttribute & gt; (Wrong)! = Null;); (There is another 30 lines to ensure that I do not access the wrong method name when loading additional method, so drag the display ...)
Then, after that, my question is, am I not refining correctly? ? There is a bug in the unity I should report
Here are my container definitions: container = new UnityContainer (); Container.AddNewExtension & LT; Blocking & gt; (); Container.RegisterType & LT; IMockUseDefaultConnectionString, MockUseDefaultConnectionString & gt; (New InterceptionBehavior & LT; PolicyInjectionBehavior & gt; (), New Interceptor & lt; InterfaceInterceptor & gt; (), New InjectionConstructor (New DatabaseSettings ()); Container. Registration Type & lt; IMockUseHardcodedConnectionString, MockUseHardCodedConnectionString & gt; (New Interception Brewery & Policy; Policy Injectionbearear & gt; (), New Interceptor & Interface Interface & gt; (), New Injection Connection (New Database Settings {ConnectionString = MockUseHardCodedConnectionString.ConnectionString}); / * IDatabaseSettings is not registered to handle the settings being used manually * / var first = new injection property ("order", 1); Var seconds = New injection property ("order", 2); Container .Configure & LT; Blocking & gt; () .AddPolicy ("DatabaseConnectionPolicy") .AddMatchingRule & LT; NamespaceMatchingRule & gt; (New InjectionConstructor ("MyNamespace *.", True)) .AddCallHandler & LT; DatabaseConnectionCallHandler & gt; (First); Container .Configure & LT; Blocking & gt; () .AddPolicy ("TransactionPolicy") .AddMatchingRule (New CustomAttributeMatchingRule (inherited in Typeof (TransactionAttribute, inherited: incorrect)) .AddCallHandler & LT; TransactionCallHandler & gt; (second); I think the behavior you see is one of the reasons for blocking methods. Is of design. When using the Interface Interceptor, a proxy object is created that implements the target interface, but the proxy object is an entirely different type of origin.
If you go with the Virtual Mindset receptor, which is a compatible type, then you should be able to get a custom attribute using its basic approach. Of course, the negative side of VirtualMethodInterceptor is that all methods of interception should be virtual.
No comments:
Post a Comment