System with plugins in C#

后端 未结 7 2061
臣服心动
臣服心动 2020-12-09 13:08

I have to develop a system to monitor sensor information, but many sensors might be added in the future.

That said, the idea would be to develop a system that would

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 13:16

    Depending upon the Sensors themselves, this sounds like you would need to define a single interface which all Sensors will implement. Your main "application skeleton" will then work against the ISensor interface and need not concern itself with the concrete implementations of each of the Sensor classes/objects/components.

    Whether each Sensor is simply a class within the same project, or a separate assembly is up to you, although if they are separate assemblies, you'd need a way to load these assemblies dynamically.

    Some references which may help here are:

    Command Pattern Design Pattern: - http://en.wikipedia.org/wiki/Command_pattern

    Observer Pattern Design Pattern: - http://en.wikipedia.org/wiki/Observer_pattern

    Dynamically loading assemblies: - http://www.divil.co.uk/net/articles/plugins/plugins.asp

    Hope this helps.

提交回复
热议问题