本文整理汇总了C#中Expression.IsOfType方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.IsOfType方法的具体用法?C# Expression.IsOfType怎么用?C# Expression.IsOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression.IsOfType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessModeNodes
// Replace all mode by ModeExpression instead of TextExpression
private void ProcessModeNodes(Expression expression)
{
if (expression.IsOfType(ExpressionType.Binding) && expression.Has(BindingExpression.MODE))
{
TextExpression text = expression.Get<TextExpression>(BindingExpression.MODE);
if (text != null)
{
BindingMode mode;
if (Enum.TryParse(text.Value, true, out mode))
{
expression.Replace(BindingExpression.MODE, new ModeExpression {Value = mode});
}
else
{
BindingPreprocess.Logger.LogError("Invalid value for Mode in binding Expression actual value is {0}", text.Value);
}
}
else
{
BindingPreprocess.Logger.LogError("Invalid value for Mode in binding expression actual value is of type {0}", expression[BindingExpression.MODE].Type.ToString());
}
}
foreach (Expression child in expression.Attributes.Values)
{
ProcessModeNodes(child);
}
}
示例2: GetUsedResources
private List<string> GetUsedResources(Expression expression)
{
List<string> result = new List<string>();
if (expression.IsOfType(ExpressionType.Resource))
{
result.Add(expression.GetValue(ResourceExpression.KEY));
}
foreach (Expression child in expression.Attributes.Values)
{
result.AddRange(GetUsedResources(child));
}
return result;
}
示例3: GetBindingExpressions
private List<Expression> GetBindingExpressions(Expression expression)
{
List<Expression> result = new List<Expression>();
if (expression.IsOfType(ExpressionType.Binding))
{
result.Add(expression);
}
result.AddRange(expression.Attributes.Values.SelectMany(GetBindingExpressions));
return result;
}
示例4: CheckCorrectExpressionInResource
private bool CheckCorrectExpressionInResource(Expression expr)
{
if (expr.IsOfType(ExpressionType.Binding))
{
return false;
}
foreach (Expression child in expr.Attributes.Values)
{
if (!CheckCorrectExpressionInResource(child))
{
return false;
}
}
return true;
}