N
~~~ .NET Ed ~~~
Hello,
I am having a problem trying to serialize this simple structure, I use it
in a collection class that derives from CollectionBase but I noticed that at
least for now the serialization exception ocurrs when i try to serialize
this structure (see below). The idea is that it would be serialized to:
< Param type="..." method="Get" required="true">something</Param>
I use the following to serialize:
WizarParameter wpar = new WizardParameter(typeof(int),
WizardParameterMethod.Get, true, "something");
StringWriter sw = new StringWriter();
XmlSerializer ser = new XmlSerializer(typeof(WizardParameter));
ser.Serialize(sw, wpar);
[Serializable]
[XmlRoot("Param")]
public struct WizardParameter
{
/// The system type contained by this parameter
[XmlAttribute("type")]
public System.Type Type;
/// The method that should be used to pass this paramete
[XmlAttribute("method")]
public WizardParameterMethod Method; /// enumeration
/// Whether the parameter is required or optional
[XmlAttribute("required")]
public bool IsRequired;
[XmlElement("key")]
public string Key;
public WizardParameter(Type type, WizardParameterMethod method, bool
required, string key)
{
this.Type = type;
this.Method = method;
this.IsRequired = required;
this.Key = key;
}
}
I am having a problem trying to serialize this simple structure, I use it
in a collection class that derives from CollectionBase but I noticed that at
least for now the serialization exception ocurrs when i try to serialize
this structure (see below). The idea is that it would be serialized to:
< Param type="..." method="Get" required="true">something</Param>
I use the following to serialize:
WizarParameter wpar = new WizardParameter(typeof(int),
WizardParameterMethod.Get, true, "something");
StringWriter sw = new StringWriter();
XmlSerializer ser = new XmlSerializer(typeof(WizardParameter));
ser.Serialize(sw, wpar);
[Serializable]
[XmlRoot("Param")]
public struct WizardParameter
{
/// The system type contained by this parameter
[XmlAttribute("type")]
public System.Type Type;
/// The method that should be used to pass this paramete
[XmlAttribute("method")]
public WizardParameterMethod Method; /// enumeration
/// Whether the parameter is required or optional
[XmlAttribute("required")]
public bool IsRequired;
[XmlElement("key")]
public string Key;
public WizardParameter(Type type, WizardParameterMethod method, bool
required, string key)
{
this.Type = type;
this.Method = method;
this.IsRequired = required;
this.Key = key;
}
}