Пример #1
0
 public WebPartConnectionsEventArgs(WebPart provider, System.Web.UI.WebControls.WebParts.ProviderConnectionPoint providerConnectionPoint, WebPart consumer, System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint consumerConnectionPoint)
 {
     this._provider = provider;
     this._providerConnectionPoint = providerConnectionPoint;
     this._consumer = consumer;
     this._consumerConnectionPoint = consumerConnectionPoint;
 }
 public WebPartConnectionsEventArgs(WebPart provider, System.Web.UI.WebControls.WebParts.ProviderConnectionPoint providerConnectionPoint, WebPart consumer, System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint consumerConnectionPoint)
 {
     this._provider = provider;
     this._providerConnectionPoint = providerConnectionPoint;
     this._consumer = consumer;
     this._consumerConnectionPoint = consumerConnectionPoint;
 }
Пример #3
0
 public WebPartConnectionsEventArgs(WebPart provider, System.Web.UI.WebControls.WebParts.ProviderConnectionPoint providerConnectionPoint, WebPart consumer, System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint consumerConnectionPoint, WebPartConnection connection) : this(provider, providerConnectionPoint, consumer, consumerConnectionPoint)
 {
     this._connection = connection;
 }
        internal void Activate()
        {
            this.Transformers.SetReadOnly();
            WebPart provider = this.Provider;
            WebPart consumer = this.Consumer;
            Control control  = provider.ToControl();
            Control control2 = consumer.ToControl();

            System.Web.UI.WebControls.WebParts.ProviderConnectionPoint providerConnectionPoint = this.ProviderConnectionPoint;
            if (!providerConnectionPoint.GetEnabled(control))
            {
                consumer.SetConnectErrorMessage(System.Web.SR.GetString("WebPartConnection_DisabledConnectionPoint", new object[] { providerConnectionPoint.DisplayName, provider.DisplayTitle }));
            }
            else
            {
                System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint consumerConnectionPoint = this.ConsumerConnectionPoint;
                if (!consumerConnectionPoint.GetEnabled(control2))
                {
                    consumer.SetConnectErrorMessage(System.Web.SR.GetString("WebPartConnection_DisabledConnectionPoint", new object[] { consumerConnectionPoint.DisplayName, consumer.DisplayTitle }));
                }
                else if (!provider.IsClosed && !consumer.IsClosed)
                {
                    WebPartTransformer transformer = this.Transformer;
                    if (transformer == null)
                    {
                        if (providerConnectionPoint.InterfaceType == consumerConnectionPoint.InterfaceType)
                        {
                            ConnectionInterfaceCollection secondaryInterfaces = providerConnectionPoint.GetSecondaryInterfaces(control);
                            if (consumerConnectionPoint.SupportsConnection(control2, secondaryInterfaces))
                            {
                                object data = providerConnectionPoint.GetObject(control);
                                consumerConnectionPoint.SetObject(control2, data);
                                this._isActive = true;
                            }
                            else
                            {
                                consumer.SetConnectErrorMessage(System.Web.SR.GetString("WebPartConnection_IncompatibleSecondaryInterfaces", new string[] { consumerConnectionPoint.DisplayName, consumer.DisplayTitle, providerConnectionPoint.DisplayName, provider.DisplayTitle }));
                            }
                        }
                        else
                        {
                            consumer.SetConnectErrorMessage(System.Web.SR.GetString("WebPartConnection_NoCommonInterface", new string[] { providerConnectionPoint.DisplayName, provider.DisplayTitle, consumerConnectionPoint.DisplayName, consumer.DisplayTitle }));
                        }
                    }
                    else
                    {
                        Type type = transformer.GetType();
                        if (!this._webPartManager.AvailableTransformers.Contains(type))
                        {
                            string str;
                            if ((this._webPartManager.Context != null) && this._webPartManager.Context.IsCustomErrorEnabled)
                            {
                                str = System.Web.SR.GetString("WebPartConnection_TransformerNotAvailable");
                            }
                            else
                            {
                                str = System.Web.SR.GetString("WebPartConnection_TransformerNotAvailableWithType", new object[] { type.FullName });
                            }
                            consumer.SetConnectErrorMessage(str);
                        }
                        Type consumerType = WebPartTransformerAttribute.GetConsumerType(type);
                        Type providerType = WebPartTransformerAttribute.GetProviderType(type);
                        if ((providerConnectionPoint.InterfaceType == consumerType) && (providerType == consumerConnectionPoint.InterfaceType))
                        {
                            if (consumerConnectionPoint.SupportsConnection(control2, ConnectionInterfaceCollection.Empty))
                            {
                                object providerData = providerConnectionPoint.GetObject(control);
                                object obj4         = transformer.Transform(providerData);
                                consumerConnectionPoint.SetObject(control2, obj4);
                                this._isActive = true;
                            }
                            else
                            {
                                consumer.SetConnectErrorMessage(System.Web.SR.GetString("WebPartConnection_ConsumerRequiresSecondaryInterfaces", new object[] { consumerConnectionPoint.DisplayName, consumer.DisplayTitle }));
                            }
                        }
                        else if (providerConnectionPoint.InterfaceType != consumerType)
                        {
                            string str2;
                            if ((this._webPartManager.Context != null) && this._webPartManager.Context.IsCustomErrorEnabled)
                            {
                                str2 = System.Web.SR.GetString("WebPartConnection_IncompatibleProviderTransformer", new object[] { providerConnectionPoint.DisplayName, provider.DisplayTitle });
                            }
                            else
                            {
                                str2 = System.Web.SR.GetString("WebPartConnection_IncompatibleProviderTransformerWithType", new object[] { providerConnectionPoint.DisplayName, provider.DisplayTitle, type.FullName });
                            }
                            consumer.SetConnectErrorMessage(str2);
                        }
                        else
                        {
                            string str3;
                            if ((this._webPartManager.Context != null) && this._webPartManager.Context.IsCustomErrorEnabled)
                            {
                                str3 = System.Web.SR.GetString("WebPartConnection_IncompatibleConsumerTransformer", new object[] { consumerConnectionPoint.DisplayName, consumer.DisplayTitle });
                            }
                            else
                            {
                                str3 = System.Web.SR.GetString("WebPartConnection_IncompatibleConsumerTransformerWithType", new object[] { type.FullName, consumerConnectionPoint.DisplayName, consumer.DisplayTitle });
                            }
                            consumer.SetConnectErrorMessage(str3);
                        }
                    }
                }
            }
        }