Serialization, control what element
I want a certain attribute to be a member of a certain element. Say, this is my class.
Code:
using System;
using System.Xml.Serialization;
namespace ProGeek.Others
{
/// <summary>
/// Summary description for VisualStudioProject.
/// </summary>
public class VisualStudioProject
{
private string projectType;
private string productVersion;
private string schemaVersion;
private string projectGuid;
public VisualStudioProject()
{
}
[XmlAttribute]
public string ProjectType
{
get { return projectType; }
set { projectType = value; }
}
[XmlAttribute]
public string ProductVersion
{
get { return productVersion; }
set { productVersion = value; }
}
[XmlAttribute]
public string SchemaVersion
{
get { return schemaVersion; }
set { schemaVersion = value; }
}
[XmlAttribute]
public string ProjectGuid
{
get { return projectGuid; }
set { projectGuid = value; }
}
}
}
I need to have the [XmlAttribute]s to be a member of an element; say <CSHARP> not <VisualStudioProject>. Ok, yes I'm serializing the project's xml file. Ok, one more thing.... Am I on the right track? I wanted to generate project xml file based from one's input. Is this a good idea?
Thanks in advance.