Utility.cs :  » Installers-Generators » WiX » Microsoft » Tools » WindowsInstallerXml » NAntTasks » 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 » Installers Generators » WiX 
WiX » Microsoft » Tools » WindowsInstallerXml » NAntTasks » Utility.cs
//--------------------------------------------------------------------------------------------------
// <copyright file="Utility.cs" company="Microsoft">
//    Copyright (c) Microsoft Corporation.  All rights reserved.
//    
//    The use and distribution terms for this software are covered by the
//    Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
//    which can be found in the file CPL.TXT at the root of this distribution.
//    By using this software in any fashion, you are agreeing to be bound by
//    the terms of this license.
//    
//    You must not remove this notice, or any other, from this software.
// </copyright>
// 
// <summary>
// Utility methods for the Wix NAntTasks project.
// </summary>
//--------------------------------------------------------------------------------------------------

namespace Microsoft.Tools.WindowsInstallerXml.NAntTasks{
    using System;

    using NAnt.Core;
    using NAnt.Core.Util;

    /// <summary>
    /// Utility methods for the Wix NAntTasks project.
    /// </summary>
    internal sealed class Utility
    {
        #region Member Variables
        //==========================================================================================
        // Member Variables
        //==========================================================================================

        #endregion

        #region Constructors
        //==========================================================================================
        // Constructors
        //==========================================================================================

        /// <summary>
        /// Prevent direct instantiation of this class.
        /// </summary>
        private Utility()
        {
        }
        #endregion

        #region Properties
        //==========================================================================================
        // Properties
        //==========================================================================================

        #endregion
 
        #region Methods
        //==========================================================================================
        // Methods
        //==========================================================================================
        
        /// <summary>
        /// Surrounds the path with quotes if it has any embedded spaces.
        /// </summary>
        /// <param name="path">The path to quote.</param>
        /// <returns>The quoted path if it needs quotes.</returns>
        public static string QuotePathIfNeeded(string path)
        {
            // If the path is not null/emtpy, if it contains the space character somewhere,
            // and if it's not already surround in quotes, then surround it in quotes.
            if (!StringUtils.IsNullOrEmpty(path) && path.IndexOf(' ') >= 0)
            {
                if (path[0] != '"' || path[path.Length - 1] != '"' || path.Length == 1)
                {
                    path = "\"" + path + "\"";
                }
            }
            return path;
        }

        /// <summary>
        /// Verifies that the specified argument is not null and throws an exception if it is.
        /// </summary>
        /// <param name="argument">The argument to check.</param>
        /// <param name="argumentName">The name of the argument.</param>
        public static void VerifyArgumentNonNull(object argument, string argumentName)
        {
            if (argument == null)
            {
                throw new ArgumentNullException(argumentName);
            }
        }

        /// <summary>
        /// Verifies that the specifed string argument is not null and not empty and throws an
        /// exception if it is.
        /// </summary>
        /// <param name="argument">The argument to check.</param>
        /// <param name="argumentName">The name of the argument.</param>
        public static void VerifyStringArgument(string argument, string argumentName)
        {
            VerifyArgumentNonNull(argument, argumentName);
            if (argumentName.Length == 0)
            {
                throw new ArgumentException("An empty string is not allowed.", argumentName);
            }
        }
        #endregion
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.