本文整理汇总了C#中IContext.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# IContext.ContainsKey方法的具体用法?C# IContext.ContainsKey怎么用?C# IContext.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContext
的用法示例。
在下文中一共展示了IContext.ContainsKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Handle
public override void Handle(IContext context)
{
//Console.Write(this.GetType().Name);
var input = (char)context.Input;
if (input == '"')
{
context.Next = new StateA1();
context["actual-field"] = new StringBuilder();
if (!context.ContainsKey("actual-line"))
context["actual-line"] = new List<string>();
context.Next = new StateA1();
}
}
示例2: Execute
public override object Execute(IContext context, Stream writer)
{
object obj = _collection.Execute(context, writer);
object varData = null;
if (context.ContainsKey(_varName))
{
varData = context[_varName];
}
if (obj is IEnumerable)
{
IEnumerable em = (IEnumerable)obj;
int index = 0;
bool isOdd = true;
string indexName = _varName + "_index";
string oddName = _varName + "_odd";
object indexData;
object oddData;
context.TryGetValue(indexName, out indexData);
context.TryGetValue(oddName, out oddData);
foreach (object o in em)
{
try
{
context[_varName] = o;
context[indexName] = index++;
context[oddName] = isOdd;
_blockStatement.Execute(context, writer);
isOdd = !isOdd;
context.Remove(_varName);
context.Remove(indexName);
context.Remove(oddName);
}
catch (BreakException)
{
break;
}
catch (ContinueException)
{
continue;
}
}
if (indexData != null)
{
context[indexName] = indexData;
}
if (oddData != null)
{
context[oddName] = oddData;
}
}
else
{
if (obj != null)
{
PropertyInfo[] properties = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo info in properties)
{
try
{
context[_varName] = info.GetValue(obj, null);
_blockStatement.Execute(context, writer);
context.Remove(_varName);
}
catch (BreakException)
{
break;
}
catch (ContinueException)
{
continue;
}
}
}
}
if (varData != null)
{
context[_varName] = varData;
}
return null;
}