public static IBindingToSyntax <TTarget, TSource> Bind <TTarget, TSource>([NotNull] this IBindingBuilder builder,
                                                                           [NotNull] TTarget targetGeneric, [NotNull] string targetPath) where TTarget : class
 {
     Should.NotBeNull(builder, "builder");
     Should.NotBeNull(targetGeneric, "targetGeneric");
     Should.NotBeNullOrWhitespace(targetPath, "targetPath");
     builder.Add(BindingBuilderConstants.Target, targetGeneric);
     builder.Add(BindingBuilderConstants.TargetPath, BindingServiceProvider.BindingPathFactory(targetPath));
     return(new SyntaxBuilder <TTarget, TSource>(builder));
 }
Exemplo n.º 2
0
 public static IBindingToSyntax Bind([NotNull] this IBindingBuilder builder, [NotNull] object target,
                                     [NotNull] string targetPath)
 {
     Should.NotBeNull(builder, "builder");
     Should.NotBeNull(target, "target");
     Should.NotBeNullOrWhitespace(targetPath, "targetPath");
     builder.Add(BindingBuilderConstants.Target, target);
     builder.Add(BindingBuilderConstants.TargetPath, BindingPath.Create(targetPath));
     return(builder.GetOrAddSyntaxBuilder());
 }
Exemplo n.º 3
0
        private static SyntaxBuilder <object, object> GetOrAddSyntaxBuilder(this IBindingBuilder builder)
        {
            SyntaxBuilder <object, object> syntaxBuilder;

            if (!builder.TryGetData(SyntaxBuilderConstant, out syntaxBuilder))
            {
                syntaxBuilder = new SyntaxBuilder <object, object>(builder);
                builder.Add(SyntaxBuilderConstant, syntaxBuilder);
            }
            return(syntaxBuilder);
        }
Exemplo n.º 4
0
        protected virtual void BuildParameterFromLambdaExpressionInternal <TValue>(IBindingBuilder builder, Func <LambdaExpression> expression, DataConstant <Func <IDataContext, TValue> > parameterConstant)
        {
            Func <IDataContext, TValue> value;
            var func = LambdaExpressionToBindingExpressionConverter.ConvertParameter(builder, expression);

            if (typeof(TValue) == typeof(object))
            {
                value = (Func <IDataContext, TValue>)(object) func;
            }
            else
            {
                value = func.CastFunc <TValue>;
            }
            builder.Add(parameterConstant, value);
        }