开发者

Best way to implement some type of ITaggable interface

I've got a program I'm creating that reports on another certain programs backup xml files. I've gotten to the point where I need to implement some type of ITaggable interface - but am unsure how to go about it code wise.

My idea is that each item (BackupClient, BackupVersion, and BackupFile) should implement an ITaggable interface for highlighting old, out of date, or non-existent files in their HTML or Excel report. The 开发者_如何学编程user will be able to specify tags in the settings.

My question is this, how can a user dynamically specify a "tag" such as File Date > 3 days old? - Background Color = Red. Actually I guess my question is more, how can I, the programmer, implement this dynamically? I was thinking Expression trees, but am unsure this is the way to go as I havn't studied them much.

I know my ITaggable interface would have methods such as AddTag(T tag), RemoveTag(T tag), but what exactly specifies the criteria for the tag to be added?

I realize this may be subjective, and can be marked as wiki if need be, but I truly am stuck. Any input would be greatly helpful!


Well after discussing with a fellow programmer, the best solution may be the Vistor Pattern. It won't clutter my classes, and it will keep everything clean.

Visitor Pattern

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜