protected override void BindConstant(BindingInfo info) { if (info is ConstantBindingInfo <T> constantInfo) { boundProperty = new ObservableVariable <T>(constantInfo.Constant); RaiseFirstNotification(); } }
protected override void UnbindProperty() { if (boundProperty != null) { boundProperty.Changed -= OnBoundPropertyChanged; boundProperty = null; } exposedProperty.Clear(); }
public static T GetValue <T>(this IReadOnlyObservableVariable <T> variable, T fallback) { T result = fallback; if (variable.HasValue) { result = variable.Value; } return(result); }
private static IReadOnlyObservableVariable <T> BoxVariable(object variableToBox) { IReadOnlyObservableVariable <T> result = null; Type variableGenericType = variableToBox.GetType().GetGenericTypeTowardsRoot(); if (variableGenericType != null) { Type exposedType = typeof(T); Type boxedType = variableGenericType.GenericTypeArguments[0]; Type activationType = typeof(VariableBoxer <,>).MakeGenericType(exposedType, boxedType); result = Activator.CreateInstance(activationType, variableToBox) as IReadOnlyObservableVariable <T>; } return(result); }
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); } }
public VariableBoxer(IReadOnlyObservableVariable <TBoxed> boxedVariable) { this.boxedVariable = boxedVariable; boxedVariable.Changed += OnBoxedVariableChanged; boxedVariable.Cleared -= OnBoxedVariableCleared; }
public ObservableCommand(IObservableVariable <bool> canExecuteSource) { CanExecute = canExecuteSource; }
public OperatorVariableViewModel(IReadOnlyObservableVariable <T> value) { Value = value; }