Exemplo n.º 1
0
        /// <summary>
        /// Turn the innerText of an XML node into a DateTime and return that DateTime
        /// </summary>
        /// <param name="_object">The object to deserialize into</param>
        /// <param name="_node">The node containing the DateTime string</param>
        /// <param name="_deserializer">The serializer- not used</param>
        /// <returns>a DateTime object</returns>
        public bool Deserialize(CWorkingObject _object, XmlElement _node, CDeserializer _deserializer)
        {
            var sb = new StringBuilder(_node.InnerText);

            _object.Set(sb);
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Given a filename and a deserializer, return the object that was created from deserializing the Xml in the file
        /// </summary>
        /// <typeparam name="T">The Type of the object that is to be deserialized</typeparam>
        /// <param name="_filename">The name of the file that contains the information for deserialization</param>
        /// <param name="_deserializer">The Deserializer to use for the deserialization</param>
        /// <returns>The object that was deserialized</returns>
        public static T FromFile <T>(string _filename, CDeserializer _deserializer)
        {
            var doc = new XmlDocument();

            doc.Load(_filename);
            return(_deserializer.Deserialize <T>(doc));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Turn the innerText of an XML node into a DateTime and return that DateTime
        /// </summary>
        /// <param name="_object">The object to deserialize into</param>
        /// <param name="_node">The node containing the DateTime string</param>
        /// <param name="_deserializer">The serializer- not used</param>
        /// <returns>a DateTime object</returns>
        public bool Deserialize(CWorkingObject _object, XmlElement _node, CDeserializer _deserializer)
        {
            var dateData = long.Parse(_node.InnerText, NumberStyles.AllowHexSpecifier);

            _object.Set(DateTime.FromBinary(dateData));
            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Used by the framework when it realizes that the working object needs to be
        /// assocated with a reference ID
        /// </summary>
        /// <param name="_deserializer">The instance of the deserializer working on this
        /// object</param>
        /// <param name="_refId">The ID to be associated with the object WHEN it is
        /// assigned.</param>
        internal void SetRefInfo(CDeserializer _deserializer, string _refId)
        {
            m_deserializer = _deserializer;
            m_refId        = _refId;

            if (WorkingObject != null)
            {
                UpdateDeserializer();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Turn the innerText of an XML node into a guid and return that guid
 /// </summary>
 /// <param name="_node">The node containing the GUID string</param>
 /// <param name="_object">The object to deserialize into</param>
 /// <param name="_deserializer">The Deserializer- not used</param>
 /// <returns>a GUID object</returns>
 public bool Deserialize(CWorkingObject _object, XmlElement _node, CDeserializer _deserializer)
 {
     _object.Set(new Guid(_node.InnerText));
     return(true);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Retrieve a deserialized object from a file
        /// </summary>
        /// <typeparam name="T">The Type of the object that is to be deserialized</typeparam>
        /// <param name="_filename">The name of the file that contains the information for deserialization</param>
        /// <param name="_context">Serialization context for the operation</param>
        /// <returns>The object that was deserialized</returns>
        public static T FromFile <T>(string _filename, CSerializationContext _context = null)
        {
            var d = new CDeserializer(_context);

            return(FromFile <T>(_filename, d));
        }
Exemplo n.º 7
0
        /// <summary>
        /// This is the Deserializer to turn a UTC "Complete date plus hours, minutes and seconds" string
        /// back into a DateTime structure.
        /// </summary>
        /// <param name="_workingObject">The object that is to receive the new DateTime structure</param>
        /// <param name="_parentNode">The node whose InnerText contains the UTC string</param>
        /// <param name="_deserializer">The deserializer- not used.</param>
        /// <returns>"true", because this routine completely deserializes the DateTime</returns>
        public bool Deserialize(CWorkingObject _workingObject, XmlElement _parentNode, CDeserializer _deserializer)
        {
            var asString = _parentNode.InnerText;
            var dt       = FromString(asString);

            _workingObject.Set(dt);
            return(true);
        }
        /// <summary>
        /// Given an XmlElement and a "CWorkingObject" instance, try to deserialize the Xml into
        /// the working object. The surrogate may be responsible for object creation- the
        /// _workingObject should be checked to see if an object has already been created (by,
        /// for instance, a super-class). All of the information for the object should be
        /// wholely contained within the XmlElement supplied. The implementation should never
        /// need to "hunt around" the XML DOM for information about the object.
        /// </summary>
        /// <param name="_workingObject">
        /// The container for object that is being deserialized. If the "WorkingObject" property
        /// is a NULL value, then the deserializer is expected to create the object and use the
        /// <see cref="CWorkingObject.Set"/> method to assign the newly created object to the
        /// working object. If it is NOT a null value, then the deserializer is not allowed to
        /// modify this "Working Object" value.
        /// </param>
        /// <param name="_parentElement">
        /// The XmlElement containing the data to populate the object with
        /// </param>
        /// <param name="_deserializer">
        /// The CDeserializer instance making this call- This can be used to get the context
        /// information or any other relevent information.
        /// </param>
        /// <returns>
        /// TRUE if the surrogate was able to completely deserialize the object, FALSE if the
        /// framework should perform its "default" function.
        /// </returns>
        public bool Deserialize(CWorkingObject _workingObject, XmlElement _parentElement, CDeserializer _deserializer)
        {
            if (Surrogate1.Deserialize(_workingObject, _parentElement, _deserializer))
            {
                return(true);
            }

            return(Surrogate2.Deserialize(_workingObject, _parentElement, _deserializer));
        }