GetRunStub() public static method

Builds a stub EXE in a well-known location. Future calls with the same arguments will return the same EXE.
The user canceled the task. There was a compilation error while generating the stub EXE. A problem occurs while writing to the filesystem. A problem occured while downloading additional data (such as icons). Write access to the filesystem is not permitted.
public static GetRunStub ( FeedTarget target, [ command, [ handler, bool machineWide = false ) : string
target ZeroInstall.Store.FeedTarget The application to be launched via the stub.
command [ The command argument to be passed to the the "0install run" command; can be null.
handler [ A callback object used when the the user is to be informed about the progress of long-running operations such as downloads.
machineWide bool Store the stub in a machine-wide directory instead of just for the current user.
return string
コード例 #1
0
        /// <summary>
        /// Generates a command-line string for launching a <see cref="Verb"/>.
        /// </summary>
        /// <param name="target">The application being integrated.</param>
        /// <param name="verb">The verb to get to launch command for.</param>
        /// <param name="iconStore">Stores icon files downloaded from the web as local files.</param>
        /// <param name="machineWide">Store the stub in a machine-wide directory instead of just for the current user.</param>
        /// <exception cref="IOException">A problem occurred while writing to the filesystem.</exception>
        /// <exception cref="WebException">A problem occurred while downloading additional data (such as icons).</exception>
        /// <exception cref="InvalidOperationException">Write access to the filesystem is not permitted.</exception>
        internal static string GetLaunchCommandLine(FeedTarget target, Verb verb, IIconStore iconStore, bool machineWide)
        {
            string GetRunStub()
            {
                try
                {
                    return(StubBuilder.GetRunStub(target, verb.Command, iconStore, machineWide));
                }
                #region Error handling
                catch (InvalidOperationException ex)
                {
                    // Wrap exception since only certain exception types are allowed
                    throw new IOException(ex.Message, ex);
                }
                #endregion
            }

            if (verb.Arguments.Count == 0)
            {
                string arguments = string.IsNullOrEmpty(verb.ArgumentsLiteral) ? "\"%V\"" : verb.ArgumentsLiteral;
                return(GetRunStub().EscapeArgument() + " " + arguments);
            }

            return(verb.Arguments.Select(x => x.Value)
                   .Prepend(GetRunStub())
                   .JoinEscapeArguments()
                   .Replace("${item}", "\"%V\""));
        }
コード例 #2
0
        /// <summary>
        /// Creates a new Windows shortcut in the "Startup" menu.
        /// </summary>
        /// <param name="autoStart">Information about the shortcut to be created.</param>
        /// <param name="target">The target the shortcut shall point to.</param>
        /// <param name="iconStore">Stores icon files downloaded from the web as local files.</param>
        /// <param name="machineWide">Create the shortcut machine-wide instead of just for the current user.</param>
        public static void Create(AutoStart autoStart, FeedTarget target, IIconStore iconStore, bool machineWide)
        {
            #region Sanity checks
            if (autoStart == null)
            {
                throw new ArgumentNullException(nameof(autoStart));
            }
            if (iconStore == null)
            {
                throw new ArgumentNullException(nameof(iconStore));
            }
            #endregion

            string filePath = GetStartupPath(autoStart.Name, machineWide);
            Create(filePath, targetPath: StubBuilder.GetRunStub(target, autoStart.Command, iconStore));
        }
コード例 #3
0
 /// <summary>
 /// Generates a command-line string for launching a <see cref="Store.Model.Capabilities.Verb"/>.
 /// </summary>
 /// <param name="target">The application being integrated.</param>
 /// <param name="verb">The verb to get to launch command for.</param>
 /// <param name="machineWide">Store the stub in a machine-wide directory instead of just for the current user.</param>
 /// <param name="handler">A callback object used when the the user is to be informed about the progress of long-running operations such as downloads.</param>
 /// <exception cref="IOException">A problem occurs while writing to the filesystem.</exception>
 /// <exception cref="WebException">A problem occured while downloading additional data (such as icons).</exception>
 /// <exception cref="InvalidOperationException">Write access to the filesystem is not permitted.</exception>
 internal static string GetLaunchCommandLine(FeedTarget target, Store.Model.Capabilities.Verb verb, bool machineWide, ITaskHandler handler)
 {
     try
     {
         string launchCommand = "\"" + StubBuilder.GetRunStub(target, verb.Command, handler, machineWide) + "\"";
         if (!string.IsNullOrEmpty(verb.Arguments))
         {
             launchCommand += " " + verb.Arguments;
         }
         return(launchCommand);
     }
     #region Error handling
     catch (InvalidOperationException ex)
     {
         // Wrap exception since only certain exception types are allowed
         throw new IOException(ex.Message, ex);
     }
     #endregion
 }