/// <summary>
    /// Sets the OneWayBind invocation.
    /// </summary>
    /// <param name="invocationKind">The invocation kind.</param>
    /// <param name="receiverKind">The receiver kind.</param>
    /// <param name="viewModelExpression">The view model expression.</param>
    /// <param name="viewExpression">The view expression.</param>
    /// <param name="viewModelConvert">The view model conversion function.</param>
    /// <param name="target">The target parameter.</param>
    /// <returns>A reference to this builder.</returns>
    public BindHostBuilder WithOneWayInvocation(
        InvocationKind invocationKind,
        ReceiverKind receiverKind,
        Expression <Func <BindHostProxy, object> > viewModelExpression,
        Expression <Func <WhenChangedHostProxy, object> > viewExpression,
        Expression <Func <object, object, object> > viewModelConvert,
        string target = "ViewModel")
    {
        if (viewModelExpression is null)
        {
            throw new ArgumentNullException(nameof(viewModelExpression));
        }

        if (viewExpression is null)
        {
            throw new ArgumentNullException(nameof(viewExpression));
        }

        if (viewModelConvert is null)
        {
            throw new ArgumentNullException(nameof(viewModelConvert));
        }

        _oneWayBindInvocation = GetOneWayBindInvocation(invocationKind, receiverKind, viewModelExpression.ToString(), viewExpression.ToString(), target, viewModelConvert.ToString());
        return(this);
    }
예제 #2
0
        public ReceiverIdentifier(byte[] identity, ReceiverKind receiverKind)
        {
            Identity     = identity;
            ReceiverKind = receiverKind;

            hashCode = CalculateHashCode();
        }
    private static string GetOneWayBindInvocation(
        InvocationKind invocationKind,
        ReceiverKind viewModelKind,
        string viewModelArgs,
        string viewArgs,
        string targetName,
        string?viewModelConvertFunc = null)
    {
        var receiver = viewModelKind == ReceiverKind.This ? "this" : "instance";

        if (viewModelConvertFunc is not null)
        {
            viewArgs = viewArgs + ", " + viewModelConvertFunc;
        }

        return(invocationKind == InvocationKind.MemberAccess ?
               $"{receiver}.BindOneWay({targetName}, {viewModelArgs}, {viewArgs})" :
               $"BindExtensions.BindOneWay({receiver}, {targetName}, {viewModelArgs}, {viewArgs})");
    }
예제 #4
0
 public static ReceiverIdentifier Create(ReceiverKind receiverKind)
 => new ReceiverIdentifier(CreateIdentity(), receiverKind);