您可以将对象保存到 Visual Studio 中的 settings.settings 文件吗?如果有怎么办?我认为您可以使您的对象可序列化并且它应该持续存在,但是我不确定我是否做得对,即当我尝试取回对象时它始终为空。
这是代码:
[Serializable()]
[XmlRoot(ElementName = "LayerTCA", IsNullable = false, Namespace = "http://somesite.com")]
public class LayerTCA
{
//This is a COM object so I don't want to serialize this.
IFeatureClass featureClass;
string fullName;
string basicName;
public LayerTCA()
{
}
public LayerTCA(IFeatureClass featureClass)
{
FeatureClass = featureClass;
}
public IFeatureClass FeatureClass
{
get { return featureClass; }
set
{
featureClass = value;
fullName = featureClass.AliasName;
basicName = StringHelper.StringAfterLastFullStop(fullName);
}
}
[XmlAttribute(AttributeName = "BasicName")]
public string BasicName
{
get { return basicName; }
set { basicName = value; }
}
[XmlAttribute(AttributeName = "FullName")]
public string FullName
{
get { return fullName; }
set { fullName = value; }
}
public override string ToString()
{
return FullName;
}
}