object GetMemberValue(XmlTypeMapMember member, object ob, bool isValueList)
 {
     if (isValueList)
     {
         return(((object[])ob)[member.GlobalIndex]);
     }
     else
     {
         return(member.GetValue(ob));
     }
 }
Ejemplo n.º 2
0
 public XmlTypeMapElementInfo FindElement(object ob, int index, object memberValue)
 {
     if (_itemInfo.Count == 1)
     {
         return((XmlTypeMapElementInfo)_itemInfo[0]);
     }
     else if (_choiceMember != null && index != -1)
     {
         Array values = (Array)XmlTypeMapMember.GetValue(ob, _choiceMember);
         if (values == null || index >= values.Length)
         {
             throw new InvalidOperationException("Invalid or missing choice enum value in member '" + _choiceMember + "'.");
         }
         object val = values.GetValue(index);
         foreach (XmlTypeMapElementInfo elem in _itemInfo)
         {
             if (elem.ChoiceValue != null && elem.ChoiceValue.Equals(val))
             {
                 return(elem);
             }
         }
     }
     else
     {
         if (memberValue == null)
         {
             return(null);
         }
         Type type = memberValue.GetType();
         foreach (XmlTypeMapElementInfo elem in _itemInfo)
         {
             if (elem.TypeData.Type == type)
             {
                 return(elem);
             }
         }
     }
     return(null);
 }