Esempio n. 1
0
        private object bindDictionary(IServiceProvider serviceProvider)
        {
            string uid = _uid ?? GetUid(_target);
            string vid = _property.Name;

            var binding = new Binding("Dictionary")
            {
                Source = LanguageContext.Current, Mode = BindingMode.TwoWay
            };
            var converter = new LanguageConverter(uid, vid, _default);

            if (_parameters.Count == 0)
            {
                binding.Converter = converter;
                object value = binding.ProvideValue(serviceProvider);
                return(value);
            }
            else
            {
                var multiBinding = new MultiBinding {
                    Mode = BindingMode.TwoWay, Converter = converter
                };
                multiBinding.Bindings.Add(binding);
                if (string.IsNullOrEmpty(uid))
                {
                    var uidBinding = _parameters[0] as Binding;
                    if (uidBinding == null)
                    {
                        throw new ArgumentException("Uid Binding parameter must be the first, and of type Binding");
                    }
                }
                foreach (Binding parameter in _parameters)
                {
                    multiBinding.Bindings.Add(parameter);
                }
                object value = multiBinding.ProvideValue(serviceProvider);
                return(value);
            }
        }
        private object bindDictionary(IServiceProvider serviceProvider)
        {
            string uid = _uid ?? GetUid(_target);
            string vid = _property.Name;

            var binding = new Binding("Dictionary") {Source = LanguageContext.Current, Mode = BindingMode.TwoWay};
            var converter = new LanguageConverter(uid, vid, _default);
            if (_parameters.Count == 0)
            {
                binding.Converter = converter;
                object value = binding.ProvideValue(serviceProvider);
                return value;
            }
            else
            {
                var multiBinding = new MultiBinding {Mode = BindingMode.TwoWay, Converter = converter};
                multiBinding.Bindings.Add(binding);
                if (string.IsNullOrEmpty(uid))
                {
                    var uidBinding = _parameters[0] as Binding;
                    if (uidBinding == null)
                    {
                        throw new ArgumentException("Uid Binding parameter must be the first, and of type Binding");
                    }
                }
                foreach (Binding parameter in _parameters)
                {
                    multiBinding.Bindings.Add(parameter);
                }
                object value = multiBinding.ProvideValue(serviceProvider);
                return value;
            }
        }