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


C# ICommand.Run方法代码示例

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


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

示例1: TryToProceedCommand

        private bool TryToProceedCommand(ICommand command, IEnumerable<string> args)
        {
            if (command != null)
            {
                if (command.Verbose)
                    Console.WriteLine("Proceeding Command: " + command.Name);

                try
                {
                    _commandPropertyWalker.FillCommandProperties(args, command);
                    command.Console = Console;
                    command.Run();
                    return true;
                }
                catch (Exception exception)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Unexpected error happended while proceeding the command: " + command.Name);
                    var exceptionWalker = new ExceptionWalker(exception);
                    foreach (var message in exceptionWalker.GetExceptionMessages())
                    {
                        Console.WriteLine(message);
                    }
                    Console.ResetColor();
                    return false;
                }
            }
            return false;
        }
开发者ID:straeger,项目名称:shell.me,代码行数:29,代码来源:CommandLoop.cs

示例2: Cycle

        protected void Cycle(ICommand command)
        {
            try
            {
                command.Run();

                Thread.Sleep(this.interval);
            }
            catch (TimeoutException)
            {
            }
        }
开发者ID:scottdensmore,项目名称:AzureMultiEntitySchema,代码行数:12,代码来源:CommandHandler.cs

示例3: RunCommand

 private static CommandResult RunCommand(HttpApplication application, ICommand command)
 {
     try
     {
         return command.Run(new HttpRequestWrapper(application.Request));
     }
     catch (AuthServicesException)
     {
         return new CommandResult()
         {
             HttpStatusCode = HttpStatusCode.InternalServerError
         };
     }
 }
开发者ID:roswah,项目名称:authservices,代码行数:14,代码来源:Saml2AuthenticationModule.cs

示例4: RunCommand

 private static CommandResult RunCommand(HttpContext application, ICommand command, IOptions options)
 {
     try
     {
         return command.Run(new HttpRequestWrapper(application.Request).ToHttpRequestData(), options, application.Session);
     }
     catch (OIDCException)
     {
         return new CommandResult
         {
             HttpStatusCode = HttpStatusCode.InternalServerError
         };
     }
 }
开发者ID:biancini,项目名称:OpenIDConnect-Csharp-Client,代码行数:14,代码来源:OpenIDHttpHandler.cs

示例5: RunCommand

		void RunCommand(ICommand command)
		{
			command.Owner = treeView;
			command.Run();
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:5,代码来源:UnitTestsPad.cs

示例6: TryToProceedCommand

        private bool TryToProceedCommand(ICommand command, IEnumerable<string> args)
        {
            if (command != null)
            {
                AbstractTraceConsole traceConsole = null;
                try
                {
                    command.InjectProperties(args);
                    traceConsole = new TraceConsole(Console, command);

                    if (!command.AllowParallel && !_lockingService.AcquireLock(command.Name))
                        return false;

                    command.Console = traceConsole;
                    command.Run();
                    return true;
                }
                catch (Exception exception)
                {
                    LogException(traceConsole, exception, command);
                    return false;
                }
                finally
                {
                    if (!command.AllowParallel)
                        _lockingService.ReleaseLock(command.Name);

                    var disposable = traceConsole as IDisposable;
                    if (disposable != null)
                        disposable.Dispose();
                }

            }
            return false;
        }
开发者ID:dff-solutions,项目名称:shell.me,代码行数:35,代码来源:CommandLoop.cs

示例7: ExecuteCommand

    /// <summary>
    /// Executes a command
    /// </summary>
    /// <param name="cmd">The command to execute</param>
    /// <param name="args">Arguments to apply to the command</param>
    /// <param name="directive">Directives to execute with</param>
    /// <returns>The outcome of the execution</returns>
    private CommandResult ExecuteCommand(ICommand cmd, string[] args, ExecutionDirective directive)
    {
      cmd.Initialise(_context, _formatter);
      CommandResult result = null;

      var manualParseInterface = CommandInspector.GetManualParseCommand(cmd);
      if (manualParseInterface != null)
      {
        var subArgs = from arg in args
                      select Parser.PerformSubstitution(_context, arg);

        result = manualParseInterface.Run(subArgs.ToArray());
      }
      else
      {
        var properties = cmd.GetType().GetProperties();

        object propValue = null;
        var processingArgs = args;

        // Process multi-word named parameters first
        foreach (var prop in properties)
        {
          propValue = null;

          var namedParameterAttribute = CommandInspector.GetNamedParameter(prop);
          if (namedParameterAttribute != null && namedParameterAttribute.WordCount > 1)
          {
            var words = new List<string>();

            for (var i = 0; i < namedParameterAttribute.WordCount; i++)
            {
              var value = string.Empty;
              ParameterUtil.GetParameter(args, "-" + namedParameterAttribute.Name, i, ref value);
              if (!string.IsNullOrEmpty(value))
                words.Add(value);
            }

            if (words.Count > 0)
            {
              propValue = words.ToArray();
              processingArgs = ParameterUtil.RemoveParameter(processingArgs, "-" + namedParameterAttribute.Name, namedParameterAttribute.WordCount);
            }
          }

          ConvertAndAssignParameter(prop, cmd, propValue);
        }

        // Find flags
        var flags = from prop in properties
                    let attr = CommandInspector.GetFlagParameter(prop)
                    where attr != null
                    select attr.Name;

        // Parse remaining arguments
        StringDictionary named = null;
        string[] numbered = null;
        ParameterUtil.ExtractParameters(out named, out numbered, processingArgs, flags.ToArray());

        // Map the parameters to properties
        foreach (var prop in properties)
        {
          propValue = null;

          var namedParameterAttribute = CommandInspector.GetNamedParameter(prop);
          if (namedParameterAttribute != null)
          {
            if (named.ContainsKey(namedParameterAttribute.Name))
              propValue = named[namedParameterAttribute.Name];
          }

          var numberedParameterAttribute = CommandInspector.GetNumberedParameter(prop);
          if (numberedParameterAttribute != null)
          {
            if (numberedParameterAttribute.Number < numbered.Length)
              propValue = numbered[numberedParameterAttribute.Number];
          }

          var flagParameterAttribute = CommandInspector.GetFlagParameter(prop);
          if (flagParameterAttribute != null)
          {
            if (named.ContainsKey(flagParameterAttribute.Name))
            {
#if NET45
              var origVal = (bool)prop.GetValue(cmd);
#else
              var origVal = (bool)prop.GetValue(cmd, null);
#endif
              propValue = !origVal;
            }
          }

          ConvertAndAssignParameter(prop, cmd, propValue);
//.........这里部分代码省略.........
开发者ID:KerwinMa,项目名称:revolver,代码行数:101,代码来源:CommandHandler.cs

示例8: RunCommand

 private static CommandResult RunCommand(HttpApplication application, ICommand command, IOptions options)
 {
     return command.Run(
     new HttpRequestWrapper(application.Request).ToHttpRequestData(),
     options);
 }
开发者ID:Scott-Herbert,项目名称:authservices,代码行数:6,代码来源:Saml2AuthenticationModule.cs


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