/// <param name="designer"> The property designer. </param> public PropertyDesignerManager(object instance, PropertyDescriptor descriptor, IDesigner designer) { _designer = designer; _designer.Disposed += new EventHandler(DesignerDisposed); _designer.Service.OnRequestSave += new RequestHandler(DesignerRequestedSave); _descriptor = descriptor; _descriptor.AddValueChanged(instance, new EventHandler(PropertyChanged)); _instance = instance; IDisposableNotify localInstance = _instance as IDisposableNotify; if (localInstance != null) { localInstance.Disposed += new EventHandler(InstanceDisposed); } ISite site = ((IComponent)_instance).Site; if (site != null) { _service = (IDesignService)site.GetService(typeof(IDesignService)); _service.Dependants.Add(_designer.Service); } else { _service = null; } }
private void DesignerDisposed(object sender, EventArgs e) { IDisposableNotify instance = _instance as IDisposableNotify; if (instance != null) { instance.Disposed -= new EventHandler(InstanceDisposed); } _descriptor.RemoveValueChanged(_instance, new EventHandler(PropertyChanged)); if (_service != null) { _service.Dependants.Remove(_designer.Service); } }
/// <summary> /// Gets a handle for the given object and registers it in the handle dictionary. /// </summary> /// <param name="objectValue"></param> /// <returns></returns> public int GetHandle(object objectValue) { lock (_handleSync) { int result = _nextHandle; _nextHandle++; _handles.Add(result, objectValue); IDisposableNotify disposableNotify = objectValue as IDisposableNotify; if (disposableNotify != null) { disposableNotify.Disposed += new EventHandler(ObjectDisposed); _handleIndex.Add(disposableNotify, result); } return(result); } }
private object ReleaseObject(int handle) { lock (_handleSync) { object objectValue; if (!_handles.TryGetValue(handle, out objectValue)) { throw new ServerException(ServerException.Codes.UnknownObjectHandle, ErrorSeverity.System); } _handles.Remove(handle); IDisposableNotify disposableNotify = objectValue as IDisposableNotify; if (disposableNotify != null) { disposableNotify.Disposed -= new EventHandler(ObjectDisposed); _handleIndex.Remove(disposableNotify); } return(objectValue); } }