public void config(string toolName, string version, string instalDir, string installFile, Uri installUri)
 	{
 		ToolName = toolName;
 		Version = version;    		
 		Install_Dir = instalDir;
 		Install_Uri = installUri;
 		Install_File = installFile;
 		VersionWebDownload =  Install_Uri.str();
 	}
 public static VirtualArticleAction add_Mapping_Redirect(this TM_Xml_Database tmXmlDatabase, Guid id, Uri redirectUri)
 {
     var virtualAction = new VirtualArticleAction
                                 {
                                     Id = id,
                                     Action = "Redirect",
                                     Redirect_Uri = redirectUri.str()
                                 };
     tmXmlDatabase.getVirtualArticles().add(id, virtualAction);
     tmXmlDatabase.saveVirtualArticles();
     return virtualAction;
 }
 	public string download(Uri uri)
 	{
 		"Downloading from Uri: {0}".info(uri);
 		if (uri.isNull())
 			return null;
 		VersionWebDownload = uri.str();
 		
 		//var localFilePath = PublicDI.config.O2TempDir.pathCombine(CurrentVersionZipFile);    	
 		//"downloading file {0} from {1} to {2}".info(CurrentVersionZipFile, CurrentVersionWebDownload,localFilePath);
 		"downloading file {0}".info(VersionWebDownload);
 		    		    	
         //if (new Web().httpFileExists(VersionWebDownload))            
         //{
           //  var downloadedFile =  new Web().downloadBinaryFile(VersionWebDownload);                
           var downloadedFile = VersionWebDownload.download();
             if (downloadedFile.fileExists())
             {
             	var targetFile = tempLocationOf_Install_File();//localDownloadsDir.pathCombine(Install_File);
             	"Copying file: {0}".info(targetFile);
             	Files.Copy(downloadedFile, targetFile);
             	"Deleting file: {0}".info(targetFile);
             	Files.deleteFile(downloadedFile);                	
             	if (targetFile.fileExists())
             		return targetFile;
             }
         //}
         return null;            
 	}
		public ascx_HtmlTagViewer show(Uri uri)
		{	
			if (PageToOpen.notNull())
				PageToOpen.set_Text(uri.str());
			return show(uri.getHtml());
		}
    	public string download(Uri uri)
    	{
    		var targetFile = tempLocationOf_Install_File();//localDownloadsDir.pathCombine(Install_File);
    		if (targetFile.fileExists())
    		{
    			"found previously downloaded copy: {0}".info(targetFile);
    			return targetFile;
    		}
    		"Downloading from Uri: {0}".info(uri);
    		if (uri.isNull())
    			return null;
    		VersionWebDownload = uri.str();
    		
            var downloadedFile = VersionWebDownload.download();
             
            if (downloadedFile.fileExists())
			{
             	for(int i =0 ; i< 5; i++) // try to get the file 5 times since sometimes the file is still not available (due to AV)
             	{
					this.sleep(1000);	            
	            	"Copying file: {0}".info(targetFile);
	            	if (Files.copy(downloadedFile, targetFile).valid())
	            	{
	            		"Deleting file: {0}".info(downloadedFile);
	            		Files.deleteFile(downloadedFile);                	
	            	}
	            	if (targetFile.fileExists())
	            		return targetFile;	            	
	            		            	
	            }	            
	         };
            return null;            
    	}
 public static WatiN_IE open(this WatiN_IE watinIe, Uri uri)
 {
     return (watinIe.notNull() && uri.notNull())
         ? watinIe.open(uri.str())
         : watinIe;
 }
 public static WatiN_IE wait_For_Uri(this WatiN_IE watinIe, Uri expectedUri,  int maxWait = 1000)
 {
     return (watinIe.notNull() && expectedUri.notNull())
         ? watinIe.wait_For_Url(expectedUri.str(),maxWait)
         : watinIe;
 }
 public static WatiN_IE assert_Uri_Is(this WatiN_IE watinIe, Uri expectedUri, string message = Extra_NUnit_Messages.ASSERT_URL_IS)
 {
     return (watinIe.notNull() && expectedUri.notNull())
                 ? watinIe.assert_Url_Is(expectedUri.str(),message)
                 : watinIe;
 }