本文整理汇总了C#中Result.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Result.ToString方法的具体用法?C# Result.ToString怎么用?C# Result.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Result
的用法示例。
在下文中一共展示了Result.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSelectedCount
public int GetSelectedCount(Result result)
{
if (Records.ContainsKey(result.ToString()))
{
return Records[result.ToString()];
}
return 0;
}
示例2: Notify
public override void Notify(Result message)
{
// Perform notification using the information in the result.
// Will only be invoked when the result value meets the threshold so there's no need to check that.
Console.WriteLine(message.ToString());
}
示例3: Add
public void Add(Result result)
{
if (Records.ContainsKey(result.ToString()))
{
Records[result.ToString()] += 1;
}
else
{
Records.Add(result.ToString(), 1);
}
//hasAddedCount++;
//if (hasAddedCount == 10)
//{
// hasAddedCount = 0;
//}
CommonStorage.Instance.Save();
}
示例4: CreateMessage
protected override MailMessage CreateMessage(Result result)
{
MailMessage mail = new MailMessage();
mail.To.Add(ConvertToEmailAddresses(Audience));
mail.From = new MailAddress(FromEmailAddress);
// Don't worry about a subject, just send all the info in the body
mail.Body = result.ToString();
return mail;
}
示例5: CreateMessage
protected virtual MailMessage CreateMessage(Result result)
{
MailMessage mail = new MailMessage();
mail.To.Add(Audience);
mail.From = new MailAddress(FromEmailAddress);
mail.Subject = result.ActionName + " " + result.Value.ToString() + "ed";
mail.Body = result.ToString();
return mail;
}
示例6: ResolveResult
private Result ResolveResult()
{
var currentState = States.CopyingLiterals;
var result = new Result();
StringBuilder currentExpression = null;
foreach (var character in _template.ToCharArray())
{
switch (currentState)
{
case States.CopyingLiterals:
if (character == '{')
{
currentState = States.ParsingExpression;
currentExpression = new StringBuilder();
}
else if (character == '}')
{
throw new ArgumentException("Malformed template, unexpected } : " + result.ToString());
}
else
{
result.Append(character);
}
break;
case States.ParsingExpression:
if (character == '}')
{
ProcessExpression(currentExpression, result);
currentState = States.CopyingLiterals;
}
else
{
currentExpression.Append(character);
}
break;
}
}
if (currentState == States.ParsingExpression)
{
result.Append("{");
result.Append(currentExpression.ToString());
throw new ArgumentException("Malformed template, missing } : " + result.ToString());
}
if (result.ErrorDetected)
{
throw new ArgumentException("Malformed template : " + result.ToString());
}
return result;
}
示例7: Run
/// <summary>
/// Executes the tool with the specified arguments
/// </summary>
/// <param name="arguments">The arguments to pass on the command line. The value of arguments will be persisted in the Arguments property.</param>
/// <returns>A Result object containing data about the run</returns>
public virtual Result Run(string arguments)
{
if (String.Empty == this.ToolFile)
{
throw new Exception("The tool is not specified");
}
// Expand environment variables in the tool file
string expandedToolFile = Environment.ExpandEnvironmentVariables(this.ToolFile);
if (!File.Exists(expandedToolFile))
{
throw new FileNotFoundException(String.Format("The file {0} could not be found", expandedToolFile), expandedToolFile);
}
Process process = new Process();
process.StartInfo.FileName = expandedToolFile;
process.StartInfo.Arguments = Environment.ExpandEnvironmentVariables(arguments);
process.StartInfo.WorkingDirectory = Environment.ExpandEnvironmentVariables(this.WorkingDirectory);
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
foreach(string environmentVariable in this.EnvironmentVariables.Keys)
{
if (!process.StartInfo.EnvironmentVariables.ContainsKey(environmentVariable))
{
process.StartInfo.EnvironmentVariables.Add(environmentVariable, this.EnvironmentVariables[environmentVariable]);
}
else
{
process.StartInfo.EnvironmentVariables[environmentVariable] = this.EnvironmentVariables[environmentVariable];
}
}
// RunAsUser
if (null != this.RunAsUser)
{
process.StartInfo.Domain = RunAsUser.Domain;
process.StartInfo.UserName = RunAsUser.Username;
process.StartInfo.Password = new System.Security.SecureString();
process.StartInfo.Password.Clear(); // Make sure there is no junk
foreach (char c in RunAsUser.Password.ToCharArray())
{
process.StartInfo.Password.AppendChar(c);
}
process.StartInfo.LoadUserProfile = true;
}
// Create the Result object
Result result = new Result();
result.Command = this.CommandLine;
try
{
// Run the process
process.Start();
StringBuilder standardOutput = new StringBuilder();
while (!process.StandardOutput.EndOfStream)
{
standardOutput.AppendLine(process.StandardOutput.ReadLine());
}
result.StandardOutput = standardOutput.ToString();
StringBuilder standardError = new StringBuilder();
while (!process.StandardError.EndOfStream)
{
standardError.AppendLine(process.StandardError.ReadLine());
}
result.StandardError = standardError.ToString();
process.WaitForExit();
result.ExitCode = process.ExitCode;
}
finally
{
if (null != process)
{
process.Close();
}
}
if (this.PrintOutputToConsole)
{
Console.WriteLine(result.ToString());
}
this.Results.Push(result);
return result;
}
示例8: Notify
public override void Notify(Result message)
{
Console.WriteLine(message.ToString());
}