本文整理汇总了C#中Results.TryFind方法的典型用法代码示例。如果您正苦于以下问题:C# Results.TryFind方法的具体用法?C# Results.TryFind怎么用?C# Results.TryFind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Results
的用法示例。
在下文中一共展示了Results.TryFind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DecodeTelemetryEvent
public bool DecodeTelemetryEvent(Results results, out string eventName, out KeyValuePair<string, object>[] properties)
{
properties = null;
// NOTE: the message event is an MI Extension from clrdbg, though we could use in it the future for other debuggers
eventName = results.TryFindString("event-name");
if (string.IsNullOrEmpty(eventName) || !char.IsLetter(eventName[0]) || !eventName.Contains('/'))
{
Debug.Fail("Bogus telemetry event. 'Event-name' property is missing or invalid.");
return false;
}
TupleValue tuple;
if (!results.TryFind("properties", out tuple))
{
Debug.Fail("Bogus message event, missing 'properties' property");
return false;
}
List<KeyValuePair<string, object>> propertyList = new List<KeyValuePair<string, object>>(tuple.Content.Count);
foreach (NamedResultValue pair in tuple.Content)
{
ConstValue resultValue = pair.Value as ConstValue;
if (resultValue == null)
continue;
string content = resultValue.Content;
if (string.IsNullOrEmpty(content))
continue;
object value = content;
int numericValue;
if (content.Length >= 3 && content.StartsWith("0x", StringComparison.OrdinalIgnoreCase) && int.TryParse(content.Substring(2), NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out numericValue))
{
value = numericValue;
}
else if (int.TryParse(content, NumberStyles.None, CultureInfo.InvariantCulture, out numericValue))
{
value = numericValue;
}
if (value != null)
{
propertyList.Add(new KeyValuePair<string, object>(pair.Name, value));
}
}
properties = propertyList.ToArray();
// If we are processing a clrdbg ProcessCreate event, save the event properties so we can use them to send other events
if (eventName == "VS/Diagnostics/Debugger/clrdbg/ProcessCreate")
{
_clrdbgProcessCreateProperties = properties;
}
return true;
}