Mixins with C# 4.0

后端 未结 5 1580
孤城傲影
孤城傲影 2020-12-13 02:45

I\'ve seen various questions regarding if mixins can be created in C# and they are often directed to the re-mix project on codeplex. However, I don\'t know if I like the \"

5条回答
  •  时光取名叫无心
    2020-12-13 03:06

    I worked on a project in 2008 using a dependency injection style library that let us define the design of our application (in code) using an internal domain specific language (DSL).

    The library let us define Systems and to compose those systems from other systems. A system represented a set of objects that implemented interfaces within a scope. The system/subsystem could choose to expose interfaces to the parent scope.

    The effect of this was that mixins came for free. You would just add the class implementing the slice of behaviour to your system definition and expose its interface to the parent scope. That system now has that behaviour.

    You maybe be able to do this with modern dependency injection frameworks too.

    We were using NDI (https://github.com/NigelThorne/ndependencyinjection/wiki).

    Note: I wrote NDI in back in 2008.

提交回复
热议问题