public void AddExtendedBrowsingHandlers(Hashtable handlers)
        {
            object targetObject = this.TargetObject;

            if (targetObject != null)
            {
                for (int i = 0; i < extendedInterfaces.Length; i++)
                {
                    System.Type type = extendedInterfaces[i];
                    if (type.IsInstanceOfType(targetObject))
                    {
                        Com2ExtendedBrowsingHandler handler = (Com2ExtendedBrowsingHandler)handlers[type];
                        if (handler == null)
                        {
                            handler        = (Com2ExtendedBrowsingHandler)Activator.CreateInstance(extendedInterfaceHandlerTypes[i]);
                            handlers[type] = handler;
                        }
                        if (!type.IsAssignableFrom(handler.Interface))
                        {
                            throw new ArgumentException(System.Windows.Forms.SR.GetString("COM2BadHandlerType", new object[] { type.Name, handler.Interface.Name }));
                        }
                        handler.SetupPropertyHandlers(this.props);
                    }
                }
            }
        }
Exemple #2
0
        /// <include file='doc\COM2Properties.uex' path='docs/doc[@for="Com2Properties.AddExtendedBrowsingHandlers"]/*' />
        /// <devdoc>
        /// Checks the source object for eache extended browsing inteface
        /// listed in extendedInterfaces and creates a handler from extendedInterfaceHandlerTypes
        /// to handle it.
        /// </devdoc>
        public void AddExtendedBrowsingHandlers(Hashtable handlers)
        {
            object target = this.TargetObject;

            if (target == null)
            {
                return;
            }


            // process all our registered types
            Type t;

            for (int i = 0; i < extendedInterfaces.Length; i++)
            {
                t = extendedInterfaces[i];

                // is this object an implementor of the interface?
                //
                if (t.IsInstanceOfType(target))
                {
                    // since handlers must be stateless, check to see if we've already
                    // created one of this type
                    //
                    Com2ExtendedBrowsingHandler handler = (Com2ExtendedBrowsingHandler)handlers[t];
                    if (handler == null)
                    {
                        handler     = (Com2ExtendedBrowsingHandler)Activator.CreateInstance(extendedInterfaceHandlerTypes[i]);
                        handlers[t] = handler;
                    }

                    // make sure we got the right one
                    //
                    if (t.IsAssignableFrom(handler.Interface))
                    {
#if DEBUG
                        if (DbgCom2PropertiesSwitch.TraceVerbose)
                        {
                            Debug.WriteLine("Adding browsing handler type " + handler.Interface.Name + " to object " + dbgObjName + ", class=" + dbgObjClass);
                        }
#endif
                        // allow the handler to attach itself to the appropriate properties
                        //
                        handler.SetupPropertyHandlers(props);
                    }
                    else
                    {
                        throw new ArgumentException(string.Format(SR.COM2BadHandlerType, t.Name, handler.Interface.Name));
                    }
                }
            }
        }