开发者

Marking Component Class as Dependent Upon Another

My application has a "pipeline" concept that runs through and executes one to many "components". Some of these components cannot be executed unless one to many other components are run before it.

My goal is to somehow annotate these dependencies so that I can test via unit tests that they are ordered properly for execution in th开发者_如何学运维e pipeline.

Is there a construct in C#/.NET that would support this objective? My plan was to just inherit from a base component class that has a property on it, but I was hoping there'd be a better way.

Thoughts/suggestions?


Ideally, if a "Component" requires other components to be exectuted as a pipeline, you should design your system so that it takes the other "components" as as argument to either it's constructor, or to its execution method.

This way, it's impossible to create or execute your component without having properly initialized data.


Attributes would be one way to go:

http://msdn.microsoft.com/en-us/library/z0w1kczw.aspx


You can implement yourself in C# the pattern Chain Of Responsability. All object contain the next step (like a linked list) and it executes one after the other.

Marking Component Class as Dependent Upon Another

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜