33 lines
956 B
C#
33 lines
956 B
C#
|
using System;
|
|||
|
using System.Xml;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Collections;
|
|||
|
|
|||
|
namespace oodb.mapping
|
|||
|
{
|
|||
|
public class ArrayMapping : ListMapping
|
|||
|
{
|
|||
|
public ArrayMapping(OODB oodb,Type type)
|
|||
|
:base(oodb,typeof(List<>).MakeGenericType(type.GetElementType()))
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public override XmlElement ToXml(XmlDocument xmlDocument, object value)
|
|||
|
{
|
|||
|
IList list = value as IList;
|
|||
|
Array array = Array.CreateInstance(ElementMapping.NativeType, list.Count);
|
|||
|
(list as IList).CopyTo(array, 0);
|
|||
|
|
|||
|
return base.ToXml(xmlDocument,list);
|
|||
|
}
|
|||
|
public override object FromXml(XmlElement xmlValue)
|
|||
|
{
|
|||
|
IList list = base.FromXml(xmlValue) as IList;
|
|||
|
Array array = Array.CreateInstance(ElementMapping.NativeType, list.Count) as Array;
|
|||
|
list.CopyTo(array, list.Count);
|
|||
|
return array;
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|