本文整理汇总了C#中ExecutionContext.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutionContext.GetValue方法的具体用法?C# ExecutionContext.GetValue怎么用?C# ExecutionContext.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext.GetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CircularReferenceTesting2
public void CircularReferenceTesting2(ContextValue[] values)
{
TestDelegate handle = new TestDelegate(() => {
ExecutionContext context = new ExecutionContext(Parser.GetParser());
foreach (ContextValue value in values) {
context.Set(value);
}
context.GetValue("a", null);
});
Assert.Throws<CircularReferenceException>(handle);
}
示例2: ExternalValueTesting
public object ExternalValueTesting(bool caching, ContextValue[] values)
{
Dictionary<string, object> externals = new Dictionary<string, object>();
foreach (ContextValue value in values) {
if (value.ContextType == ContextType.Value) {
externals.Add(value.Name, value.Value);
} else {
externals.Add(value.Name, value);
}
}
ExecutionContext context = new ExecutionContext(Parser.GetParser()) { CacheExternalValue = caching, };
context.TryGetExternalData = new TryGetValueDelegate((string name, object input, out object value) => {
if (input is IDictionary<string, object>) {
return ((IDictionary<string, object>)input).TryGetValue(name, out value);
} else {
value = null;
return true;
}
});
object result = context.GetValue("a", externals);
return result;
}
示例3: ExternalValueWithCircularReference
void ExternalValueWithCircularReference(bool caching, ContextValue[] values)
{
TestDelegate handle = new TestDelegate(() => {
Dictionary<string, object> externals = new Dictionary<string, object>();
foreach (ContextValue value in values) {
if (value.ContextType == ContextType.Value) {
externals.Add(value.Name, value.Value);
} else {
externals.Add(value.Name, value);
}
}
ExecutionContext context = new ExecutionContext(Parser.GetParser()) { CacheExternalValue = caching, };
context.TryGetExternalData = new TryGetValueDelegate((string name, object input, out object value) => {
if (input is IDictionary<string, object>) {
return ((IDictionary<string, object>)input).TryGetValue(name, out value);
} else {
value = null;
return true;
}
});
context.GetValue("a", externals);
});
Assert.Throws<CircularReferenceException>(handle);
}