Exemple #1
0
        public bool TryGetValue(
            IValueDescriptor valueDescriptor,
            BindingContext?bindingContext,
            out object?boundValue
            )
        {
            if (!string.IsNullOrEmpty(valueDescriptor.ValueName))
            {
                CommandResult?commandResult = bindingContext?.ParseResult.CommandResult;

                while (commandResult != null)
                {
                    if (commandResult.TryGetValueForOption(valueDescriptor, out var optionValue))
                    {
                        boundValue = optionValue;
                        return(true);
                    }

                    if (
                        commandResult.TryGetValueForArgument(valueDescriptor, out var argumentValue)
                        )
                    {
                        boundValue = argumentValue;
                        return(true);
                    }

                    commandResult = commandResult.Parent as CommandResult;
                }
            }

            boundValue = null;
            return(false);
        }
Exemple #2
0
        public bool TryGetValue(IValueDescriptor valueDescriptor,
                                BindingContext?bindingContext,
                                out object?boundValue)
        {
            var specificDescriptor = ValueDescriptor;

            switch (specificDescriptor)
            {
            case IOption option:
                var optionResult = bindingContext?.ParseResult.FindResultFor(option);
                if (!(optionResult is null))
                {
                    boundValue = optionResult.GetValueOrDefault();
                    return(true);
                }
                break;

            case IArgument argument:
                var argumentResult = bindingContext?.ParseResult.FindResultFor(argument);
                if (!(argumentResult is null))
                {
                    boundValue = argumentResult.GetValueOrDefault();
                    return(true);
                }
                break;
            }

            boundValue = null;
            return(false);
        }
 public bool TryGetValue(
     IValueDescriptor valueDescriptor,
     BindingContext?bindingContext,
     out object?boundValue)
 {
     boundValue = bindingContext?.ServiceProvider.GetService(valueDescriptor.ValueType);
     return(true);
 }
 public bool TryGetValue(
     IValueDescriptor valueDescriptor,
     BindingContext?bindingContext,
     out object?boundValue)
 {
     boundValue = valueDescriptor.ValueType.GetDefaultValueForType();
     return(true);
 }
Exemple #5
0
 public bool TryGetValue(
     IValueDescriptor valueDescriptor,
     BindingContext?bindingContext,
     out object?boundValue)
 {
     boundValue = ArgumentConverter.GetDefaultValue(valueDescriptor.ValueType);
     return(true);
 }
Exemple #6
0
 public bool TryGetValue(
     IValueDescriptor valueDescriptor,
     BindingContext?bindingContext,
     out object?boundValue
     )
 {
     boundValue = null;
     return(false);
 }
        public bool TryGetValue(
            IValueDescriptor valueDescriptor,
            BindingContext?bindingContext,
            out object?boundValue
            )
        {
            boundValue = _getValue(bindingContext);

            return(true);
        }
    public bool TryGetValue(
        IValueDescriptor valueDescriptor,
        BindingContext?bindingContext,
        out object?boundValue)
    {
        if (!string.IsNullOrEmpty(valueDescriptor.ValueName))
        {
            CommandResult?commandResult = bindingContext?.ParseResult.CommandResult;

            while (commandResult is { })
    bool IValueSource.TryGetValue(IValueDescriptor valueDescriptor, BindingContext?bindingContext, out object?boundValue)
    {
        if (bindingContext is null)
        {
            boundValue = default;
            return(false);
        }

        boundValue = GetBoundValue(bindingContext);
        return(true);
    }