本文整理汇总了C#中System.Result.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Result.SetValue方法的具体用法?C# Result.SetValue怎么用?C# Result.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Result
的用法示例。
在下文中一共展示了Result.SetValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_call_graphite_using_TCP
public void Should_call_graphite_using_TCP()
{
var result = new Result("name", new DateTime(2012, 11, 10, 9, 8, 7), "path");
result.SetValue(1);
var graphiteClient = new GraphiteTcpClient("metrics.london.ttldev.local", 2003);
graphiteClient.Send(result);
}
示例2: Should_return_a_graphite_message_list
public void Should_return_a_graphite_message_list()
{
var list = new List<IResult>();
var res = new Result("name", new DateTime(2012, 12, 11, 10, 9, 8), "path");
res.SetValue(123);
list.Add(res);
var graphiteMetrics = new GraphiteMetrics(list);
var msgList = graphiteMetrics.ToGraphiteMessageList();
string msg = "path.name 123 1355220548\n";
Assert.That(msgList, Is.EqualTo(msg));
}
示例3: Should_send_list_to_graphite_udp
public void Should_send_list_to_graphite_udp()
{
var graphiteUdp = new Graphite.GraphiteUdpClient("metrics.london.ttldev.local");
var res = new List<IResult>();
var p1 = new Result("name", DateTime.Now, "test.path1");
p1.SetValue(20);
var p2 = new Result("name", DateTime.Now, "test.path2");
p2.SetValue(20);
var p3 = new Result("name", DateTime.Now, "test.path3");
p3.SetValue(30);
res.Add(p1);
//res.Add(p2);
//res.Add(p3);
graphiteUdp.Send(new GraphiteMetrics(res));
}
示例4: Get
public override IList<IResult> Get()
{
var rtn = new List<IResult>();
try
{
foreach (var o in this.GetWmiObject(this.Sql, this.machineName, RootPath))
{
var value = -1;
var dateTime = DateTime.Now;
var name = string.Empty;
foreach (var col in o.Properties)
{
if (col.Type == CimType.String)
{
name = Convert.ToString(col.Value);
}
if (col.Type == CimType.UInt32)
{
value = Convert.ToInt32(col.Value);
}
if (col.Type == CimType.UInt64)
{
value = Convert.ToInt32(col.Value);
}
if (col.Type == CimType.DateTime)
{
dateTime = Convert.ToDateTime(col.Value);
}
}
this.Log.Debug(string.Format("Name {0} value {1} datetime {2}", name, value, dateTime));
var r = new Result(name, dateTime, this.Path);
r.SetValue(value);
rtn.Add(r);
}
}
catch (ManagementException e)
{
this.Log.Error(string.Format("Error with {0} {1} {2}", this.Type, this.Path, this.Sql));
this.Log.Error(e.Message);
this.Log.Error(e.StackTrace);
}
return rtn;
}
示例5: Map
private Result Map(IDataRecord record)
{
var value = -1;
var dateTime = DateTime.Now;
var name = string.Empty;
for (int i = 0; i < record.FieldCount; i++)
{
if (record[i] is string)
{
name = Convert.ToString(record.GetValue(i));
}
if (record[i] is int)
{
value = record.GetInt32(i);
}
if (record[i] is DateTime)
{
dateTime = record.GetDateTime(i);
}
}
this.Log.Debug(string.Format("Got [{1}] {0}", value, dateTime));
var r = new Result(name, dateTime, this.Path);
r.SetValue(value);
return r;
}
示例6: InvokeSafely
/// <summary>
/// Used by the safe synchronization delegate.
/// </summary>
/// <param name="invocation">The invocation.</param>
/// <param name="result">The result holder.</param>
private static void InvokeSafely(IInvocation invocation, Result result)
{
if (result == null)
{
invocation.Proceed();
}
else
{
try
{
invocation.Proceed();
result.SetValue(false, invocation.ReturnValue);
}
catch (Exception exception)
{
result.SetException(false, exception);
}
}
}
示例7: InvokeSynchronously
/// <summary>
/// Continues the invocation synchronously.
/// </summary>
/// <param name="invocation">The invocation.</param>
/// <param name="result">The result holder.</param>
private static void InvokeSynchronously(IInvocation invocation, Result result)
{
invocation.Proceed();
result = result ?? CreateResult(invocation);
if (result != null)
{
result.SetValue(true, invocation.ReturnValue);
}
}
示例8: TotalFailed
private Result TotalFailed(CcTray tray, DateTime now)
{
var totalFailed = new Result("TotalFailed", now, this.Path);
totalFailed.SetValue(tray.FailedPipelines().Count);
return totalFailed;
}
示例9: Map
private Result Map(DataRow record)
{
var value = -1;
var dateTime = DateTime.Now;
var name = string.Empty;
for (int i = 0; i < record.ItemArray.Length; i++)
{
if (record[i] is string)
{
name = Convert.ToString(record[i]);
}
if (record[i] is int || record[i] is decimal)
{
value = Convert.ToInt32(record[i]);
}
if (record[i] is DateTime)
{
dateTime = Convert.ToDateTime(record[i]);
}
}
this.Log.Debug(string.Format("Got [{1}] {0}", value, dateTime));
var res = new Result(name, dateTime, this.Path);
res.SetValue(value);
return res;
}
示例10: Map
private Result Map(ILogRecord record)
{
var value = -1;
var dateTime = DateTime.Now;
var name = string.Empty;
var r = record.getValue(0);
if ((r is string))
{
name = Convert.ToString(r);
}
if ((r is int) || (r is decimal))
{
value = Convert.ToInt32(r);
}
r = record.getValue(1);
if ((r is string))
{
name = Convert.ToString(r);
}
if ((r is int) || (r is decimal))
{
value = Convert.ToInt32(r);
}
//Console.WriteLine(record.getValue(0).GetType());
//Console.WriteLine(record.getValue(1).GetType());
try
{
//Console.WriteLine(record.getValue(2));
}
catch (Exception ex)
{
var s = ex.Message;
}
//Console.WriteLine(string.Format("{0} {1}", record.getValue(0), record.getValue(1)));
//for (int i = 0; i < record.; i++)
//{
// if (record[i] is string)
// {
// name = Convert.ToString(record[i]);
// }
// if (record[i] is int || record[i] is decimal)
// {
// value = Convert.ToInt32(record[i]);
// }
// if (record[i] is DateTime)
// {
// dateTime = Convert.ToDateTime(record[i]);
// }
//}
if (this.Name != string.Empty && name == string.Empty)
{
name = this.Name;
}
this.Log.Debug(string.Format("Got [{1}] {0}", value, dateTime));
var result = new Result(name, dateTime, this.Path);
result.SetValue(value);
return result;
}