castle-dynamicproxy

How can I write Interceptor (AOP) with Castle Core or Other libraries (just free libraries) for Cross Cutting Concerns

瘦欲@ 提交于 2019-12-25 01:44:09
问题 I want to have an attribute like this for Cross Cutting Concerns like Logging , Exception , ... public class MyService { [Log] // Interception (AOP) [ExceptionHandler] // Interception (AOP) public void DoSomething() { } } I know that I can write these codes with postsharp but I want to write these interceptions with free libraries like Castle Core and ... Can anyone help me and write a sample for these purpose ??? I need a very simple sample for learning concepts 回答1: Autofac is a free IoC

Could not load type Castle.Proxies.IReadinessProxy when running xUnit integration tests in parallel with Autofac

和自甴很熟 提交于 2019-12-25 01:18:28
问题 I am having an issue that I've been many days unable to resolve. I use xUnit with a given-then-when abstraction to make tests more readable. I am using a wrapper over EventStore and running some integration tests. They all go well.. except one that fails when running all in parallel (and xUnit runs in parallel), but if I run them all sequentially they all succeed. I cannot understand why this would be an issue because every single fact is supposed to run the constructor (the given) and the

Ninject interception proxying class with non empty constructor via castle dynamic proxy

人走茶凉 提交于 2019-12-22 11:00:12
问题 I am basing most of my current implementation off the information provided here: Ninject Intercept any method with certain attribute? I use a custom planning strategy class which looks for all methods with given attributes (not ninject interceptor attributes) which will then get proxied if it matches the criteria. An example of usage would be: Kernel.Components.Add<IPlanningStrategy, CustomPlanningStrategy<LoggingAttribute, LoggerInterceptor>>(); This would then look for any methods which

castle dynamic proxy creation

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 02:05:10
问题 I am implementing a design where my layer would sit between client and server, and whatever objects i get from server, i would wrap it in a transparent proxy and give to the client, that way i can keep a track of what changed in the object, so when saving it back, i would only send changed information. I looked at castle dynamic proxy, linfu, although they can generate a proxy type, but they cant take existing objects and wrap them instead. Wondering if its possible to do with these

Applying Aspect Oriented Programming

让人想犯罪 __ 提交于 2019-12-18 04:37:28
问题 I've been using some basic AOP style solutions for cross-cutting concerns like security, logging, validation, etc. My solution has revolved around Castle Windsor and DynamicProxy because I can apply everything using a Boo based DSL and keep my code clean of Attributes. I was told at the weekend to have a look at PostSharp as it's supposed to be a "better" solution. I've had a quick look at PostSharp, but I've been put off by the Attribute usage. Has anyone tried both solutions and would care

Using Simple Injector with Castle Proxy Interceptor

柔情痞子 提交于 2019-12-18 02:47:49
问题 I'm using Simple Injector in my asp.net mvc 4 project. I can't figure out how can I use Simple Injector with castle proxy interceptor. 回答1: There's in fact a section about Interception in the Simple Injector documentation that pretty clearly describes how to do interception. The code samples given there don't show how to work with Castle DynamicProxy, but you actually need to change a few lines of code to get this working. If you use the Interception Extensions code snippet, to get it working

Castle DynamicProxy: Get unproxied object

久未见 提交于 2019-12-17 16:49:06
问题 I'm using Castle DynamicProxy to add an interceptor to my types. Now I need to get the underlying base type (NOT the proxy itself). I found a few hints on SO that suggested to use the ProxyUtil class like this: object realInstance = ProxyUtil.GetUnproxiedInstance(proxyInstance); This does not seem to work as bool isProxy = ProxyUtil.IsProxy(realInstance); is always true. I also tried using the following code snippet, which is essentially what ProxyUtil is doing: var accessor = proxyInstance

Castle DynamicProxy: Get unproxied object

不打扰是莪最后的温柔 提交于 2019-12-17 16:49:04
问题 I'm using Castle DynamicProxy to add an interceptor to my types. Now I need to get the underlying base type (NOT the proxy itself). I found a few hints on SO that suggested to use the ProxyUtil class like this: object realInstance = ProxyUtil.GetUnproxiedInstance(proxyInstance); This does not seem to work as bool isProxy = ProxyUtil.IsProxy(realInstance); is always true. I also tried using the following code snippet, which is essentially what ProxyUtil is doing: var accessor = proxyInstance

Castle DynamicProxy: create a new property with a custom attribute for XML serialization

若如初见. 提交于 2019-12-14 02:35:50
问题 I have a situation where I have some DTO classes that should be implemented like: public class City { public string Name { get; set; } public State State { get; set; } } public class State { public string Name { get; set; } } The problem is, these are actually DTO classes for REST XML resources. And the City resource may include the State resource inline, or it may simply provide the resource ID (a URI). I am handling access to the DTO via the Repository pattern and would like it to be

Help Migrating mixins from Castle.DynamicProxy to DynamicProxy2

妖精的绣舞 提交于 2019-12-14 02:33:54
问题 I am trying to update some code from using DynamicProxy to DynamicProxy2. In particular we where using DynamicProxy to provide a mixin of two classes. The setup is something like this: public interface IHasShape { string Shape { get; } } public interface IHasColor { string Color { get; } } public interface IColoredShape : IHasShape, IHasColor { } Then assuming some obvious concrete implementations of IHasShape and IHasColor we would create a mixin like this: public IColoredShape