I have the following XML file that i am trying to read into a class in c# using DE-serialization:
<?xml version="1.0"?>
<PropertiesMapping>
<Property>
<WEB_Class>InfoRequest</WEB_Class>
<COM_Class>CInfoReq</COM_Class>
<Mappings>
<Map>
<WEB_Property>theId</WEB_Property>
<COM_Property>TheID</COM_Property>
</Map>
<Map>
<WEB_Property>theName</WEB_Property>
<COM_Property>NewName</COM_Property>
</Map>
</Mappings>
</Property>
</PropertiesMapping>
The following is the code I am using, and while it executes without error no data gets read into the class PropertiesMapping, where am i going wrong??
PropertiesMapping pm = null;
try
{
System.IO.StreamReader str = new System.IO.StreamReader(@"PropertyMapping.xml");
System.Xml.Serialization.XmlSerializer xSerializer = new System.Xml.Serialization.XmlSerializer(typeof(PropertiesMapping));
pm = (PropertiesMapping)xSerializer.Deserialize(str);
str.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public class PropertiesMapping
{
private string m_WEB_Class = "";
private string m_COM_Class = "";
private List<IndividualProperties> m_EachProperty = null;
public string WEB_Class
{
get
{
return m_WEB_Class;
}
set
{
m_WEB_Class = value;
}
}
public string COM_Class
{
get
{
return m_COM_Class;
}
set
{
m_COM_Class = value;
}
}
public IndividualProperties GetIndividualProperties(int iIndex)
{
return m_EachProperty[iIndex];
}
public void SetIndividualProperties(IndividualProperties theProp)
{
m_EachProperty.Add(theProp);
}
}
public class IndividualProperties
{
private string m_WEB_PropertyField;
private string m_COM_PropertyField;
public string WEB_Property
{
get
{
return this.m_WEB_PropertyField;
}
set
{
this.m_WEB_PropertyField = value;
}
}
public string COM_Property
{
get
{
return this.m_COM_PropertyField;
}
set
{
this.m_COM_PropertyField = value;
}
}
}