iinterceptor

Intercept Properties With Castle Windsor IInterceptor

只愿长相守 提交于 2020-01-02 07:39:37
问题 Does anyone have a suggestion on a better way to intercept a properties with Castle DynamicProxy? Specifically, I need the PropertyInfo that I'm intercepting, but it's not directly on the IInvocation, so what I do is: public static PropertyInfo GetProperty(this MethodInfo method) { bool takesArg = method.GetParameters().Length == 1; bool hasReturn = method.ReturnType != typeof(void); if (takesArg == hasReturn) return null; if (takesArg) { return method.DeclaringType.GetProperties() .Where

NHibernate and interceptors - measuring/monitoring SQL round-trip times

本秂侑毒 提交于 2019-12-31 02:18:26
问题 In order to get early-warning of a slow or potentially slow areas, I'd like to have an Interceptor for NHibernate that can act as a performance monitor, so that any database operation that takes more than a given time raises an event and (importantly) a full stacktrace into the application's logs. Interceptors seemed to be a good window into this. However, having experimented, there doesn't seem to be anyway to catch a "just-back-from-SQL" event: OnPreFlush and OnPostFlush work on full

NHibernate add unmapped column in interceptor

时光怂恿深爱的人放手 提交于 2019-12-23 03:42:09
问题 I'm trying to save a mapped entity using NHibernate but my insert to the database fails because the underlying table has a column that does not allow nulls and IS NOT mapped in my domain object. The reason it isn't mapped is because the column in question supports a legacy application and has no relevance to my application - so I'd like to not pollute my entity with the legacy property. I know I could use a private field inside my class - but this still feels nasty to me. I've read that I can

NHibernate add unmapped column in interceptor

三世轮回 提交于 2019-12-23 03:42:03
问题 I'm trying to save a mapped entity using NHibernate but my insert to the database fails because the underlying table has a column that does not allow nulls and IS NOT mapped in my domain object. The reason it isn't mapped is because the column in question supports a legacy application and has no relevance to my application - so I'd like to not pollute my entity with the legacy property. I know I could use a private field inside my class - but this still feels nasty to me. I've read that I can

Register an Interceptor with Castle Fluent Interface

跟風遠走 提交于 2019-12-10 10:46:41
问题 I am trying to implement nhibernate transaction handling through Interceptors and couldn’t figure out how to register the interface through fluent mechanism. I see a Component.For<ServicesInterceptor>().Interceptors but not sure how to use it. Can someone help me out? This example seemed a little complex. 回答1: You do it in two steps: You need to register the interceptor as a service in the container: container.Register(Component.For<MyInterceptor>()); You register the component you want to

NHibernate add unmapped column in interceptor

我与影子孤独终老i 提交于 2019-12-06 22:06:31
I'm trying to save a mapped entity using NHibernate but my insert to the database fails because the underlying table has a column that does not allow nulls and IS NOT mapped in my domain object. The reason it isn't mapped is because the column in question supports a legacy application and has no relevance to my application - so I'd like to not pollute my entity with the legacy property. I know I could use a private field inside my class - but this still feels nasty to me. I've read that I can use an NHibernate interceptor and override the OnSave() method to add in the new column right before

Intercept Properties With Castle Windsor IInterceptor

爷,独闯天下 提交于 2019-12-05 20:40:58
Does anyone have a suggestion on a better way to intercept a properties with Castle DynamicProxy? Specifically, I need the PropertyInfo that I'm intercepting, but it's not directly on the IInvocation, so what I do is: public static PropertyInfo GetProperty(this MethodInfo method) { bool takesArg = method.GetParameters().Length == 1; bool hasReturn = method.ReturnType != typeof(void); if (takesArg == hasReturn) return null; if (takesArg) { return method.DeclaringType.GetProperties() .Where(prop => prop.GetSetMethod() == method).FirstOrDefault(); } else { return method.DeclaringType

Castle Interceptors With Fluent Interface

廉价感情. 提交于 2019-11-28 06:31:31
问题 I'm trying to get an interceptor I've written to work, but for some reason it doesn't seem to be instantiating the interceptor when I request my components. I'm doing something like this (forgive me if this doesn't quite compile, but you should get the idea): container.Register( Component.For<MyInterceptor>().LifeStyle.Transient, AllTypes.Pick().FromAssembly(...).If(t => typeof(IView).IsAssignableFrom(t)). Configure(c => c.LifeStyle.Is(LifestyleType.Transient).Named(...). Interceptors(new