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


C# CommandLineParser.GetParameterValueAsBool方法代码示例

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


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

示例1: 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


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