Alright I fixed it. Before I got to far into my other plan I was reading and found out about XmlAttributeOverrides. Well this does the trick along with a little reflection. What I did was "virtualy" mark all properties and fields in the Form class (and the classes that Form derives from) with the XmlIgnore attribute. Therefore it only serializes the properties and fields that I created in my class that derives from Form. Heres the code I used to do it:
Code:
XmlAttributeOverrides over = new XmlAttributeOverrides();
XmlAttributes attributes = new XmlAttributes();
attributes.XmlIgnore = true;
Type type = typeof(Form);
while (type != null)
{
foreach (PropertyInfo info in type.GetProperties())
{
over.Add(type, info.Name, attributes);
}
foreach (FieldInfo info in type.GetFields())
{
over.Add(type, info.Name, attributes);
}
type = type.BaseType;
}
And than I created the XmlSerializer like this:
Code:
XmlSerializer serializer = new XmlSerializer(typeof(Options), over);