Пример #1
0
        protected override void OnValidate()
        {
            base.OnValidate();

            if (expectedViewModelType != null && expectedViewModelType.Type != null)
            {
                Type genericType = expectedViewModelType.Type.GetGenericTypeTowardsRoot();
                Type dataType    = genericType.GenericTypeArguments[0];
                Type bindingType = typeof(IReadOnlyObservableVariable <>).MakeGenericType(dataType);

                if (bindingInfo.Type != bindingType)
                {
                    bindingInfo = new BindingInfo(bindingType);
                    BindingInfoTrackerProxy.RefreshBindingInfo();
                }
            }
        }
Пример #2
0
        private void SanitizeTypes()
        {
            bool didTypeChange = false;

            if (bindingType == BindingType.Variable && fromBinding.Type != typeof(IReadOnlyObservableVariable <TFrom>))
            {
                fromBinding   = new BindingInfo(typeof(IReadOnlyObservableVariable <TFrom>));
                expectedType  = new SerializableType(typeof(OperatorVariableViewModel <TTo>));
                didTypeChange = true;
            }

            if (bindingType == BindingType.Collection && fromBinding.Type != typeof(IReadOnlyObservableCollection <TFrom>))
            {
                fromBinding   = new BindingInfo(typeof(IReadOnlyObservableCollection <TFrom>));
                expectedType  = new SerializableType(typeof(OperatorCollectionViewModel <TTo>));
                didTypeChange = true;
            }

            if (bindingType == BindingType.Command && fromBinding.Type != typeof(IObservableCommand <TTo>))
            {
                fromBinding   = new BindingInfo(typeof(IObservableCommand <TTo>));
                expectedType  = new SerializableType(typeof(OperatorCommandViewModel <TFrom>));
                didTypeChange = true;
            }

            if (bindingType == BindingType.Event && fromBinding.Type != typeof(IObservableEvent <TFrom>))
            {
                fromBinding   = new BindingInfo(typeof(IObservableEvent <TFrom>));
                expectedType  = new SerializableType(typeof(OperatorEventViewModel <TTo>));
                didTypeChange = true;
            }

            if (didTypeChange)
            {
                BindingInfoTrackerProxy.RefreshBindingInfo();
            }
        }