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


C# CommandResult类代码示例

本文整理汇总了C#中CommandResult的典型用法代码示例。如果您正苦于以下问题:C# CommandResult类的具体用法?C# CommandResult怎么用?C# CommandResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Result_should_wire_the_success_and_failure_results

		public void Result_should_wire_the_success_and_failure_results()
		{
			var result = new CommandResult<Message, Entity>(new Message(), entity => new ViewResult {ViewName = "foo"},
			                                                message => new ViewResult {ViewName = "bar"});
			result.Success.AssertViewRendered().ForView("foo");
			result.Failure.AssertViewRendered().ForView("bar");
		}
开发者ID:sthapa123,项目名称:codecampserver,代码行数:7,代码来源:CommandResultTester.cs

示例2: Run

		public override void Run(CommandResult rlt, bool isPreview = false)
		{
			if (!IsBypass)
			{
				Process.Start(Executor.Instance.ParseIdString(Cmd), Executor.Instance.ParseIdString(Args));
			}
		}
开发者ID:mind0n,项目名称:hive,代码行数:7,代码来源:RunCommand.cs

示例3: Should_invoke_a_command_with_flags

        public void Should_invoke_a_command_with_flags()
        {
            var commandResult = new CommandResult
            {
                MatchResults = new List<IMatchResult>
                {
                    new MatchResult()
                },
                OptionalMatchResults = new List<IMatchResult>
                {
                    new NamedValueMatchResult("option", "value")
                }
            };

            dynamic parameterResults = null;
            dynamic flagResults = null;
            var command = new Command("command [-o|option]", (parameters, flags) => {
                parameterResults = parameters;
                flagResults = flags;
            });

            var commandInvoker = new DefaultCommandInvoker();

            commandInvoker.Invoke(commandResult, command);

            Assert.NotNull(parameterResults);
            Assert.Empty((ExpandoObject)parameterResults);
            Assert.NotNull(flagResults);
            Assert.Equal(1, ((ExpandoObject)flagResults).Count());
            Assert.Equal("value", flagResults.option);
        }
开发者ID:rlgnak,项目名称:Clif,代码行数:31,代码来源:DefaultCommandInvokerTests.cs

示例4: RunAndWaitForExit

        public CommandResult RunAndWaitForExit()
        {
            CommandResult result = new CommandResult();
            using (Process process = Process.Start(CreateStartInfo(_command, _args)))
            {
                if (!string.IsNullOrEmpty(_input))
                {
                    using (StreamWriter inputWriter = process.StandardInput)
                    {
                        inputWriter.Write(_input);
                    }
                }

                process.WaitForExit();
                result.ExitCode = process.ExitCode;
                using (StreamReader outputReader = process.StandardOutput)
                {
                    result.Output = outputReader.ReadToEnd();
                }
                using (StreamReader errorReader = process.StandardError)
                {
                    result.Error = errorReader.ReadToEnd();
                }
                return result;
            }
        }
开发者ID:dyang,项目名称:P4Cmdlets,代码行数:26,代码来源:Command.cs

示例5: AddModelErrors

        public static ModelStateDictionary AddModelErrors(this ModelStateDictionary modelState, CommandResult result)
        {
            foreach (var error in result.Errors)
                modelState.AddModelError(error.Key, error.Error);

            return modelState;
        }
开发者ID:rtennys,项目名称:Momo,代码行数:7,代码来源:ModelStateDictionaryExtensions.cs

示例6: Execute

        public override CommandResult Execute(CommandTreeViewNode node = null)
        {
			CommandResult rlt = new CommandResult();
			try
			{
				object resultValue = new CommandResult();
				if (string.Equals(CommandExecutionContext.Instance.CurrentMachine.Address, ".") || string.Equals(CommandExecutionContext.Instance.CurrentMachine.Address, "127.0.0.1"))
				{
					ProcessStartInfo info = new ProcessStartInfo();
					info.FileName = "cmd.exe";
					info.Arguments = string.Format("/c {0}", this.Command_Line);
					Process.Start(info);
				}
				else
				{
					resultValue = RemoteExecute(this.Command_Line);
				}
				rlt.ResultValue = resultValue;
			}
			catch (Exception e)
			{
				rlt.LastError = e;
			}
			return rlt;
        }
开发者ID:mind0n,项目名称:hive,代码行数:25,代码来源:RemoteExecuteCommand.cs

示例7: ExecuteInternal

		private CommandResult ExecuteInternal()
		{
			CommandResult result = new CommandResult();
			if (Is_Running)
			{
				while (!isCancelling)
				{
					using (ServiceController sc = new ServiceController(Service_Name, CommandExecutionContext.Instance.CurrentMachine.Address))
					{
						if (sc.Status == ServiceControllerStatus.Running)
						{
							break;
						}
					}
					Thread.Sleep(Interval);
				}
			}
			else
			{
				while (!isCancelling)
				{
					using (ServiceController sc = new ServiceController(Service_Name, CommandExecutionContext.Instance.CurrentMachine.Address))
					{
						if (sc.Status == ServiceControllerStatus.Stopped)
						{
							break;
						}
					}
					Thread.Sleep(Interval);
				}
			}
			base.AccomplishCancellation();
			return result;
		}
开发者ID:mind0n,项目名称:hive,代码行数:34,代码来源:ServiceManipulateCommand.cs

示例8: Saml2RedirectBinding_Bind

        public void Saml2RedirectBinding_Bind()
        {
            // Example from http://en.wikipedia.org/wiki/SAML_2.0#HTTP_Redirect_Binding
            var xmlData = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<samlp:AuthnRequest
  xmlns:samlp=""urn:oasis:names:tc:SAML:2.0:protocol""
  xmlns:saml=""urn:oasis:names:tc:SAML:2.0:assertion""
  ID=""aaf23196-1773-2113-474a-fe114412ab72""
  Version=""2.0""
  IssueInstant=""2004-12-05T09:21:59Z""
  AssertionConsumerServiceIndex=""0""
  AttributeConsumingServiceIndex=""0"">
  <saml:Issuer>https://sp.example.com/SAML2</saml:Issuer>
  <samlp:NameIDPolicy
    AllowCreate=""true""
    Format=""urn:oasis:names:tc:SAML:2.0:nameid-format:transient""/>
</samlp:AuthnRequest>
";


            var serializedData = "fZFfa8IwFMXfBb9DyXvaJtZ1BqsURRC2Mabbw95ivc5Am3TJrXPffmmLY3%2fA15Pzuyf33On8XJXBCaxTRmeEhTEJQBdmr%2fRbRp63K3pL5rPhYOpkVdYib%2fCon%2bC9AYfDQRB4WDvRvWWksVoY6ZQTWlbgBBZik9%2ffCR7GorYGTWFK8pu6DknnwKL%2fWEetlxmR8sBHbHJDWZqOKGdsRJM0kfQAjCUJ43KX8s78ctnIz%2blp5xpYa4dSo1fjOKGM03i8jSeCMzGevHa2%2fBK5MNo1FdgN2JMqPLmHc0b6WTmiVbsGoTf5qv66Zq2t60x0wXZ2RKydiCJXh3CWVV1CWJgqanfl0%2bin8xutxYOvZL18NKUqPlvZR5el%2bVhYkAgZQdsA6fWVsZXE63W2itrTQ2cVaKV2CjSSqL1v9P%2fAXv4C"; // hand patched with lower case version of UrlEncode characters to match the .NET UrlDecode output
            var destinationUri = new Uri("http://www.example.com/acs");

            var subject = Saml2Binding.Get(Saml2BindingType.HttpRedirect).Bind(xmlData, destinationUri, null);

            var expected = new CommandResult()
            {
                Location = new Uri("http://www.example.com/acs?SAMLRequest=" + serializedData),
                HttpStatusCode = System.Net.HttpStatusCode.SeeOther,
            };

            subject.ShouldBeEquivalentTo(expected);
        }
开发者ID:dmarlow,项目名称:authservices,代码行数:33,代码来源:Saml2RedirectBindingTests.cs

示例9: Run

	    public override void Run(CommandResult rlt, bool isPreview = false)
	    {
	        tfsroot = Executor.Instance.ParseIdString(TfsRoot);
	        srcbranch = Executor.Instance.ParseIdString(SrcBranch);
	        desbranch = Executor.Instance.ParseIdString(DesBranch);
	        tool = Executor.Instance.ParseIdString(Tool);
	        AppendSymbol(ref tfsroot);
	        foreach (string i in SrcFiles)
	        {
	            string src = i;
	            if (src.StartsWith("###"))
	            {
	                src = src.Replace("###", tfsroot);
	            }
	            else if (src.StartsWith("$/Root") || src.StartsWith("$\\Root"))
	            {
	                src = src.Replace("$/Root", tfsroot);
	                src = src.Replace("$\\Root", tfsroot);
	                src = src.Replace("/", "\\");
	                src = src.Replace("\\\\", "\\");
	            }
	            if (!src.EndsWith("\\"))
	            {
	                Compare(src);
	            }
	            else
	            {
	                string[] files = Directory.GetFiles(src, "*.*", SearchOption.AllDirectories);
	                foreach (string file in files)
	                {
	                    Compare(file);
	                }
	            }
	        }
	    }
开发者ID:mind0n,项目名称:hive,代码行数:35,代码来源:BranchCompairCommand.cs

示例10: RunCommand

    public CommandResult RunCommand(string command)
    {
        CommandResult result = new CommandResult();

        MemoryStream ms = new MemoryStream();
        try
        {
            m_pythonEngine.Runtime.IO.SetOutput(ms, new StreamWriter(ms, Encoding.UTF8));
            object o = m_pythonEngine.Execute(command, m_scriptScope);
            result.output = ReadStream(ms);
            if (o != null)
            {
                result.returnValue = o;
                m_scriptScope.SetVariable("_", o);
                try
                {
                    string objectStr = m_pythonEngine.Execute("repr(_)", m_scriptScope).ToString();
                    result.returnValueStr = objectStr;
                }
                catch
                {
                    result.returnValueStr = o.ToString();
                }
            }
        }
        catch (System.Exception e)
        {
            result.output = ReadStream(ms);
            result.exception = e;
        }
        ms.Dispose();

        return result;
    }
开发者ID:stmbenn,项目名称:PixelJam,代码行数:34,代码来源:PythonEnvironment.cs

示例11: RaiseCommandRan

 public void RaiseCommandRan(CommandRunData data, CommandResult result)
 {
     var e = CommandRan;
     if (e != null)
     {
         e(this, Tuple.Create(data, result));
     }
 }
开发者ID:rride,项目名称:VsVim,代码行数:8,代码来源:MockCommandRunner.cs

示例12: Execute

 public override CommandResult Execute(CommandTreeViewNode node = null)
 {
     CommandResult result = new CommandResult();
     CommandExecutionContext.Instance.CurrentMachine.DomainUsername = Username;
     CommandExecutionContext.Instance.CurrentMachine.Password = Password;
     CommandExecutionContext.Instance.CurrentMachine.Address = Address;
     return result;
 }
开发者ID:mind0n,项目名称:hive,代码行数:8,代码来源:ChangeServerCommand.cs

示例13: AssertInsertWithTransaction

 protected void AssertInsertWithTransaction(CommandResult result)
 {
     Assert.True(result.IsCompleted);
     var modeSwitch = result.AsCompleted().Item;
     Assert.True(modeSwitch.IsSwitchModeWithArgument);
     var data = modeSwitch.AsSwitchModeWithArgument();
     Assert.Equal(ModeKind.Insert, data.Item1);
     Assert.True(data.Item2.IsInsertWithTransaction);
 }
开发者ID:louisfeng,项目名称:VsVim,代码行数:9,代码来源:CommandUtilTest.cs

示例14: Run

		public override void Run(CommandResult rlt, bool isPreview = false)
		{
			ConnectCommand cn = Executor.Instance.Get<ConnectCommand>(ConnectionId);
			
			ImpersonateUser iu = new ImpersonateUser();
				iu.Impersonate(cn.Domain, cn.User, cn.Pwd);
				ExecuteInternal(cn);
				iu.Undo();
		}
开发者ID:mind0n,项目名称:hive,代码行数:9,代码来源:ServiceCommand.cs

示例15: GetError

        public static Exception GetError(XName commandName, CommandResult result, SqlDataReader reader)
        {
            Exception returnValue = null;

            if (result != CommandResult.Success)
            {
                switch (result)
                {
                    case CommandResult.InstanceAlreadyExists:
                        returnValue = new InstanceCollisionException(commandName, reader.GetGuid(1));
                        break;
                    case CommandResult.InstanceLockNotAcquired:
                        returnValue = new InstanceLockedException(commandName, reader.GetGuid(1), reader.GetGuid(2), ReadLockOwnerMetadata(reader));
                        break;
                    case CommandResult.InstanceNotFound:
                        returnValue = new InstanceNotReadyException(commandName, reader.GetGuid(1));
                        break;
                    case CommandResult.KeyAlreadyExists:
                        returnValue = new InstanceKeyCollisionException(commandName, Guid.Empty,
                            new InstanceKey(reader.GetGuid(1)), Guid.Empty);
                        break;
                    case CommandResult.KeyNotFound:
                        returnValue = new InstanceKeyNotReadyException(commandName, new InstanceKey(reader.GetGuid(1)));
                        break;
                    case CommandResult.InstanceLockLost:
                        returnValue = new InstanceLockLostException(commandName, reader.GetGuid(1));
                        break;
                    case CommandResult.InstanceCompleted:
                        returnValue = new InstanceCompleteException(commandName, reader.GetGuid(1));
                        break;
                    case CommandResult.KeyDisassociated:
                        returnValue = new InstanceKeyCompleteException(commandName, new InstanceKey(reader.GetGuid(1)));
                        break;
                    case CommandResult.StaleInstanceVersion:
                        returnValue = new InstanceLockLostException(commandName, reader.GetGuid(1));
                        break;
                    case CommandResult.HostLockExpired:
                        returnValue = new InstancePersistenceException(SR.HostLockExpired);
                        break;
                    case CommandResult.HostLockNotFound:
                        returnValue = new InstancePersistenceException(SR.HostLockNotFound);
                        break;
                    case CommandResult.CleanupInProgress:
                        returnValue = new InstancePersistenceCommandException(SR.CleanupInProgress);
                        break;
                    case CommandResult.InstanceAlreadyLockedToOwner:
                        returnValue = new InstanceAlreadyLockedToOwnerException(commandName, reader.GetGuid(1), reader.GetInt64(2));
                        break;
                    default:
                        returnValue = new InstancePersistenceCommandException(SR.UnknownSprocResult(result));
                        break;
                }
            }

            return returnValue;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:56,代码来源:StoreUtilities.cs


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