А потом я делаю так
using System;
using Rsdn.Framework.Data;
using Rsdn.Framework.Data.Mapping;
namespace ConsoleApp
{
public enum TriState {Yes, No, NotApplicable};
public class TestMap
{
[STAThread]
static void Main(string[] args)
{
TestMap.TestChangeType();
}
public class Src
{
public string Field1 = "no";
}
[MapXml("Dest")]
public class Dest
{
private TriState _f1 = TriState.NotApplicable;
public TriState Field1
{
get
{
return _f1;
}
set
{
_f1 = value;
}
}
}
public static void TestChangeType()
{
MapDescriptor.SetMappingSchema(@"D:\Projects\Research\RSDNTest\Mapping.xml");
Src s = new Src();
Dest d = (Dest)Map.ToObject(s, typeof(Dest));
string temp = d.Field1.ToString();
Console.WriteLine(temp);
}
}
}
Вот XML:
<?xml version="1.0" encoding="utf-8" ?>
<mapping xmlns="http://www.rsdn.ru/mapping.xsd">
<type name="Dest">
</type>
<value_type name="TriState ">
<value target="Yes" source="yes" source_type="System.String" />
<value target="No" source="no" source_type="System.String" />
<value target="NotApplicable" source="(n/a)" source_type="System.String" />
<null_value target="NotApplicable" />
<default_value target="NotApplicable" />
</value_type>
</mapping>
И получаю:
An unhandled exception of type 'Rsdn.Framework.Data.Mapping.RsdnMapException' occurred in rsdn.framework.data.dll
Additional information: Cannot assign value 'no' of 'String' type to 'Dest.Field1'. Input string was not in a correct format.