How to build a mix-in architecture framework in C#? -


i have concept framework of controls build. makes idea different not intend take "one size fits all" approach or "one control rule them all" approach.

as example, telerik makes nice grid control, componentone, xceed, etc.. however, gigantic controls hundreds or thousands of methods , properties, complex object model hiearchies, etc... these grids way overkill need, still have take on herculean task of learning entire grid simple.

my concept more of "mix-in" aproach. create simple control, , build features can "add-in" control la carte. example, have simple grid, , want add grid "sections" headers , footers each.

ok, where's problem? traditional way of doing via multiple inheritance, c# not support. if did support it, i'm still of opinion mi adds more problems solves.

so i'm soliciting opinions on how approach problem. mef potential solution?

edit:

something occurs me possible use expression trees build control various expressions. i'd have think through more, it's interesting concept.

another possible option might "control generator" generates assembly based on selected features. seems more complex, t4 might managable.

a few options

  1. consider decorator pattern; small objects extend behavior of minimalist class can build @ runtime. canonical example in dotnet framework around io streams (e.g. streamreader/writer, textstreamreader/writer, filestreamreader/writer); it's common in oo ui frameworks, typical example looking var window=new horizontalscrollingwindowdecorator(new verticalscrollingwindowdecorator(new window));

  2. the state, strategy, command, , composite patterns offer various alternatives dealing composition of behavior without requiring lots of control flow. example, delegate types of behavior current state of object (some of class methods call methods of current object state). can delegate behavior command objects, or build complex commands using composite commands. single inheritance leads favor composition of objects on inheritance, , these classic patterns composing behavior work single-inheritance.

  3. you can use delegates "hole in middle" pattern that's commonplace in functional programming, when small piece of behavior needs implemented particular instance.

  4. you can use postsharp or similar aspect-oriented programming tool runtime or compile-time weaving of behavior, useful cases when behavior needed several different classes doesn't have primary responsibility of class.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -