private void EnableControlsByVersion(BindingSource bindingSource, IVersionable dataSource) { List <Control> list = new List <Control>(); foreach (Control item in this.removedBindings[bindingSource].Keys) { list.Add(item); } foreach (Control control in list) { List <Binding> list2 = new List <Binding>(this.removedBindings[bindingSource][control]); foreach (Binding binding in list2) { ExchangeObjectVersion propertyDefinitionVersion = PropertyConstraintProvider.GetPropertyDefinitionVersion(dataSource, binding.BindingMemberInfo.BindingMember); if (!dataSource.ExchangeVersion.IsOlderThan(propertyDefinitionVersion)) { control.DataBindings.Add(binding); this.removedBindings[bindingSource][control].Remove(binding); if (this.removedBindings[bindingSource][control].Count == 0) { ISpecifyPropertyState specifyPropertyState = control as ISpecifyPropertyState; if (specifyPropertyState != null) { specifyPropertyState.SetPropertyState(binding.PropertyName, PropertyState.Normal, string.Empty); } else { control.Enabled = true; } } } } } }
private void DisableControlsByVersion(BindingSource bindingSource, IVersionable dataSource) { BindingManagerBase bindingManagerBase = this.ContainerBindingContext[bindingSource]; for (int i = bindingManagerBase.Bindings.Count - 1; i >= 0; i--) { Binding binding = bindingManagerBase.Bindings[i]; ExchangeObjectVersion propertyDefinitionVersion = PropertyConstraintProvider.GetPropertyDefinitionVersion(dataSource, binding.BindingMemberInfo.BindingMember); if (dataSource.ExchangeVersion.IsOlderThan(propertyDefinitionVersion)) { if (!this.removedBindings[bindingSource].ContainsKey(binding.Control)) { this.removedBindings[bindingSource][binding.Control] = new List <Binding>(); } this.removedBindings[bindingSource][binding.Control].Add(binding); ISpecifyPropertyState specifyPropertyState = binding.Control as ISpecifyPropertyState; if (specifyPropertyState != null) { specifyPropertyState.SetPropertyState(binding.PropertyName, PropertyState.UnsupportedVersion, Strings.FeatureVersionMismatchDescription(propertyDefinitionVersion.ExchangeBuild)); } else { binding.Control.Enabled = false; } binding.Control.DataBindings.Remove(binding); } } }