コード例 #1
0
        /// <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;
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: HandleManager.cs プロジェクト: laszlo-kiss/Dataphor
        /// <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);
            }
        }
コード例 #4
0
ファイル: HandleManager.cs プロジェクト: laszlo-kiss/Dataphor
        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);
            }
        }