private static Action <IBindingToSyntax>[] ConvertInternal(LambdaExpression expression, IBindingToSyntax syntax, bool ignoreCallback) { Expression lastExpression; string path; if (BindingExtensions.TryGetMemberPath(expression.Body, ".", false, out lastExpression, out path) && expression.Parameters[0] == lastExpression) { if (ignoreCallback) { syntax.ToSource(context => BindingExtensions.CreateBindingSource(context, path, null)); return(Empty.Array <Action <IBindingToSyntax> >()); } return(new Action <IBindingToSyntax>[] { s => s.ToSource(context => BindingExtensions.CreateBindingSource(context, path, null)) }); } var visitor = new LambdaExpressionToBindingExpressionConverter(expression); visitor.ConvertInternal(expression); var actions = visitor._callbacks.ToArray(); visitor._members = null; visitor._sourceExpression = null; visitor._currentExpression = null; visitor._methodExpression = null; visitor._callbacks = null; return(actions); }
public static IBindingModeInfoBehaviorSyntax ToSelf([NotNull] this IBindingToSyntax syntax, [NotNull] string selfPath) { Should.NotBeNull(selfPath, "selfPath"); return(syntax.ToSource(context => { object target = context.GetData(BindingBuilderConstants.Target, true); return new BindingSource(BindingServiceProvider.ObserverProvider.Observe(target, BindingPath.Create(selfPath), false)); })); }
public static IBindingModeInfoBehaviorSyntax To([NotNull] this IBindingToSyntax syntax, [NotNull] object source, [NotNull] string sourcePath) { Should.NotBeNull(source, "source"); Should.NotBeNull(sourcePath, "sourcePath"); return(syntax.ToSource(context => { IObserver observer = BindingServiceProvider.ObserverProvider.Observe(source, BindingPath.Create(sourcePath), false); return new BindingSource(observer); })); }
public static IBindingModeInfoBehaviorSyntax To([NotNull] this IBindingToSyntax syntax, [NotNull] string sourcePath) { Should.NotBeNull(sourcePath, "sourcePath"); return(syntax.ToSource(context => { IBindingContext bindingContext = BindingServiceProvider .ContextManager .GetBindingContext(context.GetData(BindingBuilderConstants.Target, true), context.GetData(BindingBuilderConstants.TargetPath, true).Path); IObserver observer = BindingServiceProvider.ObserverProvider.Observe(bindingContext, BindingPath.Create(sourcePath), false); return new BindingSource(observer); })); }
public static IBindingModeInfoBehaviorSyntax <object> To([NotNull] this IBindingToSyntax syntax, [NotNull] string sourcePath) { Should.NotBeNull(sourcePath, "sourcePath"); return(syntax.ToSource(context => BindingExtensions.CreateBindingSource(context, sourcePath, null))); }