// Bind the varaible named varName, in the Object boundObject, to update whenever a registered variable of the targetVariable is updated // Can also have an optional notify function that willbe called whever the target is updated public void BindVariable(string varName, object boundObject, string targetVariable, BindingNotify optionalNotify = null) { BoundVarialbe newBinding = new BoundVarialbe(); newBinding.boundObject = boundObject; newBinding.boundVariable = varName; newBinding.notify = optionalNotify; List<BoundVarialbe> boundList; if(bindingMap.TryGetValue(targetVariable, out boundList)) { // target variable is already being watched boundList.Add(newBinding); } else { // The target variable has not been registered boundList = new List<BoundVarialbe>(); bindingMap.Add(targetVariable, boundList); boundList.Add(newBinding); } }
// Bind the varaible named varName, in the Object boundObject, to update whenever a registered variable of the targetVariable is updated // Can also have an optional notify function that willbe called whever the target is updated public void BindVariable(string varName, object boundObject, string targetVariable, BindingNotify optionalNotify = null) { BoundVarialbe newBinding = new BoundVarialbe(); newBinding.boundObject = boundObject; newBinding.boundVariable = varName; newBinding.notify = optionalNotify; List <BoundVarialbe> boundList; if (bindingMap.TryGetValue(targetVariable, out boundList)) { // target variable is already being watched boundList.Add(newBinding); } else { // The target variable has not been registered boundList = new List <BoundVarialbe>(); bindingMap.Add(targetVariable, boundList); boundList.Add(newBinding); } }