Example #1
0
 public ConsumerConnectionPointCollection(ICollection connectionPoints)
 {
     if (connectionPoints == null)
     {
         throw new ArgumentNullException("connectionPoints");
     }
     this._ids = new HybridDictionary(connectionPoints.Count, true);
     foreach (object obj2 in connectionPoints)
     {
         if (obj2 == null)
         {
             throw new ArgumentException(System.Web.SR.GetString("Collection_CantAddNull"), "connectionPoints");
         }
         ConsumerConnectionPoint point = obj2 as ConsumerConnectionPoint;
         if (point == null)
         {
             throw new ArgumentException(System.Web.SR.GetString("Collection_InvalidType", new object[] { "ConsumerConnectionPoint" }), "connectionPoints");
         }
         string iD = point.ID;
         if (this._ids.Contains(iD))
         {
             throw new ArgumentException(System.Web.SR.GetString("WebPart_Collection_DuplicateID", new object[] { "ConsumerConnectionPoint", iD }), "connectionPoints");
         }
         base.InnerList.Add(point);
         this._ids.Add(iD, point);
     }
 }
 public WebPartConnectionsEventArgs(WebPart provider, ProviderConnectionPoint providerConnectionPoint,
                                    WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint,
                                    WebPartConnection connection) : this(provider, providerConnectionPoint,
                                                                         consumer, consumerConnectionPoint)
 {
     _connection = connection;
 }
        public ConsumerConnectionPointCollection(ICollection connectionPoints)
        {
            if (connectionPoints == null)
            {
                throw new ArgumentNullException("connectionPoints");
            }

            _ids = new HybridDictionary(connectionPoints.Count, true /* caseInsensitive */);
            foreach (object obj in connectionPoints)
            {
                if (obj == null)
                {
                    throw new ArgumentException(SR.GetString(SR.Collection_CantAddNull), "connectionPoints");
                }
                ConsumerConnectionPoint point = obj as ConsumerConnectionPoint;
                if (point == null)
                {
                    throw new ArgumentException(SR.GetString(SR.Collection_InvalidType, "ConsumerConnectionPoint"),
                                                "connectionPoints");
                }
                string id = point.ID;
                if (!_ids.Contains(id))
                {
                    InnerList.Add(point);
                    _ids.Add(id, point);
                }
                else
                {
                    throw new ArgumentException(SR.GetString(SR.WebPart_Collection_DuplicateID, "ConsumerConnectionPoint", id), "connectionPoints");
                }
            }
        }
 public WebPartConnectionsEventArgs(WebPart provider, ProviderConnectionPoint providerConnectionPoint,
                                    WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint) {
     // Arguments may be null, when deleting a connection because a part is no longer on the page
     _provider = provider;
     _providerConnectionPoint = providerConnectionPoint;
     _consumer = consumer;
     _consumerConnectionPoint = consumerConnectionPoint;
 }
    public virtual new WebPartConnection ConnectWebParts (WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartTransformer transformer)
    {
      Contract.Requires (provider != null);
      Contract.Requires (consumer != null);
      Contract.Requires (providerConnectionPoint != null);
      Contract.Requires (consumerConnectionPoint != null);

      return default(WebPartConnection);
    }
 public WebPartConnectionsEventArgs(WebPart provider, ProviderConnectionPoint providerConnectionPoint,
                                    WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint)
 {
     // Arguments may be null, when deleting a connection because a part is no longer on the page
     _provider = provider;
     _providerConnectionPoint = providerConnectionPoint;
     _consumer = consumer;
     _consumerConnectionPoint = consumerConnectionPoint;
 }
 private void ClearPendingConnection()
 {
     this._pendingConnectionType = ConnectionType.None;
     this._pendingConnectionPointID = string.Empty;
     this._pendingSelectedValue = null;
     this._pendingConsumerID = string.Empty;
     this._pendingConsumer = null;
     this._pendingConsumerConnectionPoint = null;
     this._pendingProvider = null;
     this._pendingProviderConnectionPoint = null;
     this._pendingTransformerConfigurationControlTypeName = null;
     this._pendingConnectionID = null;
 }
 public WebPartConnectionsEventArgs(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartConnection connection)
 {
 }
 public ConsumerInfo(WebPart webPart, ConsumerConnectionPoint connectionPoint) : base(webPart) {
     _connectionPoint = connectionPoint;
 }
 public WebPartConnectionsEventArgs (WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartConnection connection)
 {
 }
 private IDictionary GetValidProviders(WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartCollection webParts)
 {
     HybridDictionary dictionary = new HybridDictionary();
     if ((((consumerConnectionPoint != null) && (consumer != null)) && consumer.AllowConnect) && (consumerConnectionPoint.AllowsMultipleConnections || !base.WebPartManager.IsConsumerConnected(consumer, consumerConnectionPoint)))
     {
         foreach (WebPart part in webParts)
         {
             if ((part.AllowConnect && (part != consumer)) && !part.IsClosed)
             {
                 foreach (ProviderConnectionPoint point in base.WebPartManager.GetProviderConnectionPoints(part))
                 {
                     if (base.WebPartManager.CanConnectWebParts(part, point, consumer, consumerConnectionPoint))
                     {
                         dictionary.Add(part.ID + '$' + point.ID, new ProviderInfo(part, point));
                     }
                     else
                     {
                         foreach (WebPartTransformer transformer in this.AvailableTransformers)
                         {
                             if (base.WebPartManager.CanConnectWebParts(part, point, consumer, consumerConnectionPoint, transformer))
                             {
                                 dictionary.Add(part.ID + '$' + point.ID, new ProviderInfo(part, point, transformer.GetType()));
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     return dictionary;
 }
 public WebPartConnection ConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint)
 {
   return default(WebPartConnection);
 }
 public bool CanConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint)
 {
   return default(bool);
 }
 public int IndexOf(ConsumerConnectionPoint connectionPoint) {
     return InnerList.IndexOf(connectionPoint);
 }
 public WebPartConnection ConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint,
                                          WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint) {
     return ConnectWebParts(provider, providerConnectionPoint, consumer, consumerConnectionPoint, null);
 }
        private bool CanConnectWebPartsCore(WebPart provider, ProviderConnectionPoint providerConnectionPoint,
                                            WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint,
                                            WebPartTransformer transformer, bool throwOnError) {
            if (!Personalization.IsModifiable) {
                if (throwOnError) {
                    // Will throw appropriate exception
                    Personalization.EnsureEnabled(/* ensureModifiable */ true);
                }
                else {
                    return false;
                }
            }

            if (provider == null) {
                throw new ArgumentNullException("provider");
            }
            if (!Controls.Contains(provider)) {
                throw new ArgumentException(SR.GetString(SR.UnknownWebPart), "provider");
            }

            if (consumer == null) {
                throw new ArgumentNullException("consumer");
            }
            if (!Controls.Contains(consumer)) {
                throw new ArgumentException(SR.GetString(SR.UnknownWebPart), "consumer");
            }

            if (providerConnectionPoint == null) {
                throw new ArgumentNullException("providerConnectionPoint");
            }
            if (consumerConnectionPoint == null) {
                throw new ArgumentNullException("consumerConnectionPoint");
            }

            Control providerControl = provider.ToControl();
            Control consumerControl = consumer.ToControl();

            if (providerConnectionPoint.ControlType != providerControl.GetType()) {
                throw new ArgumentException(SR.GetString(SR.WebPartManager_InvalidConnectionPoint), "providerConnectionPoint");
            }
            if (consumerConnectionPoint.ControlType != consumerControl.GetType()) {
                throw new ArgumentException(SR.GetString(SR.WebPartManager_InvalidConnectionPoint), "consumerConnectionPoint");
            }

            if (provider == consumer) {
                if (throwOnError) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartManager_CantConnectToSelf));
                }
                else {
                    return false;
                }
            }

            if (provider.IsClosed) {
                if (throwOnError) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartManager_CantConnectClosed, provider.ID));
                }
                else {
                    return false;
                }
            }

            if (consumer.IsClosed) {
                if (throwOnError) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartManager_CantConnectClosed, consumer.ID));
                }
                else {
                    return false;
                }
            }

            if (!providerConnectionPoint.GetEnabled(providerControl)) {
                if (throwOnError) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_DisabledConnectionPoint, providerConnectionPoint.ID, provider.ID));
                }
                else {
                    return false;
                }
            }

            if (!consumerConnectionPoint.GetEnabled(consumerControl)) {
                if (throwOnError) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_DisabledConnectionPoint, consumerConnectionPoint.ID, consumer.ID));
                }
                else {
                    return false;
                }
            }

            // Check AllowsMultipleConnections on each ConnectionPoint
            if (!providerConnectionPoint.AllowsMultipleConnections) {
                foreach (WebPartConnection c in Connections) {
                    if (c.Provider == provider && c.ProviderConnectionPoint == providerConnectionPoint) {
                        if (throwOnError) {
                            throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_Duplicate, providerConnectionPoint.ID, provider.ID));
                        }
                        else {
                            return false;
                        }
                    }
                }
            }

            if (!consumerConnectionPoint.AllowsMultipleConnections) {
                foreach (WebPartConnection c in Connections) {
                    if (c.Consumer == consumer && c.ConsumerConnectionPoint == consumerConnectionPoint) {
                        if (throwOnError) {
                            throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_Duplicate, consumerConnectionPoint.ID, consumer.ID));
                        }
                        else {
                            return false;
                        }
                    }
                }
            }

            if (transformer == null) {
                if (providerConnectionPoint.InterfaceType != consumerConnectionPoint.InterfaceType) {
                    if (throwOnError) {
                        throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_NoCommonInterface,
                            new string[] {providerConnectionPoint.DisplayName, provider.ID,
                                consumerConnectionPoint.DisplayName, consumer.ID}));
                    }
                    else {
                        return false;
                    }
                }

                ConnectionInterfaceCollection secondaryInterfaces = providerConnectionPoint.GetSecondaryInterfaces(providerControl);
                if (!consumerConnectionPoint.SupportsConnection(consumerControl, secondaryInterfaces)) {
                    if (throwOnError) {
                        throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_IncompatibleSecondaryInterfaces, new string[] {
                                consumerConnectionPoint.DisplayName, consumer.ID,
                                providerConnectionPoint.DisplayName, provider.ID}));
                    }
                    else {
                        return false;
                    }
                }
            }
            else {
                Type transformerType = transformer.GetType();

                if (!AvailableTransformers.Contains(transformerType)) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_TransformerNotAvailable, transformerType.FullName));
                }

                // Check matching interfaces on connection points and transformer attribute.
                // Note that we require the connection interfaces to match exactly.  We do not match
                // a derived interface type.  This is because we want to simplify the interface matching
                // algorithm when transformers are involved.  If we allowed derived interfaces to match,
                // then we would to take into account the "closest" match if multiple transformers
                // have compatible interfaces.
                Type transformerConsumerType = WebPartTransformerAttribute.GetConsumerType(transformerType);
                Type transformerProviderType = WebPartTransformerAttribute.GetProviderType(transformerType);
                if (providerConnectionPoint.InterfaceType != transformerConsumerType) {
                    if (throwOnError) {
                        throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_IncompatibleProviderTransformer,
                            providerConnectionPoint.DisplayName, provider.ID, transformerType.FullName));
                    }
                    else {
                        return false;
                    }
                }
                if (transformerProviderType != consumerConnectionPoint.InterfaceType) {
                    if (throwOnError) {
                        throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_IncompatibleConsumerTransformer,
                            transformerType.FullName, consumerConnectionPoint.DisplayName, consumer.ID));
                    }
                    else {
                        return false;
                    }
                }

                // A transformer never provides any secondary interfaces
                if (!consumerConnectionPoint.SupportsConnection(consumerControl, ConnectionInterfaceCollection.Empty)) {
                    if (throwOnError) {
                        throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_ConsumerRequiresSecondaryInterfaces,
                            consumerConnectionPoint.DisplayName, consumer.ID));
                    }
                    else {
                        return false;
                    }
                }

            }

            return true;
        }
        public int IndexOf(ConsumerConnectionPoint connectionPoint)
        {
            Contract.Ensures(Contract.Result <int>() >= -1);

            return(default(int));
        }
Example #18
0
 public int IndexOf(ConsumerConnectionPoint connectionPoint)
 {
     return(base.InnerList.IndexOf(connectionPoint));
 }
Example #19
0
 public bool Contains(ConsumerConnectionPoint connectionPoint)
 {
     return(base.InnerList.Contains(connectionPoint));
 }
        public virtual new WebPartConnection ConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartTransformer transformer)
        {
            Contract.Requires(provider != null);
            Contract.Requires(consumer != null);
            Contract.Requires(providerConnectionPoint != null);
            Contract.Requires(consumerConnectionPoint != null);

            return(default(WebPartConnection));
        }
 private static ICollection[] CreateConnectionPoints(Type type)
 {
     ArrayList connectionPoints = new ArrayList();
     ArrayList list2 = new ArrayList();
     foreach (MethodInfo info in type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance))
     {
         object[] customAttributes = info.GetCustomAttributes(typeof(ConnectionConsumerAttribute), true);
         if (customAttributes.Length == 1)
         {
             ConsumerConnectionPoint point;
             ParameterInfo[] parameters = info.GetParameters();
             Type interfaceType = null;
             if (parameters.Length == 1)
             {
                 interfaceType = parameters[0].ParameterType;
             }
             if ((!info.IsPublic || (info.ReturnType != typeof(void))) || (interfaceType == null))
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("WebPartManager_InvalidConsumerSignature", new object[] { info.Name, type.FullName }));
             }
             ConnectionConsumerAttribute attribute = customAttributes[0] as ConnectionConsumerAttribute;
             string displayName = attribute.DisplayName;
             string iD = attribute.ID;
             Type connectionPointType = attribute.ConnectionPointType;
             bool allowsMultipleConnections = attribute.AllowsMultipleConnections;
             if (connectionPointType == null)
             {
                 point = new ConsumerConnectionPoint(info, interfaceType, type, displayName, iD, allowsMultipleConnections);
             }
             else
             {
                 object[] args = new object[] { info, interfaceType, type, displayName, iD, allowsMultipleConnections };
                 point = (ConsumerConnectionPoint) Activator.CreateInstance(connectionPointType, args);
             }
             connectionPoints.Add(point);
         }
         object[] objArray3 = info.GetCustomAttributes(typeof(ConnectionProviderAttribute), true);
         if (objArray3.Length == 1)
         {
             ProviderConnectionPoint point2;
             Type returnType = info.ReturnType;
             if ((!info.IsPublic || (returnType == typeof(void))) || (info.GetParameters().Length != 0))
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("WebPartManager_InvalidProviderSignature", new object[] { info.Name, type.FullName }));
             }
             ConnectionProviderAttribute attribute2 = objArray3[0] as ConnectionProviderAttribute;
             string str3 = attribute2.DisplayName;
             string id = attribute2.ID;
             Type type5 = attribute2.ConnectionPointType;
             bool flag2 = attribute2.AllowsMultipleConnections;
             if (type5 == null)
             {
                 point2 = new ProviderConnectionPoint(info, returnType, type, str3, id, flag2);
             }
             else
             {
                 object[] objArray4 = new object[] { info, returnType, type, str3, id, flag2 };
                 point2 = (ProviderConnectionPoint) Activator.CreateInstance(type5, objArray4);
             }
             list2.Add(point2);
         }
     }
     return new ICollection[] { new ConsumerConnectionPointCollection(connectionPoints), new ProviderConnectionPointCollection(list2) };
 }
Example #22
0
        internal void Activate()
        {
            // This method should only be called on WebPartConnections in the WebPartManager, so
            // _webPartManager should never be null.
            Debug.Assert(_webPartManager != null);

            Transformers.SetReadOnly();

            WebPart providerWebPart = Provider;

            // Cannot be null because Activate() is only called on valid Connections
            Debug.Assert(providerWebPart != null);

            WebPart consumerWebPart = Consumer;

            // Cannot be null because Activate() is only called on valid Connections
            Debug.Assert(consumerWebPart != null);

            Control providerControl = providerWebPart.ToControl();
            Control consumerControl = consumerWebPart.ToControl();

            ProviderConnectionPoint providerConnectionPoint = ProviderConnectionPoint;

            // Cannot be null because Activate() is only called on valid Connections
            Debug.Assert(providerConnectionPoint != null);

            if (!providerConnectionPoint.GetEnabled(providerControl))
            {
                consumerWebPart.SetConnectErrorMessage(SR.GetString(SR.WebPartConnection_DisabledConnectionPoint, providerConnectionPoint.DisplayName, providerWebPart.DisplayTitle));
                return;
            }

            ConsumerConnectionPoint consumerConnectionPoint = ConsumerConnectionPoint;

            // Cannot be null because Activate() is only called on valid Connections
            Debug.Assert(consumerConnectionPoint != null);

            if (!consumerConnectionPoint.GetEnabled(consumerControl))
            {
                consumerWebPart.SetConnectErrorMessage(SR.GetString(SR.WebPartConnection_DisabledConnectionPoint, consumerConnectionPoint.DisplayName, consumerWebPart.DisplayTitle));
                return;
            }

            // Do not activate connections involving closed WebParts
            if (!providerWebPart.IsClosed && !consumerWebPart.IsClosed)
            {
                WebPartTransformer transformer = Transformer;
                if (transformer == null)
                {
                    if (providerConnectionPoint.InterfaceType == consumerConnectionPoint.InterfaceType)
                    {
                        ConnectionInterfaceCollection secondaryInterfaces = providerConnectionPoint.GetSecondaryInterfaces(providerControl);
                        if (consumerConnectionPoint.SupportsConnection(consumerControl, secondaryInterfaces))
                        {
                            object dataObject = providerConnectionPoint.GetObject(providerControl);
                            consumerConnectionPoint.SetObject(consumerControl, dataObject);
                            _isActive = true;
                        }
                        else
                        {
                            consumerWebPart.SetConnectErrorMessage(SR.GetString(SR.WebPartConnection_IncompatibleSecondaryInterfaces, new string[] {
                                consumerConnectionPoint.DisplayName, consumerWebPart.DisplayTitle,
                                providerConnectionPoint.DisplayName, providerWebPart.DisplayTitle
                            }));
                        }
                    }
                    else
                    {
                        consumerWebPart.SetConnectErrorMessage(SR.GetString(SR.WebPartConnection_NoCommonInterface, new string[] {
                            providerConnectionPoint.DisplayName, providerWebPart.DisplayTitle,
                            consumerConnectionPoint.DisplayName, consumerWebPart.DisplayTitle
                        }));
                    }
                }
                else
                {
                    Type transformerType = transformer.GetType();

                    if (!_webPartManager.AvailableTransformers.Contains(transformerType))
                    {
                        string errorMessage;
                        if (_webPartManager.Context != null && _webPartManager.Context.IsCustomErrorEnabled)
                        {
                            errorMessage = SR.GetString(SR.WebPartConnection_TransformerNotAvailable);
                        }
                        else
                        {
                            errorMessage = SR.GetString(SR.WebPartConnection_TransformerNotAvailableWithType, transformerType.FullName);
                        }
                        consumerWebPart.SetConnectErrorMessage(errorMessage);

                        //
                    }

                    // Check matching interfaces on connection points and transformer attribute
                    Type transformerConsumerType = WebPartTransformerAttribute.GetConsumerType(transformerType);
                    Type transformerProviderType = WebPartTransformerAttribute.GetProviderType(transformerType);

                    if (providerConnectionPoint.InterfaceType == transformerConsumerType &&
                        transformerProviderType == consumerConnectionPoint.InterfaceType)
                    {
                        // A transformer never provides any secondary interfaces
                        if (consumerConnectionPoint.SupportsConnection(consumerControl, ConnectionInterfaceCollection.Empty))
                        {
                            object dataObject        = providerConnectionPoint.GetObject(providerControl);
                            object transformedObject = transformer.Transform(dataObject);
                            consumerConnectionPoint.SetObject(consumerControl, transformedObject);
                            _isActive = true;
                        }
                        else
                        {
                            consumerWebPart.SetConnectErrorMessage(SR.GetString(SR.WebPartConnection_ConsumerRequiresSecondaryInterfaces,
                                                                                consumerConnectionPoint.DisplayName, consumerWebPart.DisplayTitle));
                        }
                    }
                    else if (providerConnectionPoint.InterfaceType != transformerConsumerType)
                    {
                        string errorMessage;
                        if (_webPartManager.Context != null && _webPartManager.Context.IsCustomErrorEnabled)
                        {
                            errorMessage = SR.GetString(SR.WebPartConnection_IncompatibleProviderTransformer,
                                                        providerConnectionPoint.DisplayName, providerWebPart.DisplayTitle);
                        }
                        else
                        {
                            errorMessage = SR.GetString(SR.WebPartConnection_IncompatibleProviderTransformerWithType,
                                                        providerConnectionPoint.DisplayName, providerWebPart.DisplayTitle, transformerType.FullName);
                        }
                        consumerWebPart.SetConnectErrorMessage(errorMessage);
                    }
                    else
                    {
                        string errorMessage;
                        if (_webPartManager.Context != null && _webPartManager.Context.IsCustomErrorEnabled)
                        {
                            errorMessage = SR.GetString(SR.WebPartConnection_IncompatibleConsumerTransformer,
                                                        consumerConnectionPoint.DisplayName, consumerWebPart.DisplayTitle);
                        }
                        else
                        {
                            errorMessage = SR.GetString(SR.WebPartConnection_IncompatibleConsumerTransformerWithType,
                                                        transformerType.FullName, consumerConnectionPoint.DisplayName, consumerWebPart.DisplayTitle);
                        }
                        consumerWebPart.SetConnectErrorMessage(errorMessage);
                    }
                }
            }
        }
        public virtual WebPartConnection ConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint,
                                                         WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint,
                                                         WebPartTransformer transformer) {
            CanConnectWebPartsCore(provider, providerConnectionPoint, consumer, consumerConnectionPoint,
                                   transformer, /*throwOnError*/ true);

            if (DynamicConnections.IsReadOnly) {
                throw new InvalidOperationException(SR.GetString(SR.WebPartManager_ConnectTooLate));
            }

            WebPartConnectionsCancelEventArgs ce = new WebPartConnectionsCancelEventArgs(
                provider, providerConnectionPoint, consumer, consumerConnectionPoint);
            OnWebPartsConnecting(ce);
            if (_allowEventCancellation && ce.Cancel) {
                return null;
            }

            Control providerControl = provider.ToControl();
            Control consumerControl = consumer.ToControl();

            WebPartConnection connection = new WebPartConnection();
            connection.ID = CreateDynamicConnectionID();
            connection.ProviderID = providerControl.ID;
            connection.ConsumerID = consumerControl.ID;
            connection.ProviderConnectionPointID = providerConnectionPoint.ID;
            connection.ConsumerConnectionPointID = consumerConnectionPoint.ID;

            if (transformer != null) {
                Internals.SetTransformer(connection, transformer);
            }

            Internals.SetIsShared(connection, Personalization.Scope == PersonalizationScope.Shared);
            Internals.SetIsStatic(connection, false);

            DynamicConnections.Add(connection);
            _hasDataChanged = true;

            OnWebPartsConnected(new WebPartConnectionsEventArgs(provider, providerConnectionPoint,
                                                                consumer, consumerConnectionPoint, connection));

            return connection;
        }
 public void CopyTo(ConsumerConnectionPoint[] array, int index) {
     InnerList.CopyTo(array, index);
 }
        // Returns an array of ICollection objects.  The first is the ConsumerConnectionPoints, the
        // second is the ProviderConnectionPoints.
        private static ICollection[] CreateConnectionPoints(Type type) {
            ArrayList consumerConnectionPoints = new ArrayList();
            ArrayList providerConnectionPoints = new ArrayList();

            MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            foreach (MethodInfo method in methods) {

                // Create consumer connection points
                object[] consumerAttributes = method.GetCustomAttributes(typeof(ConnectionConsumerAttribute), true);
                // ConnectionConsumerAttribute.AllowMultiple is false
                Debug.Assert(consumerAttributes.Length == 0 || consumerAttributes.Length == 1);
                if (consumerAttributes.Length == 1) {
                    // Consumer signature: method is public, return type is void, takes one parameter
                    ParameterInfo[] parameters = method.GetParameters();
                    Type parameterType = null;
                    if (parameters.Length == 1) {
                        parameterType = parameters[0].ParameterType;
                    }

                    if (method.IsPublic && method.ReturnType == typeof(void) && parameterType != null) {
                        ConnectionConsumerAttribute attribute = consumerAttributes[0] as ConnectionConsumerAttribute;
                        String displayName = attribute.DisplayName;
                        String id = attribute.ID;
                        Type connectionPointType = attribute.ConnectionPointType;
                        bool allowsMultipleConnections = attribute.AllowsMultipleConnections;
                        ConsumerConnectionPoint connectionPoint;
                        if (connectionPointType == null) {
                            connectionPoint = new ConsumerConnectionPoint(method, parameterType, type,
                                                                          displayName, id, allowsMultipleConnections);
                        }
                        else {
                            // The ConnectionPointType is validated in the attribute property getter
                            Object[] args = new Object[] { method, parameterType, type, displayName, id, allowsMultipleConnections };
                            connectionPoint = (ConsumerConnectionPoint)Activator.CreateInstance(connectionPointType, args);
                        }
                        consumerConnectionPoints.Add(connectionPoint);
                    }
                    else {
                        throw new InvalidOperationException(SR.GetString(SR.WebPartManager_InvalidConsumerSignature, method.Name, type.FullName));
                    }
                }

                // Create provider connection points
                object[] providerAttributes = method.GetCustomAttributes(typeof(ConnectionProviderAttribute), true);
                // ConnectionProviderAttribute.AllowMultiple is false
                Debug.Assert(providerAttributes.Length == 0 || providerAttributes.Length == 1);
                if (providerAttributes.Length == 1) {
                    // Provider signature: method is public, return type is an object, and takes no parameters
                    Type returnType = method.ReturnType;
                    if (method.IsPublic && returnType != typeof(void) && method.GetParameters().Length == 0) {
                        ConnectionProviderAttribute attribute = providerAttributes[0] as ConnectionProviderAttribute;
                        String displayName = attribute.DisplayName;
                        String id = attribute.ID;
                        Type connectionPointType = attribute.ConnectionPointType;
                        bool allowsMultipleConnections = attribute.AllowsMultipleConnections;
                        ProviderConnectionPoint connectionPoint;
                        if (connectionPointType == null) {
                            connectionPoint = new ProviderConnectionPoint(method, returnType, type,
                                                                          displayName, id, allowsMultipleConnections);
                        }
                        else {
                            // The ConnectionPointType is validated in the attribute property getter
                            Object[] args = new Object[] { method, returnType, type, displayName, id, allowsMultipleConnections };
                            connectionPoint = (ProviderConnectionPoint)Activator.CreateInstance(connectionPointType, args);
                        }
                        providerConnectionPoints.Add(connectionPoint);
                    }
                    else {
                        throw new InvalidOperationException(SR.GetString(SR.WebPartManager_InvalidProviderSignature, method.Name, type.FullName));
                    }
                }
            }

            return new ICollection[] { new ConsumerConnectionPointCollection(consumerConnectionPoints),
                new ProviderConnectionPointCollection(providerConnectionPoints) };
        }
 public virtual new WebPartConnection ConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartTransformer transformer)
 {
   return default(WebPartConnection);
 }
        /// <devdoc>
        /// If the WebPart is a consumer on the given connection point, returns the corresponding connection.
        /// Else, returns null.
        /// </devdoc>
        internal WebPartConnection GetConnectionForConsumer(WebPart consumer, ConsumerConnectionPoint connectionPoint) {
            ConsumerConnectionPoint actualConnectionPoint = connectionPoint;
            // 
            if (connectionPoint == null) {
                actualConnectionPoint = GetConsumerConnectionPoint(consumer, null);
            }

            // PERF: Use the StaticConnections and DynamicConnections collections separately, instead
            // of using the Connections property which is created on every call.
            foreach (WebPartConnection connection in StaticConnections) {
                if (!Internals.ConnectionDeleted(connection) && connection.Consumer == consumer) {
                    ConsumerConnectionPoint c =
                        GetConsumerConnectionPoint(consumer, connection.ConsumerConnectionPointID);
                    if (c == actualConnectionPoint) {
                        return connection;
                    }
                }
            }

            foreach (WebPartConnection connection in DynamicConnections) {
                if (!Internals.ConnectionDeleted(connection) && connection.Consumer == consumer) {
                    ConsumerConnectionPoint c =
                        GetConsumerConnectionPoint(consumer, connection.ConsumerConnectionPointID);
                    if (c == actualConnectionPoint) {
                        return connection;
                    }
                }
            }

            return null;
        }
 private bool EnsurePendingData()
 {
     if (this.WebPartToConnect == null)
     {
         this.ClearPendingConnection();
         this._mode = ConnectionsZoneMode.ExistingConnections;
         return false;
     }
     if ((this._pendingConsumer != null) && (((this._pendingConsumerConnectionPoint == null) || (this._pendingProvider == null)) || (this._pendingProviderConnectionPoint == null)))
     {
         this.DisplayConnectionError();
         return false;
     }
     if (this._pendingConnectionType == ConnectionType.Provider)
     {
         this._pendingProvider = this.WebPartToConnect;
         this._pendingProviderConnectionPoint = base.WebPartManager.GetProviderConnectionPoint(this.WebPartToConnect, this._pendingConnectionPointID);
         if (this._pendingProviderConnectionPoint == null)
         {
             this.DisplayConnectionError();
             return false;
         }
         IDictionary dictionary = (IDictionary) this._connectionPointInfo[this._pendingProviderConnectionPoint];
         ConsumerInfo info = null;
         if (dictionary != null)
         {
             info = (ConsumerInfo) dictionary[this._pendingSelectedValue];
         }
         if (info == null)
         {
             this.DisplayConnectionError();
             return false;
         }
         this._pendingConsumer = info.WebPart;
         this._pendingConsumerConnectionPoint = info.ConnectionPoint;
         return true;
     }
     string str = this._pendingConsumerID;
     if (this._pendingConnectionType == ConnectionType.Consumer)
     {
         if (!string.IsNullOrEmpty(this._pendingConnectionID))
         {
             WebPartConnection connection = base.WebPartManager.Connections[this._pendingConnectionID];
             if (connection != null)
             {
                 this._pendingConnectionPointID = connection.ConsumerConnectionPointID;
                 this._pendingConsumer = connection.Consumer;
                 this._pendingConsumerConnectionPoint = connection.ConsumerConnectionPoint;
                 this._pendingConsumerID = connection.Consumer.ID;
                 this._pendingProvider = connection.Provider;
                 this._pendingProviderConnectionPoint = connection.ProviderConnectionPoint;
                 this._pendingTransformer = connection.Transformer;
                 this._pendingSelectedValue = null;
                 this._pendingConnectionType = ConnectionType.Consumer;
                 return true;
             }
             this.DisplayConnectionError();
             return false;
         }
         if (string.IsNullOrEmpty(str))
         {
             this._pendingConsumer = this.WebPartToConnect;
         }
         else
         {
             this._pendingConsumer = base.WebPartManager.WebParts[str];
         }
         this._pendingConsumerConnectionPoint = base.WebPartManager.GetConsumerConnectionPoint(this._pendingConsumer, this._pendingConnectionPointID);
         if (this._pendingConsumerConnectionPoint == null)
         {
             this.DisplayConnectionError();
             return false;
         }
         if (!string.IsNullOrEmpty(this._pendingSelectedValue))
         {
             IDictionary dictionary2 = (IDictionary) this._connectionPointInfo[this._pendingConsumerConnectionPoint];
             ProviderInfo info2 = null;
             if (dictionary2 != null)
             {
                 info2 = (ProviderInfo) dictionary2[this._pendingSelectedValue];
             }
             if (info2 == null)
             {
                 this.DisplayConnectionError();
                 return false;
             }
             this._pendingProvider = info2.WebPart;
             this._pendingProviderConnectionPoint = info2.ConnectionPoint;
         }
         return true;
     }
     this.ClearPendingConnection();
     return false;
 }
 public bool Contains(ConsumerConnectionPoint connectionPoint)
 {
     return(default(bool));
 }
 public int IndexOf(ConsumerConnectionPoint connectionPoint)
 {
     return(default(int));
 }
        private bool EnsurePendingData() {
            if (WebPartToConnect == null) {
                ClearPendingConnection();
                _mode = ConnectionsZoneMode.ExistingConnections;
                return false;
            }

            if ((_pendingConsumer != null) &&
                (_pendingConsumerConnectionPoint == null ||
                _pendingProvider == null ||
                _pendingProviderConnectionPoint == null)) {

                DisplayConnectionError();
                return false;
            }

            if (_pendingConnectionType == ConnectionType.Provider) {
                Debug.Assert(_pendingSelectedValue != null);

                _pendingProvider = WebPartToConnect;
                _pendingProviderConnectionPoint =
                    WebPartManager.GetProviderConnectionPoint(WebPartToConnect, _pendingConnectionPointID);

                if (_pendingProviderConnectionPoint == null) {
                    DisplayConnectionError();
                    return false;
                }

                IDictionary consumers = (IDictionary)_connectionPointInfo[_pendingProviderConnectionPoint];
                ConsumerInfo consumerInfo = null;
                if (consumers != null) {
                    consumerInfo = (ConsumerInfo)consumers[_pendingSelectedValue];
                }

                if (consumerInfo == null) {
                    DisplayConnectionError();
                    return false;
                }

                _pendingConsumer = consumerInfo.WebPart;
                _pendingConsumerConnectionPoint = consumerInfo.ConnectionPoint;

                return true;
            }

            string consumerID = _pendingConsumerID;
            if (_pendingConnectionType == ConnectionType.Consumer) {
                if (!String.IsNullOrEmpty(_pendingConnectionID)) {
                    // Editing an existing connection
                    WebPartConnection connection = WebPartManager.Connections[_pendingConnectionID];
                    if (connection != null) {
                        _pendingConnectionPointID = connection.ConsumerConnectionPointID;
                        _pendingConsumer = connection.Consumer;
                        _pendingConsumerConnectionPoint = connection.ConsumerConnectionPoint;
                        _pendingConsumerID = connection.Consumer.ID;
                        _pendingProvider = connection.Provider;
                        _pendingProviderConnectionPoint = connection.ProviderConnectionPoint;
                        _pendingTransformer = connection.Transformer;
                        _pendingSelectedValue = null;
                        _pendingConnectionType = ConnectionType.Consumer;
                        return true;
                    }
                    DisplayConnectionError();
                    return false;
                }
                if (String.IsNullOrEmpty(consumerID)) {
                    _pendingConsumer = WebPartToConnect;
                }
                else {
                    _pendingConsumer = WebPartManager.WebParts[consumerID];
                }

                _pendingConsumerConnectionPoint =
                    WebPartManager.GetConsumerConnectionPoint(_pendingConsumer, _pendingConnectionPointID);

                if (_pendingConsumerConnectionPoint == null) {
                    DisplayConnectionError();
                    return false;
                }

                // Get provider
                if (!String.IsNullOrEmpty(_pendingSelectedValue)) {
                    IDictionary providers = (IDictionary)_connectionPointInfo[_pendingConsumerConnectionPoint];
                    ProviderInfo providerInfo = null;
                    if (providers != null) {
                        providerInfo = (ProviderInfo)providers[_pendingSelectedValue];
                    }

                    if (providerInfo == null) {
                        DisplayConnectionError();
                        return false;
                    }

                    _pendingProvider = providerInfo.WebPart;
                    _pendingProviderConnectionPoint = providerInfo.ConnectionPoint;
                }

                return true;
            }
            else {
                // No pending connection
                Debug.Assert(_pendingConnectionType == ConnectionType.None);

                ClearPendingConnection();

                return false;
            }
        }
        private IDictionary GetValidProviders(WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint,
                                              WebPartCollection webParts) {
            HybridDictionary validProviders = new HybridDictionary();

            // ConnectionsZone must check the AllowConnect property, since it only affects the UI
            // and is not checked by CanConnectWebParts()
            if (consumerConnectionPoint == null || consumer == null || !consumer.AllowConnect) {
                return validProviders;
            }

            // PERF: Skip if consumer is already connected, and does not allow multiple connections
            if (!consumerConnectionPoint.AllowsMultipleConnections &&
                WebPartManager.IsConsumerConnected(consumer, consumerConnectionPoint)) {
                return validProviders;
            }

            foreach (WebPart provider in webParts) {
                // ConnectionsZone must check the AllowConnect property, since it only affects the UI
                // and is not checked by CanConnectWebParts()
                if (!provider.AllowConnect) {
                    continue;
                }

                // PERF: Skip provider if it equals consumer or is closed
                if (provider == consumer || provider.IsClosed) {
                    continue;
                }

                foreach (ProviderConnectionPoint providerConnectionPoint in WebPartManager.GetProviderConnectionPoints(provider)) {
                    if (WebPartManager.CanConnectWebParts(provider, providerConnectionPoint,
                                                          consumer, consumerConnectionPoint)) {
                        validProviders.Add(provider.ID + ID_SEPARATOR + providerConnectionPoint.ID,
                            new ProviderInfo(provider, providerConnectionPoint));
                    }
                    else {
                        foreach (WebPartTransformer transformer in AvailableTransformers) {
                            if (WebPartManager.CanConnectWebParts(provider, providerConnectionPoint,
                                                                  consumer, consumerConnectionPoint, transformer)) {
                                validProviders.Add(provider.ID + ID_SEPARATOR + providerConnectionPoint.ID,
                                    new ProviderInfo(provider, providerConnectionPoint, transformer.GetType()));
                                break;
                            }
                        }
                    }
                }
            }

            return validProviders;
        }
 public bool CanConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint)
 {
     return(default(bool));
 }
 public ConsumerInfo(WebPart webPart, ConsumerConnectionPoint connectionPoint,
                     Type transformerType) : base(webPart, transformerType) {
     _connectionPoint = connectionPoint;
 }
 public int IndexOf(ConsumerConnectionPoint connectionPoint)
 {
   return default(int);
 }
 internal bool IsConsumerConnected(WebPart consumer, ConsumerConnectionPoint connectionPoint)
 {
     return (this.GetConnectionForConsumer(consumer, connectionPoint) != null);
 }
 public virtual bool CanConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartTransformer transformer)
 {
     return this.CanConnectWebPartsCore(provider, providerConnectionPoint, consumer, consumerConnectionPoint, transformer, false);
 }
 public virtual WebPartConnection ConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartTransformer transformer)
 {
     this.CanConnectWebPartsCore(provider, providerConnectionPoint, consumer, consumerConnectionPoint, transformer, true);
     if (this.DynamicConnections.IsReadOnly)
     {
         throw new InvalidOperationException(System.Web.SR.GetString("WebPartManager_ConnectTooLate"));
     }
     WebPartConnectionsCancelEventArgs e = new WebPartConnectionsCancelEventArgs(provider, providerConnectionPoint, consumer, consumerConnectionPoint);
     this.OnWebPartsConnecting(e);
     if (this._allowEventCancellation && e.Cancel)
     {
         return null;
     }
     Control control = provider.ToControl();
     Control control2 = consumer.ToControl();
     WebPartConnection connection = new WebPartConnection {
         ID = this.CreateDynamicConnectionID(),
         ProviderID = control.ID,
         ConsumerID = control2.ID,
         ProviderConnectionPointID = providerConnectionPoint.ID,
         ConsumerConnectionPointID = consumerConnectionPoint.ID
     };
     if (transformer != null)
     {
         this.Internals.SetTransformer(connection, transformer);
     }
     this.Internals.SetIsShared(connection, this.Personalization.Scope == PersonalizationScope.Shared);
     this.Internals.SetIsStatic(connection, false);
     this.DynamicConnections.Add(connection);
     this._hasDataChanged = true;
     this.OnWebPartsConnected(new WebPartConnectionsEventArgs(provider, providerConnectionPoint, consumer, consumerConnectionPoint, connection));
     return connection;
 }
 public virtual new bool CanConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartTransformer transformer)
 {
     return(default(bool));
 }
 internal WebPartConnection GetConnectionForConsumer(WebPart consumer, ConsumerConnectionPoint connectionPoint)
 {
     ConsumerConnectionPoint consumerConnectionPoint = connectionPoint;
     if (connectionPoint == null)
     {
         consumerConnectionPoint = this.GetConsumerConnectionPoint(consumer, null);
     }
     foreach (WebPartConnection connection in this.StaticConnections)
     {
         if ((!this.Internals.ConnectionDeleted(connection) && (connection.Consumer == consumer)) && (this.GetConsumerConnectionPoint(consumer, connection.ConsumerConnectionPointID) == consumerConnectionPoint))
         {
             return connection;
         }
     }
     foreach (WebPartConnection connection2 in this.DynamicConnections)
     {
         if ((!this.Internals.ConnectionDeleted(connection2) && (connection2.Consumer == consumer)) && (this.GetConsumerConnectionPoint(consumer, connection2.ConsumerConnectionPointID) == consumerConnectionPoint))
         {
             return connection2;
         }
     }
     return null;
 }
 public WebPartConnection ConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint)
 {
     return(default(WebPartConnection));
 }
 public bool CanConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint)
 {
     return this.CanConnectWebParts(provider, providerConnectionPoint, consumer, consumerConnectionPoint, null);
 }
 public WebPartConnectionsEventArgs(WebPart provider, ProviderConnectionPoint providerConnectionPoint,
                                    WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint,
                                    WebPartConnection connection) : this(provider, providerConnectionPoint,
                                                                         consumer, consumerConnectionPoint) {
     _connection = connection;
 }
 private bool CanConnectWebPartsCore(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartTransformer transformer, bool throwOnError)
 {
     if (!this.Personalization.IsModifiable)
     {
         if (!throwOnError)
         {
             return false;
         }
         this.Personalization.EnsureEnabled(true);
     }
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     if (!this.Controls.Contains(provider))
     {
         throw new ArgumentException(System.Web.SR.GetString("UnknownWebPart"), "provider");
     }
     if (consumer == null)
     {
         throw new ArgumentNullException("consumer");
     }
     if (!this.Controls.Contains(consumer))
     {
         throw new ArgumentException(System.Web.SR.GetString("UnknownWebPart"), "consumer");
     }
     if (providerConnectionPoint == null)
     {
         throw new ArgumentNullException("providerConnectionPoint");
     }
     if (consumerConnectionPoint == null)
     {
         throw new ArgumentNullException("consumerConnectionPoint");
     }
     Control control = provider.ToControl();
     Control control2 = consumer.ToControl();
     if (providerConnectionPoint.ControlType != control.GetType())
     {
         throw new ArgumentException(System.Web.SR.GetString("WebPartManager_InvalidConnectionPoint"), "providerConnectionPoint");
     }
     if (consumerConnectionPoint.ControlType != control2.GetType())
     {
         throw new ArgumentException(System.Web.SR.GetString("WebPartManager_InvalidConnectionPoint"), "consumerConnectionPoint");
     }
     if (provider == consumer)
     {
         if (throwOnError)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartManager_CantConnectToSelf"));
         }
         return false;
     }
     if (provider.IsClosed)
     {
         if (throwOnError)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartManager_CantConnectClosed", new object[] { provider.ID }));
         }
         return false;
     }
     if (consumer.IsClosed)
     {
         if (throwOnError)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartManager_CantConnectClosed", new object[] { consumer.ID }));
         }
         return false;
     }
     if (!providerConnectionPoint.GetEnabled(control))
     {
         if (throwOnError)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_DisabledConnectionPoint", new object[] { providerConnectionPoint.ID, provider.ID }));
         }
         return false;
     }
     if (!consumerConnectionPoint.GetEnabled(control2))
     {
         if (throwOnError)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_DisabledConnectionPoint", new object[] { consumerConnectionPoint.ID, consumer.ID }));
         }
         return false;
     }
     if (!providerConnectionPoint.AllowsMultipleConnections)
     {
         foreach (WebPartConnection connection in this.Connections)
         {
             if ((connection.Provider == provider) && (connection.ProviderConnectionPoint == providerConnectionPoint))
             {
                 if (throwOnError)
                 {
                     throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_Duplicate", new object[] { providerConnectionPoint.ID, provider.ID }));
                 }
                 return false;
             }
         }
     }
     if (!consumerConnectionPoint.AllowsMultipleConnections)
     {
         foreach (WebPartConnection connection2 in this.Connections)
         {
             if ((connection2.Consumer == consumer) && (connection2.ConsumerConnectionPoint == consumerConnectionPoint))
             {
                 if (throwOnError)
                 {
                     throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_Duplicate", new object[] { consumerConnectionPoint.ID, consumer.ID }));
                 }
                 return false;
             }
         }
     }
     if (transformer == null)
     {
         if (providerConnectionPoint.InterfaceType != consumerConnectionPoint.InterfaceType)
         {
             if (throwOnError)
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_NoCommonInterface", new string[] { providerConnectionPoint.DisplayName, provider.ID, consumerConnectionPoint.DisplayName, consumer.ID }));
             }
             return false;
         }
         ConnectionInterfaceCollection secondaryInterfaces = providerConnectionPoint.GetSecondaryInterfaces(control);
         if (!consumerConnectionPoint.SupportsConnection(control2, secondaryInterfaces))
         {
             if (throwOnError)
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_IncompatibleSecondaryInterfaces", new string[] { consumerConnectionPoint.DisplayName, consumer.ID, providerConnectionPoint.DisplayName, provider.ID }));
             }
             return false;
         }
     }
     else
     {
         Type type = transformer.GetType();
         if (!this.AvailableTransformers.Contains(type))
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_TransformerNotAvailable", new object[] { type.FullName }));
         }
         Type consumerType = WebPartTransformerAttribute.GetConsumerType(type);
         Type providerType = WebPartTransformerAttribute.GetProviderType(type);
         if (providerConnectionPoint.InterfaceType != consumerType)
         {
             if (throwOnError)
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_IncompatibleProviderTransformer", new object[] { providerConnectionPoint.DisplayName, provider.ID, type.FullName }));
             }
             return false;
         }
         if (providerType != consumerConnectionPoint.InterfaceType)
         {
             if (throwOnError)
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_IncompatibleConsumerTransformer", new object[] { type.FullName, consumerConnectionPoint.DisplayName, consumer.ID }));
             }
             return false;
         }
         if (!consumerConnectionPoint.SupportsConnection(control2, ConnectionInterfaceCollection.Empty))
         {
             if (throwOnError)
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_ConsumerRequiresSecondaryInterfaces", new object[] { consumerConnectionPoint.DisplayName, consumer.ID }));
             }
             return false;
         }
     }
     return true;
 }
 public bool Contains(ConsumerConnectionPoint connectionPoint) {
     return InnerList.Contains(connectionPoint);
 }