Ejemplo n.º 1
0
        public override object Deserialize(XElement elem, XNamespace overridingNamespace)
        {
            var dsElem = elem.Elements().FirstOrDefault(x => x.Name.LocalName == "NewDataSet");

            if (dsElem == null)
            {
                return(null);
            }

            using (var xr = dsElem.CreateReader())
            {
                var dsType = ReflectionUtils.GetTypeByName("System.Data.DataSet");
                var ds     = Activator.CreateInstance(dsType);
                ReflectionUtils.InvokeMethod(ds, "ReadXml", xr);
                var dsTables      = ReflectionUtils.InvokeGetProperty <object>(ds, "Tables");
                var dsTablesCount = ReflectionUtils.InvokeGetProperty <int>(dsTables, "Count");
                if (dsTablesCount > 0)
                {
                    var dsTablesZero = ReflectionUtils.InvokeIntIndexer <object>(dsTables, "Index", 0);
                    var copyDt       = ReflectionUtils.InvokeMethod(dsTablesZero, "Copy");
                    return(copyDt);
                }
                return(null);
            }
        }