AspNetEdit.Editor.ComponentModel.DesignContainer.OnComponentChanged C# (CSharp) Method

OnComponentChanged() public method

public OnComponentChanged ( object component, MemberDescriptor member, object oldValue, object newValue ) : void
component object
member System.ComponentModel.MemberDescriptor
oldValue object
newValue object
return void
        public void OnComponentChanged(object component, MemberDescriptor member, object oldValue, object newValue)
        {
            //the names of components in this container are actually the same as their IDs
            //so if a change to the ID occurs, we hook in and change it back if not valid
            if(component is Control && ((Control) component).Site.Container == this && member.Name == "ID") {
                //check name is valid
                bool goodVal = true;
                if (newValue == null || !(newValue is String))
                    goodVal = false;
                else
                    foreach (IComponent Comp in this.Components)
                        if (Comp != component && Comp.Site != null && Comp.Site.Name == ((string) newValue))
                            goodVal = false;

                if (goodVal)
                    //success, raise change event
                    OnComponentRename (component, (string) oldValue, (string) newValue);
                else
                    //bad value, change back
                    ((PropertyDescriptor) member).SetValue (component, oldValue);
            }

            if (ComponentChanged != null)
                ComponentChanged (this, new ComponentChangedEventArgs (component, member, oldValue, newValue));
        }