using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Foo.WorkspaceMgr.Launchers
{
    class Launcher_Web : ILaunch
    {
        #region ILaunch Members

        /// <summary>
        /// Checks to see if the url is valid 
        /// ~~( We could even check if the webpage is available here!!!) ~to do later?
        /// </summary>
        /// <param name="strArtifactLocation">url to launch</param>
        /// <returns></returns>
        public FuncDepBoolType IQueryLaunch(string strArtifactLocation)
        {
            if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
            {               
                if (Uri.IsWellFormedUriString(strArtifactLocation, UriKind.Absolute))
                    return FuncDepBoolType.Success;
                else
                    return FuncDepBoolType.Failed;            
            }
            return FuncDepBoolType.ParametersInvalid;
        }

        /// <summary>        
        /// Generic Launcher should be able to handle any url type
        /// </summary>
        /// <param name="strArtifactLocation">url to launch</param>
        public FuncDepBoolType ILaunch(string strArtifactLocation)
        {
            if (!String.IsNullOrEmpty(strArtifactLocation) && (strArtifactLocation.Length > 3))
            {
                Process.Start(strArtifactLocation);
                return FuncDepBoolType.Success;
            }
            return FuncDepBoolType.ParametersInvalid;
        }

        #endregion
    }
}
