Beispiel #1
0
        public void Derialize(string fileName)
        {
            Clear();

            var context = new DeserializationContext(this, fileName);

            context.Deserialize();
        }
Beispiel #2
0
        /// <summary>
        /// Serializes from <paramref name="xmlNode"/> using
        /// <paramref name="deserializationContext"/>.
        /// </summary>
        /// <param name="deserializationContext"></param>
        /// <param name="xmlNode"></param>
        /// <param name="type"></param>
        public object Deserialize(DeserializationContext deserializationContext, XmlNode xmlNode, Type type)
        {
            ArrayList array = new ArrayList();

            foreach (XmlNode valueNode in xmlNode.SelectNodes("array/data/value"))
            {
                array.Add(deserializationContext.Deserialize(valueNode, type.GetElementType() ?? typeof(object)));
            } // foreach

            return(array.ToArray(type.GetElementType() ?? typeof(object)));
        }
        /// <summary>
        /// Serializes from <paramref name="xmlNode"/> using
        /// <paramref name="deserializationContext"/>.
        /// </summary>
        /// <param name="deserializationContext"></param>
        /// <param name="xmlNode"></param>
        /// <param name="type"></param>
        public object Deserialize(DeserializationContext deserializationContext,
                                  XmlNode xmlNode, Type type)
        {
            //
            // Creating instance of type
            object value = Activator.CreateInstance(type);

            foreach (XmlNode memberNode in xmlNode.FirstChild.SelectNodes("./member"))
            {
                string       memberName = memberNode.SelectSingleNode("./name").InnerText;
                PropertyInfo property   = GetProperty(type, memberName);

                property.SetValue(value,
                                  deserializationContext.Deserialize(
                                      memberNode.SelectSingleNode("./value"), property.PropertyType), null);
            } // foreach

            return(value);
        }
Beispiel #4
0
 /// <summary>
 /// Deserializes object of type <paramref name="type"/> from <paramref name="objectXmlNode"/>.
 /// </summary>
 /// <param name="objectXmlNode"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public object DeserializeObject(XmlNode objectXmlNode, Type type)
 {
     return(deserializationContext.Deserialize(objectXmlNode, type));
 }