本文整理汇总了C#中IExpressionNode.Accept方法的典型用法代码示例。如果您正苦于以下问题:C# IExpressionNode.Accept方法的具体用法?C# IExpressionNode.Accept怎么用?C# IExpressionNode.Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExpressionNode
的用法示例。
在下文中一共展示了IExpressionNode.Accept方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasGetErrorsMethod
private bool HasGetErrorsMethod(ref IExpressionNode node)
{
_errorPathNames.Clear();
node = node.Accept(this);
return _errorPathNames.Count != 0;
}
示例2: GetBindingValueSetterMain
private Action<IDataContext> GetBindingValueSetterMain(IExpressionNode node, Action<IDataContext, object> setSimpleValue,
Action<IDataContext, Func<IDataContext, object>> setComplexValue, bool useBindingForMember)
{
var constantNode = node as IConstantExpressionNode;
if (constantNode != null)
{
object value = constantNode.Value;
return context => setSimpleValue(context, value);
}
try
{
node = node.Accept(_memberVisitor);
if (_memberVisitor.IsMulti)
{
var members = _memberVisitor.Members.ToArrayEx();
var bindingSource = members.Length == 0
? Empty.Array<Func<IDataContext, IObserver>>()
: new Func<IDataContext, IObserver>[members.Length];
for (int i = 0; i < members.Length; i++)
bindingSource[i] = GetBindingSourceDelegate(members[i].Value);
var invoker = CreateExpressionInvoker(node, members, members.Length == 0);
return context =>
{
var sources = bindingSource.Length == 0
? Empty.Array<IObserver>()
: new IObserver[bindingSource.Length];
for (int i = 0; i < bindingSource.Length; i++)
sources[i] = bindingSource[i].Invoke(context);
setComplexValue(context, dataContext =>
{
object[] args;
if (sources.Length == 0)
args = Empty.Array<object>();
else
{
args = new object[sources.Length];
for (int i = 0; i < sources.Length; i++)
args[i] = sources[i].GetCurrentValue();
}
try
{
return invoker.Invoke(dataContext, args);
}
catch (Exception e)
{
Tracer.Error(e.Message);
return null;
}
});
};
}
else
{
if (_memberVisitor.Members.Count == 0)
{
var value = ((IConstantExpressionNode)node).Value;
return context => setSimpleValue(context, value);
}
var memberExp = _memberVisitor.Members[0].Value;
if (!useBindingForMember && !memberExp.IsRelativeSource && !memberExp.IsDynamic)
{
var path = memberExp.Path;
return context => setSimpleValue(context, path);
}
var srcFunc = GetBindingSourceDelegate(memberExp);
return context =>
{
var src = srcFunc(context);
setComplexValue(context, dataContext => src.GetCurrentValue());
};
}
}
finally
{
_memberVisitor.Clear();
}
}
示例3: Handle
public Action<IDataContext> Handle(ref IExpressionNode expression, bool isPrimaryExpression, IDataContext context)
{
if (expression == null)
return null;
expression = expression.Accept(MacrosExpressionVisitor.Instance).Accept(NullConditionalOperatorVisitor.Instance);
if (!isPrimaryExpression)
return null;
lock (_errorPathNames)
{
if (!HasGetErrorsMethod(ref expression))
return null;
var pairs = _errorPathNames.ToArrayEx();
return dataContext => UpdateBindingContext(dataContext, pairs);
}
}