Click here to Skip to main content
15,860,972 members
Articles / Desktop Programming / WPF

GoalBook - A Hybrid Smart Client

Rate me:
Please Sign up or sign in to vote.
4.86/5 (24 votes)
25 Sep 2009CPOL10 min read 78.6K   834   69  
A WPF hybrid smart client that synchronises your goals with the Toodledo online To-do service.
//===============================================================================
// Goal Book.
// Copyright © 2009 Mark Brownsword. 
//===============================================================================

#region Using Statements
using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
#endregion

namespace GoalBook.Infrastructure
{
    /// <summary>
    /// SyncTokenInfo type.
    /// </summary>
    [Serializable]
    public class SyncTokenInfo : IXmlSerializable
    {
        #region Declarations
        private const string TOKEN = "Token";
        private const string TOKEN_EXPIRES = "TokenExpires";
        #endregion

        #region Constructor
        /// <summary>
        /// Constructor.
        /// </summary>        
        public SyncTokenInfo()
        {

        }
        /// <summary>
        /// Constructor.
        /// </summary>        
        public SyncTokenInfo(string token, DateTime tokenExpires)            
        {
            Token = token;
            TokenExpires = tokenExpires;
        }
        #endregion

        #region Properties
        /// <summary>
        /// Reference to Token.
        /// </summary>
        public string Token { get; set; }

        /// <summary>
        /// Reference to TokenExpires.
        /// </summary>
        public DateTime TokenExpires { get; set; }
        #endregion

        #region Public Members
        /// <summary>
        /// Clear all data.
        /// </summary>
        public void Clear()
        {
            this.Token = null;
            this.TokenExpires = DateTime.MinValue;            
        }
        #endregion

        #region IXmlSerializable Members
        public XmlSchema GetSchema()
        {
            return null;
        }
        public void ReadXml(XmlReader reader)
        {
            Token = reader.GetAttribute(TOKEN);
            DateTime tokenExpires = DateTime.MinValue;
            if (DateTime.TryParse(reader.GetAttribute(TOKEN_EXPIRES), out tokenExpires))
            {
                TokenExpires = tokenExpires;
            }
        }
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteAttributeString(TOKEN, Token);
            writer.WriteAttributeString(TOKEN_EXPIRES, TokenExpires.ToString());            
        }
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Australia Australia
I've been working as a software developer since 2000 and hold a Bachelor of Business degree from The Open Polytechnic of New Zealand. Computers are for people and I aim to build applications for people that they would want to use.

Comments and Discussions