public ConnectionsZone() : base(WebPartManager.ConnectDisplayMode)
 {
     this._mode = ConnectionsZoneMode.ExistingConnections;
     this._pendingConnectionPointID = string.Empty;
     this._pendingConnectionType = ConnectionType.None;
     this._pendingSelectedValue = null;
     this._pendingConsumerID = string.Empty;
 }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        private void ConnectProvider(string providerConnectionPointID) {
            // We don't need to check for AllowConnect on the parts because we're already checking
            // that the data was in the drop-downs in the first place, and these check for AllowConnect.
            WebPart provider = WebPartToConnect;

            if (provider == null || provider.IsClosed) {
                DisplayConnectionError();
                return;
            }

            ProviderConnectionPoint providerConnectionPoint =
                WebPartManager.GetProviderConnectionPoint(provider, providerConnectionPointID);

            if (providerConnectionPoint == null) {
                DisplayConnectionError();
                return;
            }

            EnsureChildControls();

            if (_connectDropDownLists == null ||
                !_connectDropDownLists.Contains(providerConnectionPoint) ||
                _connectionPointInfo == null ||
                !_connectionPointInfo.Contains(providerConnectionPoint)) {

                DisplayConnectionError();
                return;
            }

            DropDownList list = (DropDownList)_connectDropDownLists[providerConnectionPoint];
            // Using Request instead of the control's selected value because some concurrency
            // conditions exist under which the selected item does not exist any more in the list.
            // In this case, we want to display a connection error (VSWhidbey 368543)
            string selectedValue = Page.Request.Form[list.UniqueID];
            if (!String.IsNullOrEmpty(selectedValue)) {
                IDictionary consumers = (IDictionary)_connectionPointInfo[providerConnectionPoint];

                if (consumers == null || !consumers.Contains(selectedValue)) {
                    DisplayConnectionError();
                    return;
                }

                ConsumerInfo consumer = (ConsumerInfo)consumers[selectedValue];
                Type transformerType = consumer.TransformerType;
                if (transformerType != null) {
                    Debug.Assert(transformerType.IsSubclassOf(typeof(WebPartTransformer)));
                    WebPartTransformer transformer =
                        (WebPartTransformer)WebPartUtil.CreateObjectFromType(transformerType);
                    if (GetConfigurationControl(transformer) == null) {
                        if (WebPartManager.CanConnectWebParts(provider, providerConnectionPoint,
                                                                consumer.WebPart, consumer.ConnectionPoint, transformer)) {
                            WebPartManager.ConnectWebParts(provider, providerConnectionPoint,
                                                            consumer.WebPart, consumer.ConnectionPoint, transformer);
                        }
                        else {
                            DisplayConnectionError();
                        }
                        Reset();
                    }
                    else {
                        // Control will be created and added on next call to CreateChildControls
                        _pendingConnectionType = ConnectionType.Provider;
                        _pendingConnectionPointID = providerConnectionPointID;
                        _pendingSelectedValue = selectedValue;
                        _mode = ConnectionsZoneMode.ConfiguringTransformer;
                        ChildControlsCreated = false;
                    }
                }
                else {
                    if (WebPartManager.CanConnectWebParts(provider, providerConnectionPoint,
                                                            consumer.WebPart, consumer.ConnectionPoint)) {
                        WebPartManager.ConnectWebParts(provider, providerConnectionPoint,
                                                        consumer.WebPart, consumer.ConnectionPoint);
                    }
                    else {
                        DisplayConnectionError();
                    }
                    Reset();
                }
                // Reset the list to the blank selection
                list.SelectedValue = null;
            }
        }
コード例 #4
0
        private void SetDropDownProperties() {
            bool anyRelevantControl = false;
            WebPart webPartToConnect = WebPartToConnect;
            if (webPartToConnect != null && !webPartToConnect.IsClosed) {
                Debug.Assert(WebPartManager != null);

                WebPartCollection webParts = WebPartManager.WebParts;

                ProviderConnectionPointCollection providerConnectionPoints =
                    WebPartManager.GetEnabledProviderConnectionPoints(webPartToConnect);
                foreach (ProviderConnectionPoint providerConnectionPoint in providerConnectionPoints) {
                    DropDownList list = (DropDownList)_connectDropDownLists[providerConnectionPoint];
                    if (list == null) {
                        continue;
                    }
                    list.Items.Clear();

                    // Set the selected index to 0, in case it was set by ControlState
                    list.SelectedIndex = 0;

                    IDictionary consumers = GetValidConsumers(webPartToConnect, providerConnectionPoint, webParts);
                    if (consumers.Count == 0) {
                        list.Enabled = false;
                        list.Items.Add(new ListItem(SR.GetString(SR.ConnectionsZone_NoConsumers), String.Empty));
                    }
                    else {
                        list.Enabled = true;
                        list.Items.Add(new ListItem());
                        _connectionPointInfo[providerConnectionPoint] = consumers;

                        // If the WebPart is currently connected on this provider point
                        // and does not support multiple connections,
                        // select the current provider and disable the dropdown.
                        WebPartConnection currentConnection = providerConnectionPoint.AllowsMultipleConnections ?
                            null :
                            WebPartManager.GetConnectionForProvider(webPartToConnect, providerConnectionPoint);
                        WebPart currentConsumerWebPart = null;
                        ConsumerConnectionPoint currentConsumerConnectionPoint = null;
                        if (currentConnection != null) {
                            currentConsumerWebPart = currentConnection.Consumer;
                            currentConsumerConnectionPoint = currentConnection.ConsumerConnectionPoint;
                            list.Enabled = false;
                        }
                        else {
                            anyRelevantControl = true;
                        }

                        foreach (DictionaryEntry consumerEntry in consumers) {
                            ConsumerInfo consumer = (ConsumerInfo)consumerEntry.Value;
                            ListItem item = new ListItem();
                            item.Text = GetDisplayTitle(consumer.WebPart, consumer.ConnectionPoint, true);
                            item.Value = (string)consumerEntry.Key;
                            if (currentConnection != null &&
                                consumer.WebPart == currentConsumerWebPart &&
                                consumer.ConnectionPoint == currentConsumerConnectionPoint) {

                                item.Selected = true;
                            }
                            list.Items.Add(item);
                        }
                    }
                }

                ConsumerConnectionPointCollection consumerConnectionPoints =
                    WebPartManager.GetEnabledConsumerConnectionPoints(webPartToConnect);
                foreach (ConsumerConnectionPoint consumerConnectionPoint in consumerConnectionPoints) {
                    DropDownList list = (DropDownList)_connectDropDownLists[consumerConnectionPoint];
                    if (list == null) {
                        continue;
                    }
                    list.Items.Clear();

                    // Set the selected index to 0, in case it was set by ControlState
                    list.SelectedIndex = 0;

                    IDictionary providers = GetValidProviders(webPartToConnect, consumerConnectionPoint, webParts);
                    if (providers.Count == 0) {
                        list.Enabled = false;
                        list.Items.Add(new ListItem(SR.GetString(SR.ConnectionsZone_NoProviders), String.Empty));
                    }
                    else {
                        list.Enabled = true;
                        list.Items.Add(new ListItem());
                        _connectionPointInfo[consumerConnectionPoint] = providers;

                        // If the WebPart is currently connected on this consumer point
                        // and does not support multiple connections,
                        // select the current provider and disable the dropdown.
                        WebPartConnection currentConnection = consumerConnectionPoint.AllowsMultipleConnections ?
                            null :
                            WebPartManager.GetConnectionForConsumer(webPartToConnect, consumerConnectionPoint);
                        WebPart currentProviderWebPart = null;
                        ProviderConnectionPoint currentProviderConnectionPoint = null;
                        if (currentConnection != null) {
                            currentProviderWebPart = currentConnection.Provider;
                            currentProviderConnectionPoint = currentConnection.ProviderConnectionPoint;
                            list.Enabled = false;
                        }
                        else {
                            anyRelevantControl = true;
                        }

                        foreach (DictionaryEntry providerEntry in providers) {
                            ProviderInfo provider = (ProviderInfo)providerEntry.Value;
                            ListItem item = new ListItem();
                            item.Text = GetDisplayTitle(provider.WebPart, provider.ConnectionPoint, false);
                            item.Value = (string)providerEntry.Key;
                            if (currentConnection != null &&
                                provider.WebPart == currentProviderWebPart &&
                                provider.ConnectionPoint == currentProviderConnectionPoint) {
                                item.Selected = true;
                            }
                            list.Items.Add(item);
                        }
                    }
                }

                if (_pendingConnectionType == ConnectionType.Consumer &&
                    _pendingSelectedValue != null &&
                    _pendingSelectedValue.Length > 0) {

                    EnsurePendingData();

                    if (_pendingConsumerConnectionPoint != null) {
                        // Display the pending connection in the appropriate DropDownList
                        Debug.Assert(_pendingSelectedValue != null);
                        DropDownList list = (DropDownList)_connectDropDownLists[_pendingConsumerConnectionPoint];
                        if (list == null) {
                            _mode = ConnectionsZoneMode.ExistingConnections;
                            return;
                        }
                        SelectValueInList(list, _pendingSelectedValue);
                    }
                    else {
                        _mode = ConnectionsZoneMode.ExistingConnections;
                        return;
                    }
                }
                else if (_pendingConnectionType == ConnectionType.Provider) {
                    EnsurePendingData();

                    if (_pendingProviderConnectionPoint != null) {
                        // Display the pending connection in the appropriate DropDownList
                        Debug.Assert(_pendingSelectedValue != null);
                        DropDownList list = (DropDownList)_connectDropDownLists[_pendingProviderConnectionPoint];
                        if (list == null) {
                            _mode = ConnectionsZoneMode.ExistingConnections;
                            return;
                        }
                        SelectValueInList(list, _pendingSelectedValue);
                    }
                    else {
                        _mode = ConnectionsZoneMode.ExistingConnections;
                        return;
                    }
                }

                if (!anyRelevantControl &&
                    (_mode == ConnectionsZoneMode.ConnectToConsumer ||
                    _mode == ConnectionsZoneMode.ConnectToProvider)) {

                    _mode = ConnectionsZoneMode.ExistingConnections;
                }
            }
        }
コード例 #5
0
 private void Reset() {
     ClearPendingConnection();
     ChildControlsCreated = false;
     _mode = ConnectionsZoneMode.ExistingConnections;
 }
コード例 #6
0
        protected override void RaisePostBackEvent(string eventArgument) {
            if (WebPartToConnect == null) {
                ClearPendingConnection();
                _mode = ConnectionsZoneMode.ExistingConnections;
                return;
            }
            string[] eventArguments = eventArgument.Split(ID_SEPARATOR);
            if (eventArguments.Length == 2 &&
                String.Equals(eventArguments[0], disconnectEventArgument, StringComparison.OrdinalIgnoreCase)) {
                // Disconnecting
                if (DisconnectVerb.Visible && DisconnectVerb.Enabled) {
                    string connectionID = eventArguments[1];

                    Disconnect(connectionID);

                    _mode = ConnectionsZoneMode.ExistingConnections;
                }
            }
            else if (eventArguments.Length == 3 &&
                String.Equals(eventArguments[0], connectEventArgument, StringComparison.OrdinalIgnoreCase)) {
                // Connecting
                if (ConnectVerb.Visible && ConnectVerb.Enabled) {
                    string connectionPointID = eventArguments[2];
                    if (String.Equals(eventArguments[1], providerEventArgument, StringComparison.OrdinalIgnoreCase)) {
                        ConnectProvider(connectionPointID);
                    }
                    else {
                        ConnectConsumer(connectionPointID);
                    }
                }
            }
            else if (eventArguments.Length == 2 &&
                String.Equals(eventArguments[0], configureEventArgument, StringComparison.OrdinalIgnoreCase)) {
                // Displaying transformer UI
                _pendingConnectionID = eventArguments[1];
                _pendingConnectionType = ConnectionType.Consumer;
                _mode = ConnectionsZoneMode.ConfiguringTransformer;
            }
            else if (String.Equals(eventArgument, connectConsumerEventArgument, StringComparison.OrdinalIgnoreCase)) {
                // Create connection to consumer
                _mode = ConnectionsZoneMode.ConnectToConsumer;
            }
            else if (String.Equals(eventArgument, connectProviderEventArgument, StringComparison.OrdinalIgnoreCase)) {
                // Create connection to provider
                _mode = ConnectionsZoneMode.ConnectToProvider;
            }
            else if (String.Equals(eventArgument, closeEventArgument, StringComparison.OrdinalIgnoreCase)) {
                // Closing the zone
                if (CloseVerb.Visible && CloseVerb.Enabled) {
                    Close();
                    _mode = ConnectionsZoneMode.ExistingConnections;
                }
            }
            else if (String.Equals(eventArgument, cancelEventArgument, StringComparison.OrdinalIgnoreCase)) {
                // Cancelling connection creation
                if (CancelVerb.Visible && CancelVerb.Enabled) {
                    _mode = ConnectionsZoneMode.ExistingConnections;
                }
            }
            else {
                base.RaisePostBackEvent(eventArgument);
            }
        }
コード例 #7
0
        protected internal override void LoadControlState(object savedState) {
            if (savedState != null) {
                object[] state = (object[])savedState;
                if (state.Length != controlStateArrayLength) {
                    throw new ArgumentException(SR.GetString(SR.Invalid_ControlState));
                }

                base.LoadControlState(state[baseIndex]);

                if (state[modeIndex] != null) {
                    _mode = (ConnectionsZoneMode)state[modeIndex];
                }
                if (state[pendingConnectionPointIDIndex] != null) {
                    _pendingConnectionPointID = (string)state[pendingConnectionPointIDIndex];
                }
                if (state[pendingConnectionTypeIndex] != null) {
                    _pendingConnectionType = (ConnectionType)state[pendingConnectionTypeIndex];
                }
                if (state[pendingSelectedValueIndex] != null) {
                    _pendingSelectedValue = (string)state[pendingSelectedValueIndex];
                }
                if (state[pendingConsumerIDIndex] != null) {
                    _pendingConsumerID = (string)state[pendingConsumerIDIndex];
                }
                if (state[pendingTransformerTypeNameIndex] != null) {
                    _pendingTransformerConfigurationControlTypeName = (string)state[pendingTransformerTypeNameIndex];
                }
                if (state[pendingConnectionIDIndex] != null) {
                    _pendingConnectionID = (string)state[pendingConnectionIDIndex];
                }
            }
            else {
                base.LoadControlState(null);
            }
        }
 private void ConnectConsumer(string consumerConnectionPointID)
 {
     WebPart webPartToConnect = this.WebPartToConnect;
     if ((webPartToConnect == null) || webPartToConnect.IsClosed)
     {
         this.DisplayConnectionError();
     }
     else
     {
         ConsumerConnectionPoint consumerConnectionPoint = base.WebPartManager.GetConsumerConnectionPoint(webPartToConnect, consumerConnectionPointID);
         if (consumerConnectionPoint == null)
         {
             this.DisplayConnectionError();
         }
         else
         {
             this.EnsureChildControls();
             if (((this._connectDropDownLists == null) || !this._connectDropDownLists.Contains(consumerConnectionPoint)) || ((this._connectionPointInfo == null) || !this._connectionPointInfo.Contains(consumerConnectionPoint)))
             {
                 this.DisplayConnectionError();
             }
             else
             {
                 DropDownList list = (DropDownList) this._connectDropDownLists[consumerConnectionPoint];
                 string str = this.Page.Request.Form[list.UniqueID];
                 if (!string.IsNullOrEmpty(str))
                 {
                     IDictionary dictionary = (IDictionary) this._connectionPointInfo[consumerConnectionPoint];
                     if ((dictionary == null) || !dictionary.Contains(str))
                     {
                         this.DisplayConnectionError();
                     }
                     else
                     {
                         ProviderInfo info = (ProviderInfo) dictionary[str];
                         Type transformerType = info.TransformerType;
                         if (transformerType != null)
                         {
                             WebPartTransformer transformer = (WebPartTransformer) WebPartUtil.CreateObjectFromType(transformerType);
                             if (this.GetConfigurationControl(transformer) == null)
                             {
                                 if (base.WebPartManager.CanConnectWebParts(info.WebPart, info.ConnectionPoint, webPartToConnect, consumerConnectionPoint, transformer))
                                 {
                                     base.WebPartManager.ConnectWebParts(info.WebPart, info.ConnectionPoint, webPartToConnect, consumerConnectionPoint, transformer);
                                 }
                                 else
                                 {
                                     this.DisplayConnectionError();
                                 }
                                 this.Reset();
                             }
                             else
                             {
                                 this._pendingConnectionType = ConnectionType.Consumer;
                                 this._pendingConnectionPointID = consumerConnectionPointID;
                                 this._pendingSelectedValue = str;
                                 this._mode = ConnectionsZoneMode.ConfiguringTransformer;
                                 base.ChildControlsCreated = false;
                             }
                         }
                         else
                         {
                             if (base.WebPartManager.CanConnectWebParts(info.WebPart, info.ConnectionPoint, webPartToConnect, consumerConnectionPoint))
                             {
                                 base.WebPartManager.ConnectWebParts(info.WebPart, info.ConnectionPoint, webPartToConnect, consumerConnectionPoint);
                             }
                             else
                             {
                                 this.DisplayConnectionError();
                             }
                             this.Reset();
                         }
                         list.SelectedValue = null;
                     }
                 }
             }
         }
     }
 }
 protected override void RaisePostBackEvent(string eventArgument)
 {
     if (this.WebPartToConnect == null)
     {
         this.ClearPendingConnection();
         this._mode = ConnectionsZoneMode.ExistingConnections;
     }
     else
     {
         string[] strArray = eventArgument.Split(new char[] { '$' });
         if ((strArray.Length == 2) && string.Equals(strArray[0], "disconnect", StringComparison.OrdinalIgnoreCase))
         {
             if (this.DisconnectVerb.Visible && this.DisconnectVerb.Enabled)
             {
                 string connectionID = strArray[1];
                 this.Disconnect(connectionID);
                 this._mode = ConnectionsZoneMode.ExistingConnections;
             }
         }
         else if ((strArray.Length == 3) && string.Equals(strArray[0], "connect", StringComparison.OrdinalIgnoreCase))
         {
             if (this.ConnectVerb.Visible && this.ConnectVerb.Enabled)
             {
                 string providerConnectionPointID = strArray[2];
                 if (string.Equals(strArray[1], "provider", StringComparison.OrdinalIgnoreCase))
                 {
                     this.ConnectProvider(providerConnectionPointID);
                 }
                 else
                 {
                     this.ConnectConsumer(providerConnectionPointID);
                 }
             }
         }
         else if ((strArray.Length == 2) && string.Equals(strArray[0], "edit", StringComparison.OrdinalIgnoreCase))
         {
             this._pendingConnectionID = strArray[1];
             this._pendingConnectionType = ConnectionType.Consumer;
             this._mode = ConnectionsZoneMode.ConfiguringTransformer;
         }
         else if (string.Equals(eventArgument, "connectconsumer", StringComparison.OrdinalIgnoreCase))
         {
             this._mode = ConnectionsZoneMode.ConnectToConsumer;
         }
         else if (string.Equals(eventArgument, "connectprovider", StringComparison.OrdinalIgnoreCase))
         {
             this._mode = ConnectionsZoneMode.ConnectToProvider;
         }
         else if (string.Equals(eventArgument, "close", StringComparison.OrdinalIgnoreCase))
         {
             if (this.CloseVerb.Visible && this.CloseVerb.Enabled)
             {
                 this.Close();
                 this._mode = ConnectionsZoneMode.ExistingConnections;
             }
         }
         else if (string.Equals(eventArgument, "cancel", StringComparison.OrdinalIgnoreCase))
         {
             if (this.CancelVerb.Visible && this.CancelVerb.Enabled)
             {
                 this._mode = ConnectionsZoneMode.ExistingConnections;
             }
         }
         else
         {
             base.RaisePostBackEvent(eventArgument);
         }
     }
 }
コード例 #10
0
 protected internal override void LoadControlState(object savedState)
 {
     if (savedState != null)
     {
         object[] objArray = (object[]) savedState;
         if (objArray.Length != 8)
         {
             throw new ArgumentException(System.Web.SR.GetString("Invalid_ControlState"));
         }
         base.LoadControlState(objArray[0]);
         if (objArray[1] != null)
         {
             this._mode = (ConnectionsZoneMode) objArray[1];
         }
         if (objArray[2] != null)
         {
             this._pendingConnectionPointID = (string) objArray[2];
         }
         if (objArray[3] != null)
         {
             this._pendingConnectionType = (ConnectionType) objArray[3];
         }
         if (objArray[4] != null)
         {
             this._pendingSelectedValue = (string) objArray[4];
         }
         if (objArray[5] != null)
         {
             this._pendingConsumerID = (string) objArray[5];
         }
         if (objArray[6] != null)
         {
             this._pendingTransformerConfigurationControlTypeName = (string) objArray[6];
         }
         if (objArray[7] != null)
         {
             this._pendingConnectionID = (string) objArray[7];
         }
     }
     else
     {
         base.LoadControlState(null);
     }
 }
コード例 #11
0
 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;
 }
コード例 #12
0
 private void SetDropDownProperties()
 {
     bool flag = false;
     WebPart webPartToConnect = this.WebPartToConnect;
     if ((webPartToConnect != null) && !webPartToConnect.IsClosed)
     {
         WebPartCollection webParts = base.WebPartManager.WebParts;
         foreach (ProviderConnectionPoint point in base.WebPartManager.GetEnabledProviderConnectionPoints(webPartToConnect))
         {
             DropDownList list = (DropDownList) this._connectDropDownLists[point];
             if (list != null)
             {
                 list.Items.Clear();
                 list.SelectedIndex = 0;
                 IDictionary dictionary = this.GetValidConsumers(webPartToConnect, point, webParts);
                 if (dictionary.Count == 0)
                 {
                     list.Enabled = false;
                     list.Items.Add(new ListItem(System.Web.SR.GetString("ConnectionsZone_NoConsumers"), string.Empty));
                 }
                 else
                 {
                     list.Enabled = true;
                     list.Items.Add(new ListItem());
                     this._connectionPointInfo[point] = dictionary;
                     WebPartConnection connection = point.AllowsMultipleConnections ? null : base.WebPartManager.GetConnectionForProvider(webPartToConnect, point);
                     WebPart consumer = null;
                     ConsumerConnectionPoint consumerConnectionPoint = null;
                     if (connection != null)
                     {
                         consumer = connection.Consumer;
                         consumerConnectionPoint = connection.ConsumerConnectionPoint;
                         list.Enabled = false;
                     }
                     else
                     {
                         flag = true;
                     }
                     foreach (DictionaryEntry entry in dictionary)
                     {
                         ConsumerInfo info = (ConsumerInfo) entry.Value;
                         ListItem item = new ListItem {
                             Text = this.GetDisplayTitle(info.WebPart, info.ConnectionPoint, true),
                             Value = (string) entry.Key
                         };
                         if (((connection != null) && (info.WebPart == consumer)) && (info.ConnectionPoint == consumerConnectionPoint))
                         {
                             item.Selected = true;
                         }
                         list.Items.Add(item);
                     }
                 }
             }
         }
         foreach (ConsumerConnectionPoint point3 in base.WebPartManager.GetEnabledConsumerConnectionPoints(webPartToConnect))
         {
             DropDownList list2 = (DropDownList) this._connectDropDownLists[point3];
             if (list2 != null)
             {
                 list2.Items.Clear();
                 list2.SelectedIndex = 0;
                 IDictionary dictionary2 = this.GetValidProviders(webPartToConnect, point3, webParts);
                 if (dictionary2.Count == 0)
                 {
                     list2.Enabled = false;
                     list2.Items.Add(new ListItem(System.Web.SR.GetString("ConnectionsZone_NoProviders"), string.Empty));
                 }
                 else
                 {
                     list2.Enabled = true;
                     list2.Items.Add(new ListItem());
                     this._connectionPointInfo[point3] = dictionary2;
                     WebPartConnection connection2 = point3.AllowsMultipleConnections ? null : base.WebPartManager.GetConnectionForConsumer(webPartToConnect, point3);
                     WebPart provider = null;
                     ProviderConnectionPoint providerConnectionPoint = null;
                     if (connection2 != null)
                     {
                         provider = connection2.Provider;
                         providerConnectionPoint = connection2.ProviderConnectionPoint;
                         list2.Enabled = false;
                     }
                     else
                     {
                         flag = true;
                     }
                     foreach (DictionaryEntry entry2 in dictionary2)
                     {
                         ProviderInfo info2 = (ProviderInfo) entry2.Value;
                         ListItem item2 = new ListItem {
                             Text = this.GetDisplayTitle(info2.WebPart, info2.ConnectionPoint, false),
                             Value = (string) entry2.Key
                         };
                         if (((connection2 != null) && (info2.WebPart == provider)) && (info2.ConnectionPoint == providerConnectionPoint))
                         {
                             item2.Selected = true;
                         }
                         list2.Items.Add(item2);
                     }
                 }
             }
         }
         if (((this._pendingConnectionType == ConnectionType.Consumer) && (this._pendingSelectedValue != null)) && (this._pendingSelectedValue.Length > 0))
         {
             this.EnsurePendingData();
             if (this._pendingConsumerConnectionPoint == null)
             {
                 this._mode = ConnectionsZoneMode.ExistingConnections;
                 return;
             }
             DropDownList list3 = (DropDownList) this._connectDropDownLists[this._pendingConsumerConnectionPoint];
             if (list3 == null)
             {
                 this._mode = ConnectionsZoneMode.ExistingConnections;
                 return;
             }
             this.SelectValueInList(list3, this._pendingSelectedValue);
         }
         else if (this._pendingConnectionType == ConnectionType.Provider)
         {
             this.EnsurePendingData();
             if (this._pendingProviderConnectionPoint == null)
             {
                 this._mode = ConnectionsZoneMode.ExistingConnections;
                 return;
             }
             DropDownList list4 = (DropDownList) this._connectDropDownLists[this._pendingProviderConnectionPoint];
             if (list4 == null)
             {
                 this._mode = ConnectionsZoneMode.ExistingConnections;
                 return;
             }
             this.SelectValueInList(list4, this._pendingSelectedValue);
         }
         if (!flag && ((this._mode == ConnectionsZoneMode.ConnectToConsumer) || (this._mode == ConnectionsZoneMode.ConnectToProvider)))
         {
             this._mode = ConnectionsZoneMode.ExistingConnections;
         }
     }
 }
コード例 #13
0
 private void Reset()
 {
     this.ClearPendingConnection();
     base.ChildControlsCreated = false;
     this._mode = ConnectionsZoneMode.ExistingConnections;
 }