• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CommandResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Run

		public override void Run(CommandResult rlt, bool isPreview = false)
        {
            if (Condition == null)
            {
				rlt.BoolResult = IsNot ? true : false;
            }
            else
            {
				rlt.BoolResult = IsNot ? !Condition.IsTrue : Condition.IsTrue;
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:11,代码来源:IfCommand.cs


示例17: CommandResultExtensions_ToActionResult_UknownStatusCode

        public void CommandResultExtensions_ToActionResult_UknownStatusCode()
        {
            var cr = new CommandResult()
            {
                HttpStatusCode = System.Net.HttpStatusCode.SwitchingProtocols
            };

            Action a = () => cr.ToActionResult();

            a.ShouldThrow<NotImplementedException>();
        }
开发者ID:dmarlow,项目名称:authservices,代码行数:11,代码来源:CommandResultExtensionsTests.cs


示例18: PrepareRequestAndExecute

 public static CommandResult PrepareRequestAndExecute(Command command, string privateKey, CommandResult.JsonPreparer<Command, CommandResult> baseExecutor)
 {
     var sb = new StringBuilder();
     foreach (
         var parameter in
             command.Parameters)
         if (String.CompareOrdinal(parameter.Key, @"userapp") != 0)
             sb.Append(parameter.Value);
     sb.Append(privateKey ?? "");
     return baseExecutor(command.WithParameter("sum", StringUtils.Md5(sb.ToString())));
 }
开发者ID:acropolium,项目名称:Rest4Net,代码行数:11,代码来源:CommandUtils.cs


示例19: Validate

        public CommandResult Validate(object instance)
        {
            var validationResults = new List<ValidationResult>();
            Validator.TryValidateObject(instance, new ValidationContext(instance), validationResults, true);

            var serviceResult = new CommandResult();

            foreach (var validationResult in validationResults)
                serviceResult.Add(validationResult.MemberNames.Join(", "), validationResult.ErrorMessage);

            return serviceResult;
        }
开发者ID:rtennys,项目名称:Momo,代码行数:12,代码来源:ValidationFacade.cs


示例20: Run

		public override void Run(CommandResult rlt, bool isPreview=false)
		{

			if (!string.IsNullOrEmpty(Id))
			{
				if (!IsReference)
				{
					Executor.Instance.SetVar(Id, IsCondition, this.Clone());
				}
				else
				{
					Executor.Instance.SetVar(Id, IsCondition, this);
				}
			}
			if (!string.IsNullOrEmpty(ContentId))
			{
				string targetId = TargetId;
				if (string.IsNullOrEmpty(targetId))
				{
					targetId = this.Id;
				}
				if (!string.IsNullOrEmpty(targetId))
				{
					object o = Executor.Instance.GetObject(ContentId);
					if (o is string)
					{
						string s = (string)o;
						Executor.Instance.SetVar(targetId, IsCondition, s);
					}
					else if (o is CommandNode)
					{
						CommandNode c = (CommandNode)o;
						if (c != null)
						{
							c.Visible = false;
							if (!IsReference)
							{
								CommandNode cloned = c.Clone();
								cloned.Id = null;
								cloned.Visible = this.Visible;
								Executor.Instance.SetVar(TargetId, IsCondition, cloned);
							}
							else
							{
								c.Visible = Visible;
								Executor.Instance.SetVar(TargetId, IsCondition, c);
							}
						}
					}
				}
			}
		}
开发者ID:mind0n,项目名称:hive,代码行数:52,代码来源:SetCommand.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CommandSet类代码示例发布时间:2022-05-24
下一篇:
C# CommandReader类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap