How to use C # attributes and reflection for injection / forced late bindings for marked objects?

I like the design patterns, the problem is that some of them can be really tedious to implement. For example, decorating an object with 20+ members is simply annoying.

So, I wanted to create a beautiful library of design patterns for applying to classes (either as base classes or attributes) in order to make the implementation of these patterns much faster and more convenient.

The problem is that ... I'm not quite sure where to start - because I'm basically not familiar with attributes and reflection.


I would like to use attributes to refer to Singletons (similar to the Export tag), Multitons and Decorators ... if at all possible. But I don’t even know where to start to create a singleton attribute that changes the functionality of its instances.

My limited research has led me to think that using reflection / late binding through an attribute and gaining access to all the marked classes in the assembly will allow you to crack one single ... but I'm still not quite sure how this will be done.

I found a circuit called Ninject 1.0, created the Singleton attribute, but the library is so vast and undocumented that I am currently unable to execute my logic.


, . , - , , - . - Ninject, ...

.

+3
1

, , .

- , .

. , . - , , . , .

, , , , , - (). .., . - . . , / , /. , "Singleton", ; Singleton , ( ) .

, / .

, , , , - "", , "IPublisher". , - "Singleton", .

.

#, , . , "singleton", "SingletonObject", . , , . , /, IPublisher ISubscriber.

, Decorator # ( ), , , -. ExpandoObject, ExpandoObject, . ExpandoObject . ! "-".

+4

All Articles