Exemple #1
0
        public static void XmlDeserialize(Stream fs, object val)
        {
            if (val == null)
            {
                return;
            }

            Mpd.Xml.Serialization.XmlSerializer xs =
                new Mpd.Xml.Serialization.XmlSerializer(val.GetType());

            object tmp = xs.Deserialize(fs);

            Type t = val.GetType();

            PropertyInfo[] infos = t.GetProperties();

            if (infos != null && infos.Length > 0)
            {
                foreach (PropertyInfo pInfo in infos)
                {
                    MethodInfo gMethod = pInfo.GetGetMethod(true);
                    MethodInfo sMethod = pInfo.GetSetMethod(true);

                    if (gMethod != null && sMethod != null)
                    {
                        sMethod.Invoke(val,
                                       new object[] { gMethod.Invoke(tmp, null) });
                    }
                }
            }
        }
Exemple #2
0
        public static void XmlSerialize(Stream fs, object val)
        {
            if (val == null)
            {
                return;
            }

            Mpd.Xml.Serialization.XmlSerializer xs =
                new Mpd.Xml.Serialization.XmlSerializer(val.GetType());

            xs.Serialize(fs, val);
        }