// Reference.cs
// Conveintly serializable
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:schemas-sc-jp:mfp:osa-1-1")]
public partial class CREDENTIALS_TYPE : CREDENTIALS_BASE_TYPE {
private string datatypeField;
private OPAQUE_DATA_TYPE metadataField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("data-type")]
public string datatype {
get {
return this.datatypeField;
}
set {
this.datatypeField = value;
}
}
/// <remarks/>
public OPAQUE_DATA_TYPE metadata {
get {
return this.metadataField;
}
set {
this.metadataField = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:schemas-sc-jp:mfp:osa-1-1")]
public partial class OPAQUE_DATA_TYPE {
private System.Xml.XmlElement[] anyField;
private System.Xml.XmlAttribute[] anyAttrField;
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute()]
public System.Xml.XmlElement[] Any {
get {
return this.anyField;
}
set {
this.anyField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAnyAttributeAttribute()]
public System.Xml.XmlAttribute[] AnyAttr {
get {
return this.anyAttrField;
}
set {
this.anyAttrField = value;
}
}
}
I have a webmethod which gets data from a device on the network, part of this data is the credentials used to authorise with the device.
We are using an API, so to recieve this data I must have the CREDENTIALS_TYPE as a parameter type in the webmethod. What I need to do is save this data, so it can be aquired without the webmethod.
Now I have serialized classes to XML files before, so I went with the familiar option, but only with classes of my own creation. I would like to know if it’s actually possible to do the same thing with a referenced class that isn’t mine?
I have to create a class that matches CREDENTIALS_TYPE and copy the data across but I haven’t been able to find a way to convert between the different types.
The “CREDENTAILS_TYPE” is coming from an MFP, so reflecting and changing the code is no good in my situation because I couldn’t update it anyway.
Any suggestions/advice?
Since you can’t modify a class you don’t own the source code to, create your own DTO with the serialization attributes you require and then use Automapper to transfer the field data back and forth between the two.