예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #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();
        }
예제 #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);
            }
        }