当前位置: 首页>>代码示例>>C#>>正文


C# CommandLineParser.GetParameterValue方法代码示例

本文整理汇总了C#中CommandLineParser.GetParameterValue方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineParser.GetParameterValue方法的具体用法?C# CommandLineParser.GetParameterValue怎么用?C# CommandLineParser.GetParameterValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandLineParser的用法示例。


在下文中一共展示了CommandLineParser.GetParameterValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HasUseableCommandLine

    /// <summary>
    /// TRUE if we believe there is enough information in the command line to proceed with running the headless task
    /// </summary>
    /// <param name="commandLine"></param>
    /// <returns></returns>
    public static bool HasUseableCommandLine(CommandLineParser commandLine)
    {
        //If the command line does not contain a "-command" argument, then we know there's nothing we can do
        if(string.IsNullOrWhiteSpace(commandLine.GetParameterValue(Parameter_Command)))
        {
            return false;
        }

        return true;
    }
开发者ID:yaswanth369,项目名称:TabMigrate,代码行数:15,代码来源:CommandLineParser_static.cs

示例2: FromCommandLine

    /// <summary>
    /// Creates a TaskMaster from command line arguments
    /// </summary>
    /// <param name="parsedCommandLine"></param>
    /// <returns></returns>
    public static TaskMaster FromCommandLine(CommandLineParser commandLine)
    {
        //----------------------------------------------------------------------
        //Add common options
        //----------------------------------------------------------------------
        var taskOptions = new TaskMasterOptions();
        //Log file
        helper_AddValueIfExists(taskOptions, TaskMasterOptions.OptionParameter_SaveLogFile, commandLine, CommandLineParser.Parameter_LogFile);
        //Error file
        helper_AddValueIfExists(taskOptions, TaskMasterOptions.OptionParameter_SaveErrorsFile, commandLine, CommandLineParser.Parameter_ErrorsFile);
        //Manual steps file
        helper_AddValueIfExists(taskOptions, TaskMasterOptions.OptionParameter_SaveManualSteps, commandLine, CommandLineParser.Parameter_ManualStepsFile);

        //Verbose logging
        if(commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_LogVerbose, false))
        {
            taskOptions.AddOption(TaskMasterOptions.Option_LogVerbose);
        }

        //Background keep alive requests
        if (commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_BackgroundKeepAlive, false))
        {
            taskOptions.AddOption(TaskMasterOptions.Option_BackgroundKeepAlive);
        }

        //----------------------------------------------------------------------------
        //Which command are we dealing with?
        //----------------------------------------------------------------------------
        var commandType = commandLine.GetParameterValue(CommandLineParser.Parameter_Command);

        if(commandType == CommandLineParser.ParameterValue_Command_Inventory)
        {
            return helper_CreateTaskMaster_SiteInventory(
                commandLine.GetParameterValue(CommandLineParser.Parameter_InventoryOutputFile)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_FromSiteUrl)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_FromUserId)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_FromUserPassword)
                ,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_FromSiteIsSystemAdmin)
                ,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_GenerateInventoryTwb, false)
                ,taskOptions
                );
        }
        else if (commandType == CommandLineParser.ParameterValue_Command_Export)
        {
            return helper_CreateTaskMaster_SiteExport(
                commandLine.GetParameterValue(CommandLineParser.Parameter_ExportDirectory)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_FromSiteUrl)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_FromUserId)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_FromUserPassword)
                ,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_FromSiteIsSystemAdmin) || commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_FromSiteIsSiteAdmin)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_ExportSingleProject)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_ExportOnlyWithTag)
                ,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_RemoveTagAfterExport, false)
                ,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_GenerateInfoFilesForDownloads, false)
                , taskOptions
                );
        }
        else if (commandType == CommandLineParser.ParameterValue_Command_Import)
        {
            return helper_CreateTaskMaster_SiteImport(
                commandLine.GetParameterValue(CommandLineParser.Parameter_ImportDirectory)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_ToSiteUrl)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_ToUserId)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_ToUserPassword)
                ,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_ToSiteIsSystemAdmin) || commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_ToSiteIsSiteAdmin)
                ,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_RemapDataserverReferences)
                ,commandLine.GetParameterValue(CommandLineParser.Parameter_DBCredentialsFile)
                ,commandLine.GetParameterValueAsBool(CommandLineParser.Parameter_ImportAssignContentOwnership)
                ,taskOptions
                );
        }

        AppDiagnostics.Assert(false, "Unknown command: " + commandType);
        return null;
    }
开发者ID:tableau,项目名称:TabMigrate,代码行数:80,代码来源:TaskMaster_static.cs

示例3: helper_AddValueIfExists

 /// <summary>
 /// Helper: Adds a command line parameter (if it exists) to the Options colleciton
 /// </summary>
 /// <param name="options"></param>
 /// <param name="optionKey"></param>
 /// <param name="commandLine"></param>
 /// <param name="commandLineKey"></param>
 private static void helper_AddValueIfExists(TaskMasterOptions options, string optionKey, CommandLineParser commandLine, string commandLineKey)
 {
     var commandlineValue = commandLine.GetParameterValue(commandLineKey);
     if (!string.IsNullOrWhiteSpace(commandlineValue))
     {
         options.AddOption(optionKey, commandlineValue);
     }
 }
开发者ID:tableau,项目名称:TabMigrate,代码行数:15,代码来源:TaskMaster_static.cs


注:本文中的CommandLineParser.GetParameterValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。