Using Generics to implement simplified object interface?

I'd use normal interfaces instead. That's much cleaner and easier And the put a proxy between the real implementation of the interface and the interface the UI sees. That proxy can be dynamically generated at runtime and can do the logging.

I'm sure there are some existing libraries that can generate the proxy for you, but thanks to Expression s it's not that hard to write it yourself either by normal interface I mean something like the following: interface MyInterface { double Value1{get;set;} void Add(); void Sub(); } Just like you'd write any interface. Then implement it in a normal class. I haven't used any proxy generator myself, but I'm sure several mocking and AoP frameworks support that.

A quick google for dynamic proxy C turns up joe.truemesh.com/blog//000181.html which claims that NMock supports this An alternative is using an IL rewrite based AOP framework like PostSharp. You point it at your assemblies(as part of the build process) and it automatically adds logging calls into it.

I'd use normal interfaces instead. That's much cleaner and easier. And the put a proxy between the real implementation of the interface and the interface the UI sees.

That proxy can be dynamically generated at runtime and can do the logging. I'm sure there are some existing libraries that can generate the proxy for you, but thanks to Expressions it's not that hard to write it yourself either. By normal interface I mean something like the following: interface MyInterface { double Value1{get;set;} void Add(); void Sub(); } Just like you'd write any interface.

Then implement it in a normal class. I haven't used any proxy generator myself, but I'm sure several mocking and AoP frameworks support that. A quick google for dynamic proxy C# turns up joe.truemesh.com/blog//000181.html which claims that NMock supports this.An alternative is using an IL rewrite based AOP framework like PostSharp.

You point it at your assemblies(as part of the build process) and it automatically adds logging calls into it.

Could you expand on what you mean by 'normal interfaces'. I'm looking for a way to have the logging code written once. Any future component that implements this would be guaranteed to have logging support without having to write any of it.

Also, could you provide me with a link that describes the proxies and Expressions you were referencing. Some quick googling found those terms to be rather broad. – codeNoob Jul 11 at 18:12 By normal interfaces I mean the natural way of writing them.

Simple properties and methods. – CodeInChaos Jul 11 at 19:13.

Another solution yet: just add base class with virtual methods and any "component" that implements it, overrides it with concrete implementation and call base class method's where you actually write logging stuff. Well you need to know the "ID" of component. That could be virtual property too where every concrete class assigns its unique "ID".

Hope this helps.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions