Esempio n. 1
0
        public void NeedsToBeBoxed_EventWithReferenceTypeToObject_ReturnFalse()
        {
            Type actualType = typeof(ObservableEvent <string>);
            Type targetType = typeof(IObservableEvent <object>);

            bool needsToBeBoxed = BindingUtils.NeedsToBeBoxed(actualType, targetType);

            needsToBeBoxed.Should().BeFalse();
        }
Esempio n. 2
0
        public void NeedsToBeBoxed_CollectionWithReferenceTypeToObject_ReturnFalse()
        {
            Type actualType = typeof(ObservableCollection <string>);
            Type targetType = typeof(IReadOnlyObservableCollection <object>);

            bool needsToBeBoxed = BindingUtils.NeedsToBeBoxed(actualType, targetType);

            needsToBeBoxed.Should().BeFalse();
        }
Esempio n. 3
0
        public void NeedsToBeBoxed_EventWithBuiltInValueTypeToObject_ReturnTrue()
        {
            Type actualType = typeof(ObservableEvent <int>);
            Type targetType = typeof(IObservableEvent <object>);

            bool needsToBeBoxed = BindingUtils.NeedsToBeBoxed(actualType, targetType);

            needsToBeBoxed.Should().BeTrue();
        }
Esempio n. 4
0
        public void NeedsToBeBoxed_CollectionWithBuiltInValueTypeToObject_ReturnTrue()
        {
            Type actualType = typeof(ObservableCollection <int>);
            Type targetType = typeof(IReadOnlyObservableCollection <object>);

            bool needsToBeBoxed = BindingUtils.NeedsToBeBoxed(actualType, targetType);

            needsToBeBoxed.Should().BeTrue();
        }
Esempio n. 5
0
        protected override void BindProperty(object property)
        {
            boundProperty = property as IReadOnlyObservableVariable <T>;

            if (boundProperty == null && BindingUtils.NeedsToBeBoxed(property.GetType(), typeof(IReadOnlyObservableVariable <T>)))
            {
                boundProperty = BoxVariable(property);
            }

            if (boundProperty != null)
            {
                boundProperty.Changed += OnBoundPropertyChanged;
                RaiseFirstNotification();
            }
            else
            {
                Debug.LogError($"Property type ({property.GetType()}) cannot be bound as {typeof(IReadOnlyObservableVariable<T>)}", context);
            }
        }