I'm working with a 3rd party file so I did not design the structure, and I'm stuck with it. For some reason all my enums are selecting the first value in the list instead of the correct one
First here is my deserialization code
using (var stream = new FileStream(filetoimport, FileMode.Open))
{
var ser = new XmlSerializer(typeof(MESSAGE));
var local_loan = (MESSAGE)ser.Deserialize(stream);
returned = ToDtax(returned, local_loan);
}
Next is the enum
[GeneratedCode("xsd", "4.6.81.0")]
[Serializable]
[XmlType(Namespace = "http://www.mismo.org/residential/2009/schemas", AnonymousType = true)]
public enum LoanIdentifierBase
{
NotSet,
AgencyCase,
InvestorCommitment,
InvestorContract,
InvestorLoan,
InvestorWorkoutCase,
LenderCase,
LenderLoan,
Then there is the class that has the enum as part of the class
[GeneratedCode("xsd", "4.0.30319.33440")]
[Serializable]
[DebuggerStepThrough]
[DesignerCategory("code")]
[XmlType(Namespace = "http://www.mismo.org/residential/2009/schemas")]
public class LoanIdentifierEnum : BaseClass
{
[XmlAttribute("SensitiveIndicator")]
public bool SensitiveIndicator { set; get; }
[XmlIgnore]
public bool SensitiveIndicatorSpecified { set; get; }
[XmlAttribute(Form = XmlSchemaForm.Qualified, Namespace = "http://www.w3.org/1999/xlink", DataType = "NCName")]
public string label { set; get; }
[XmlAnyAttribute]
public XmlAttribute[] AnyAttr { set; get; }
public LoanIdentifierBase Values { set; get; }
Finally there is the section of the import file that has the correct values but is deserializing with the wrong values
<LOAN_IDENTIFIERS>
<LOAN_IDENTIFIER SequenceNumber="1">
<LoanIdentifier SensitiveIndicator="false">UAT0019</LoanIdentifier>
<LoanIdentifierType SensitiveIndicator="false">LenderCase</LoanIdentifierType>
</LOAN_IDENTIFIER>
I have a very limited background in XML so any help would be greatly appreachiated
What I have tried:
I have put XMLElement and XMLAttribute tags over the enum. tried several suggestions from online searches. No matter what I try it always comes back with the first entry from the enum insted of the actual value