atomuri.cs :  » Network-Clients » RemoteCalendars » Google » GData » Client » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Network Clients » RemoteCalendars 
RemoteCalendars » Google » GData » Client » atomuri.cs
/* Copyright (c) 2006 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
#region Using directives

#define USE_TRACING

using System;
using System.Xml;
using System.IO; 

#endregion

//////////////////////////////////////////////////////////////////////
// Contains AtomUri.
//////////////////////////////////////////////////////////////////////
namespace Google.GData.Client{
    //////////////////////////////////////////////////////////////////////
    /// <summary>AtomUri object representation
    /// </summary> 
    //////////////////////////////////////////////////////////////////////
  public class AtomUri : IComparable
    {
        string strContent;

        /// <summary>basic constructor for the atomUri</summary> 
        public AtomUri(Uri uri)
        {
            Tracing.Assert(uri != null, "uri should not be null");
            if (uri == null)
            {
                throw new ArgumentNullException("uri"); 
            }
            this.strContent = System.Web.HttpUtility.UrlDecode(uri.ToString());
        }

        /// <summary>alternating constructor with a string</summary> 
        public AtomUri(string str)
        {
            this.strContent = System.Web.HttpUtility.UrlDecode(str);
        }

        //////////////////////////////////////////////////////////////////////
        /// <summary>accessor method public string Content</summary> 
        /// <returns> </returns>
        //////////////////////////////////////////////////////////////////////
        public string Content
        {
            get {return this.strContent;}
            set {this.strContent = value;}
        }
        /////////////////////////////////////////////////////////////////////////////

        /// <summary>override for ToString</summary> 
        public override string ToString()
        {
            return strContent;
        }

        /// <summary>comparison method similar to strings</summary> 
        public static int Compare(AtomUri a, AtomUri b)
        {
            if (a != null) 
            {
                return a.CompareTo(b);
            }
            else if (b == null) 
            {
                return 0;
            }
            return -1; 
        }

    #region IComparable Members

        /// <summary>
        /// as we do comparisons, we need to override this
        /// we return the hashcode of our string member
        /// </summary>
        /// <returns>int</returns>
        public override int GetHashCode()
        {
            return this.ToString().GetHashCode(); 
        }


        /// <summary>
        /// overloaded IComparable interface method
        /// </summary>
        /// <param name="obj">the object to compare this instance with</param>
        /// <returns>int</returns>
    public int CompareTo(object obj)
    {
      if (obj == null)
        return -1;

      if (obj is AtomUri == false)
        throw new ArgumentException("obj is not the same type as this instance.", "obj");

      return String.Compare(this.ToString(), (obj as AtomUri).ToString());
    }

    #endregion

        /// <summary>
        /// overridden equal method
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>bool</returns>
    public override bool Equals (object obj)
    {
      return this.CompareTo(obj) == 0;
    }

        /// <summary>
        /// overridden comparson operator
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns>bool</returns>
    public static bool operator == (AtomUri a, AtomUri b)
    {
            if ((object)a == null && (object)b == null) return true;
            if ((object)a != null && (object)b != null) 
            {
                return a.Equals(b);
            }
            return false; 
    }

        /// <summary>
        /// overridden comparson operator
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns>bool</returns>
        public static bool operator != (AtomUri a, AtomUri b)
        {
            return !(a == b); 
        }

        /// <summary>
        /// overridden comparson operator
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns>bool</returns>
    public static bool operator >(AtomUri a, AtomUri b)
    {
            if (a != null) 
            {
                return a.CompareTo(b) > 0;
            }
            return false; 
    }

        /// <summary>
        /// overridden comparson operator
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns>bool</returns>
    public static bool operator <(AtomUri a, AtomUri b)
    {
            if (a != null) 
            {
                return a.CompareTo(b) < 0;
            }
            return true; 
    }

        /// <summary>
        /// overridden comparson operator
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns>bool</returns>
    public static bool operator >=(AtomUri a, AtomUri b)
    {
            if (a != null)
            {
                return a.CompareTo(b) > 0 || a.Equals(b);
            }
            else if (b == null)
            {
                return true;
            }
            return false;
    }

        /// <summary>
        /// overridden comparson operator
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns>bool</returns>
    public static bool operator <=(AtomUri a, AtomUri b)
    {
            if (a != null)
            {
                return a.CompareTo(b) < 0 || a.Equals(b);
            }
            return true;
    }

    /// <summary>
    /// implicit new instance of AtomUri from string
    /// </summary>
    /// <param name="s"></param>
    /// <returns></returns>
    public static implicit operator AtomUri(string s)
    {
      return new AtomUri(s);
    }

    /// <summary>
    /// implicit new instance of AtomUri from Uri object
    /// </summary>
    /// <param name="u"></param>
    /// <returns></returns>
    public static implicit operator AtomUri(Uri u)
    {
      return new AtomUri(u);
    }
  }
    /////////////////////////////////////////////////////////////////////////////
} 
/////////////////////////////////////////////////////////////////////////////
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.