/// <summary>Sets the binding dictionary.</summary>
 /// <param name="dependencyObject">The dependency object.</param>
 /// <param name="value">The binding connector.</param>
 public static void SetMetadata(DependencyObject dependencyObject, BindingData value)
 {
     dependencyObject.SetValue(MetadataProperty, value);
 }
 /// <summary>Initializes a new instance of the <see cref="BindingData"/> class.</summary>
 /// <param name="id">The identifier.</param>
 /// <param name="nextBindingData">The next binding data.</param>
 public BindingData(int id, BindingData nextBindingData)
 {
     this.Id = id;
     this.NextBindingData = nextBindingData;
 }
        private static void GetBindingData <TSourceValue, TTargetValue>(DependencyObject target, int id, out BindingData bindingData, out IValueConverter <TSourceValue, TTargetValue> valueConverter)
        {
            valueConverter = null;
            bindingData    = null;
            var bindingMetadata = BindingConnection.GetMetadata(target);

            if (bindingMetadata?.TryGetById(id, out bindingData) == true)
            {
                var converter = bindingData.Converter;
                if (converter != null)
                {
                    if (converter is IValueConverter <TSourceValue, TTargetValue> newValueConverter)
                    {
                        valueConverter = newValueConverter;
                    }
                    else
                    {
                        valueConverter = new CastingValueConverter <TSourceValue, TTargetValue>(converter);
                    }
                }
            }
        }