本文整理汇总了C#中Expression.Has方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.Has方法的具体用法?C# Expression.Has怎么用?C# Expression.Has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression.Has方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GenerateStatementToGetTranslation
private CodeMethodInvokeExpression GenerateStatementToGetTranslation(CodePropertyReferenceExpression localizationServiceReference, Expression translationExpression)
{
List<CodeExpression> parameters = new List<CodeExpression>();
if (translationExpression.Has(TranslationExpression.UID))
{
//use method with two parameters.
parameters.Add(new CodePrimitiveExpression(translationExpression.GetValue(TranslationExpression.UID)));
}
if (translationExpression.Has(TranslationExpression.KEY))
{
//use method with only key parameter.
parameters.Add(new CodePrimitiveExpression(translationExpression.GetValue(TranslationExpression.KEY)));
}
CodeMethodInvokeExpression valueReference = new CodeMethodInvokeExpression(localizationServiceReference, "GetString", parameters.ToArray());
return valueReference;
}