我正在使用System.Configuration命名空間類型來存儲我的應用程序的配置。我需要將原始類型(System.Double)的集合存儲爲該配置的一部分。這似乎是矯枉過正創建以下內容:具有原始類型的ConfigurationElementCollection
[ConfigurationCollection(typeof(double), AddItemName="TemperaturePoint",
CollectionType=ConfigurationElementCollectionType.BasicMap)]
class DoubleCollection : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return // Do I need to create a custom ConfigurationElement that wraps a double?
}
protected override object GetElementKey(ConfigurationElement element)
{
return // Also not sure what to do here
}
}
我無法想象我是第一個遇到此問題的人。有任何想法嗎?