J
Jarod
Hello,
I have a list of objects that I want to serialize as XML and save it as
user setting. The objects are of type of the following class.
[Serializable]
public class SourceFolder
{
public SourceFolder(string path, bool controlled, bool
includesSub)
{
this.path = path;
this.controlled = controlled;
this.includesSub = includesSub;
}
public string Path
{
get
{
return path;
}
set
{
path = value;
}
}
public bool Controlled
{
get
{
return controlled;
}
set
{
controlled = value;
}
}
public bool IncludesSub
{
get
{
return includesSub;
}
set
{
includesSub = value;
}
}
private string path;
private bool controlled;
private bool includesSub;
}
In my settings object, I have a property of type List<SourceFolder>
that I assign my object list before saving. Unfortunately, the only
output in the file user.config is the following:
<setting name="SourceFolders" serializeAs="Xml">
<value />
</setting>
When I add the attribute
SettingsSerializeAs(SettingsSerializeAs.Binary) to the settings
property, it works, but the list is serialized binary what I do not
want.
Visual Studio 2005 help states that .NET framework is able to serialize
lists of any object to XML stream. What am I doing wrong that it does
not work for me? When I use List<string> instead of List<SourceFolder>,
it works fine, but not with my class.
Regards, Jens
I have a list of objects that I want to serialize as XML and save it as
user setting. The objects are of type of the following class.
[Serializable]
public class SourceFolder
{
public SourceFolder(string path, bool controlled, bool
includesSub)
{
this.path = path;
this.controlled = controlled;
this.includesSub = includesSub;
}
public string Path
{
get
{
return path;
}
set
{
path = value;
}
}
public bool Controlled
{
get
{
return controlled;
}
set
{
controlled = value;
}
}
public bool IncludesSub
{
get
{
return includesSub;
}
set
{
includesSub = value;
}
}
private string path;
private bool controlled;
private bool includesSub;
}
In my settings object, I have a property of type List<SourceFolder>
that I assign my object list before saving. Unfortunately, the only
output in the file user.config is the following:
<setting name="SourceFolders" serializeAs="Xml">
<value />
</setting>
When I add the attribute
SettingsSerializeAs(SettingsSerializeAs.Binary) to the settings
property, it works, but the list is serialized binary what I do not
want.
Visual Studio 2005 help states that .NET framework is able to serialize
lists of any object to XML stream. What am I doing wrong that it does
not work for me? When I use List<string> instead of List<SourceFolder>,
it works fine, but not with my class.
Regards, Jens