存储对象并动态分配它们
我正在构建一个小型应用程序,以某种方式改进微控制器的工作。因此,我想在某个地方存储一个受支持的库。我希望每个节点都描述要操作的约束(选项),例如 GPIO 或中断。例如:STM8s继承自Device类,必须描述它有多少GPIO,在什么寄存器下,一个标志可能将其标记为模拟/数字。有没有一种方法可以做类似具有必须在其实例中填充的抽象属性的类之类的事情?第二个问题是如何将它传递给主机应用程序 - 我知道我必须使用 Reflection 类,但是如何将已经实例化的类从程序集中导入到集合中?
希望很清楚;)
I'm building a small app to somehow improve work with microcontrollers. Thus, I want to have a library of supported ones stored somewhere. I want each node to describe the constraints, (options) to manipulate, like GPIOs or interrupts. For example: STM8s which is inherited from Device class and has to describe how many GPIO it has, under what register, a flag maybe to mark it as analog/digital. Is there a way to do something like a class with abstract properties which have to be populated in its instances? Second questions is how to pass it to host application - I know I have to use Reflection class, but how to import already instatiated class to collection from assembly?
Hope it's clear ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您正在寻找 IOC 容器。
(http://en.wikipedia.org/wiki/Inversion_of_control)
我个人将 Unity 与 C# 结合使用:http://unity。 codeplex.com/
Looks like you are looking for an IOC container.
(http://en.wikipedia.org/wiki/Inversion_of_control)
I personally use Unity with C# : http://unity.codeplex.com/