src/VirtualAutoClicker/ConsoleHelper.cs
/// <summary>
/// Returns an updated array of input arguments
/// </summary>
/// <param name="arguments"></param>
/// <returns>A rebuilt list of input arguments</returns>
Returns an updated array of input arguments
Returns an updated array of input arguments
public static string[] GetInputArguments(List<string> arguments)
        {
            var processNameBuilder = new StringBuilder();
            if (arguments.Count(arg => arg.Contains("\"", StringComparison.InvariantCultureIgnoreCase)) <= 0)
            {
                return arguments.ToArray();
            }
            var doubleQuoteIndex = arguments.FindIndex(arg => arg.StartsWith('"'));
            var endingIndex = -1;
            for (var i = 0; i < arguments.Count; i++)
            {
                if (arguments[i].EndsWith('"'))
                {
                    endingIndex = i;
                }
            }
            if (endingIndex == -1)
            {
                return arguments.ToArray();
            }
            for (var i = doubleQuoteIndex; i <= endingIndex; i++)
            {
                processNameBuilder.Append($"{arguments[i]} ");
            }
            var processName = processNameBuilder.ToString().TrimEnd();
            processName = processName.Replace("\"", "");
            arguments.RemoveRange(doubleQuoteIndex, endingIndex + 1);
            arguments = arguments
                .Prepend(processName)
                .ToList();
            return arguments.ToArray();
        }
public static string [ ] GetInputArguments ( List < string > arguments ) { var processNameBuilder = new StringBuilder ( ) ; if ( arguments . Count ( arg => arg . Contains ( " \" " , StringComparison . InvariantCultureIgnoreCase ) ) <= 0 ) { return arguments . ToArray ( ) ; } var doubleQuoteIndex = arguments . FindIndex ( arg => arg . StartsWith ( ' ' ) ) ; var endingIndex = - 1 ; for ( var i = 0 ; i < arguments . Count ; i ++ ) { if ( arguments [ i ] . EndsWith ( ' ' ) ) { endingIndex = i ; } } if ( endingIndex == - 1 ) { return arguments . ToArray ( ) ; } for ( var i = doubleQuoteIndex ; i <= endingIndex ; i ++ ) { processNameBuilder . Append ( $" { arguments [ i ] } " ) ; } var processName = processNameBuilder . ToString ( ) . TrimEnd ( ) ; processName = processName . Replace ( " \" " , " " ) ; arguments . RemoveRange ( doubleQuoteIndex , endingIndex + 1 ) ; arguments = arguments . Prepend ( processName ) . ToList ( ) ; return arguments . ToArray ( ) ; }
Returns an updated array of input arguments
Returns an updated array of input arguments
// Attempt to find the index of the ending double quote // We failed to find an ending double quote. // Ensure the process name does not end with a space. // Rebuild the arguments list with the new "merged" process name
A rebuilt list of input arguments
A rebuilt list of input arguments
arguments
List<string>
None