#region Copyright and GPL
/*************************************************************************
 * dataMagus - The open source database learning software
 * Copyright (C) 2007 by all authors
 * Authors: Monika Schwitter (monsy@gmx.ch)
 *          Jürg Zgraggen (j.zgraggen@ejaz.net)
 *          HSLU (Hochschule Luzern - Technik+Architektur)
 * 
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *************************************************************************/
#endregion
#region Using
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
#endregion

namespace dataMagus.Common
{
	/// <summary>
	/// This static class contains helper functionality for the whole application.
	/// </summary>
    public static class Helper
    {
		#region Methodes
		/// <summary>
		/// Convert a string to title case. First letter will be upper.
		/// </summary>
		/// <param name="value">Value to convert.</param>
		/// <returns>Title cased string.</returns>
        public static string ToTitleCase(string value)
        {
            if (String.IsNullOrEmpty(value))
            {
                return value;
            }
            return String.Format("{0}{1}", value.Substring(0, 1).ToUpper(), value.Substring(1));
        }

        /// <summary>
        /// Checks if an object implements the IXmlSerializable or IConvertible 
        /// or IsPrimitive. If yes, then the object is xml serializable.
        /// </summary>
        /// <param name="value">Object to check.</param>
        /// <returns>true if successfull, otherwise false.</returns>
        public static bool IsXmlSerializable(object value)
        {
            if (value is IXmlSerializable || value is IConvertible || value.GetType().IsPrimitive)
            {
                return true;
            }
            return false;
        }
		#endregion
    }
}
