XmlTypeMapElementInfoList _elementInfo;
string _choiceMember;
bool _isTextCollector;
+ TypeData _choiceTypeData;
public XmlTypeMapMemberElement()
{
set { _choiceMember = value; }
}
+ public TypeData ChoiceTypeData
+ {
+ get { return _choiceTypeData; }
+ set { _choiceTypeData = value; }
+ }
+
public XmlTypeMapElementInfo FindElement (object ob, object memberValue)
{
if (_elementInfo.Count == 1)
else if (_choiceMember != null)
{
object value = GetValue (ob, _choiceMember);
- string choiceValue = value is IFormattable ? ((IFormattable) value).ToString (null, CultureInfo.InvariantCulture) : value.ToString();
foreach (XmlTypeMapElementInfo elem in _elementInfo)
- if (elem.ChoiceValue == choiceValue) return elem;
+ if (elem.ChoiceValue != null && elem.ChoiceValue.Equals (value)) return elem;
}
else
{
if (memberValue == null)
return (XmlTypeMapElementInfo) _elementInfo[0];
- Type type = memberValue.GetType();
foreach (XmlTypeMapElementInfo elem in _elementInfo)
- if (elem.TypeData.Type == type) return elem;
+ if (elem.TypeData.Type.IsInstanceOfType (memberValue)) return elem;
}
return null;
}
+
+ public void SetChoice (object ob, object choice)
+ {
+ SetValue (ob, _choiceMember, choice);
+ }
public bool IsXmlTextCollector
{