我正在开发一个服务器控件,应该通过键/值对列表进行配置,如下所示:
<MyControls:ContentRenderer ID="ContentRenderer1" runat="server">
<MyControls:Placeholders>
<MyControls:Placeholder key="ident1">Some text which replaces {ident1}</MyControls:Placeholder>
<MyControls:Placeholder key="ident2">Some text which replaces {ident2}</MyControls:Placeholder>
</MyControls:Placeholders>
<MyControls:ContentRenderer />
我希望该属性是字典,以便我可以通过其标识符快速检索占位符映射。我知道如何使用List&lt;创建一个使用上述标记保持的属性。 T>但是我希望有一个类似hashmap的数据结构。
我在msdn上阅读了很多内容,但如果你想完全控制你的控制标记的解析方式,我仍然不知道该怎么做。
答案 0 :(得分:0)
我不认为字典是以这种方式支持的。但是,完成此操作的方法是使用基于列表的自定义类,而不是使用List,该类还存储键/对象的字典映射。
HTH。