ProviderConnectionPoint コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ProviderConnectionPoint コンストラクタの意味・解説 

ProviderConnectionPoint コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

ProviderConnectionPoint クラス新しインスタンス初期化します。

名前空間: System.Web.UI.WebControls.WebParts
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub New ( _
    callbackMethod As MethodInfo, _
    interfaceType As Type, _
    controlType As Type, _
    displayName As String, _
    id As String, _
    allowsMultipleConnections As Boolean _
)
Dim callbackMethod As MethodInfo
Dim interfaceType As Type
Dim controlType As Type
Dim displayName As String
Dim id As String
Dim allowsMultipleConnections As Boolean

Dim instance As New ProviderConnectionPoint(callbackMethod,
 interfaceType, controlType, displayName, id, allowsMultipleConnections)
public ProviderConnectionPoint (
    MethodInfo callbackMethod,
    Type interfaceType,
    Type controlType,
    string displayName,
    string id,
    bool allowsMultipleConnections
)
public:
ProviderConnectionPoint (
    MethodInfo^ callbackMethod, 
    Type^ interfaceType, 
    Type^ controlType, 
    String^ displayName, 
    String^ id, 
    bool allowsMultipleConnections
)
public ProviderConnectionPoint (
    MethodInfo callbackMethod, 
    Type interfaceType, 
    Type controlType, 
    String displayName, 
    String id, 
    boolean allowsMultipleConnections
)
public function ProviderConnectionPoint (
    callbackMethod : MethodInfo, 
    interfaceType : Type, 
    controlType : Type, 
    displayName : String, 
    id : String, 
    allowsMultipleConnections : boolean
)

パラメータ

callbackMethod

インターフェイス インスタンスコンシューマ返して接続確立するプロバイダ コントロールメソッド

interfaceType

プロバイダコンシューマ提供するインターフェイスType

controlType

プロバイダ コネクション ポイント関連付けられるプロバイダ コントロールType

displayName

接続ユーザー インターフェイス (UI) でユーザー表示されるプロバイダ コネクション ポイント表示名

id

プロバイダ コネクション ポイント一意識別子

allowsMultipleConnections

プロバイダ コネクション ポイントコンシューマとの間で同時に複数接続を持つことができるかどうかを示すブール値。

例外例外
例外種類条件

ArgumentNullException

callbackMethodnull 参照 (Visual Basic では Nothing) です。

または

interfaceTypenull 参照 (Visual Basic では Nothing) です。

または

controlTypenull 参照 (Visual Basic では Nothing) です。

または

displayNamenull 参照 (Visual Basic では Nothing) または空の文字列 ("") です。

ArgumentException

controlType が、プロバイダ コントロール (またはそれから派生した有効なクラス) と同じ型ではありません。

解説解説
使用例使用例

ProviderConnectionPoint クラス派生としてカスタム プロバイダ コネクション ポイント作成する方法次のコード例示します

コード例は、次の 3 つの部分から成ります

コード例最初部分は、プロバイダおよびコンシューマWebPart コントロールソースと、TableProviderConnectionPoint という名前のカスタム ProviderConnectionPoint クラスです。TableProviderConnectionPoint クラスコンストラクタ基本コンストラクタ呼び出し、「パラメータ」のセクション示した必須パラメータを渡す必要がありますまた、TableProviderWebPart クラスでは、接続のためのコールバック メソッドとして GetConnectionInterface メソッド指定されConnectionProvider 属性パラメータとしてカスタム TableProviderConnectionPoint宣言していることも必要です。これは、カスタム プロバイダ コネクション ポイント作成し、それをプロバイダ コントロール関連付ける方法示してます。この例は、ソース コード動的にコンパイルされ、Web アプリケーションの App_Code サブフォルダ内のファイルソース コード ファイル配置する必要があることを前提にしています。

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

//This sample code creates a Web Parts control that acts as a provider
 of table data.
namespace Samples.AspNet.CS.Controls
{
  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class TableProviderWebPart
 : WebPart, IWebPartTable
    {
        DataTable _table;

        public TableProviderWebPart()
        {
            _table = new DataTable();

            DataColumn col = new DataColumn();
            col.DataType = typeof(string);
            col.ColumnName = "Name";
            _table.Columns.Add(col);

            col = new DataColumn();
            col.DataType = typeof(string);
            col.ColumnName = "Address";
            _table.Columns.Add(col);

            col = new DataColumn();
            col.DataType = typeof(int);
            col.ColumnName = "ZIP Code";
            _table.Columns.Add(col);

            DataRow row = _table.NewRow();
            row["Name"] = "John Q. Public";
            row["Address"] = "123 Main Street";
            row["ZIP Code"] = 98000;
            _table.Rows.Add(row);
        }

        public PropertyDescriptorCollection Schema
        {
            get
            {
                return TypeDescriptor.GetProperties(_table.DefaultView[0]);
            }
        }
        public void GetTableData(TableCallback
 callback)
        {
                callback(_table.Rows);
        }

        public bool ConnectionPointEnabled
        {
            get
            {
                object o = ViewState["ConnectionPointEnabled"];
                return (o != null) ? (bool)o
 : true;
            }
            set
            {
                ViewState["ConnectionPointEnabled"] = value;
            }
        }

        [ConnectionProvider("Table", typeof(TableProviderConnectionPoint),
 AllowsMultipleConnections = true)]
        public IWebPartTable GetConnectionInterface()
        {
            return new TableProviderWebPart();
        }

        public class TableProviderConnectionPoint
 : ProviderConnectionPoint
        {
            public TableProviderConnectionPoint(MethodInfo callbackMethod,
 Type interfaceType, Type controlType,
            string name, string id, bool
 allowsMultipleConnections) : base(
                callbackMethod, interfaceType, controlType,
                name, id, allowsMultipleConnections)
            {
            }
            public override bool GetEnabled(Control
 control)
            {
                return ((TableProviderWebPart)control).ConnectionPointEnabled;
            }
        }
    }
    
    // This code sample demonstrates a custom WebPart controls that
 acts as 
    // a consumer in a Web Parts connection.
  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public class TableConsumer : WebPart
  {
    private IWebPartTable _provider;
    private ICollection _tableData;

    private void GetTableData(object tableData)
    {
      _tableData = (ICollection)tableData;
    }

    protected override void OnPreRender(EventArgs
 e)
    {
      if (_provider != null)
      {
        _provider.GetTableData(new TableCallback(GetTableData));
      }
    }


    protected override void RenderContents(HtmlTextWriter
 writer)
    {
      if (_provider != null)
      {
        PropertyDescriptorCollection props = _provider.Schema;
        int count = 0;
        if (props != null && props.Count
 > 0 && _tableData != null)
        {
          foreach (PropertyDescriptor prop in
 props)
          {
            foreach (DataRow o in _tableData)
            {
              writer.Write(prop.DisplayName + ": " + o[count]);
            }
            writer.WriteBreak();
            writer.WriteLine();
            count = count + 1;
          }
        }
        else
        {
          writer.Write("No data");
        }
      }
      else
      {
        writer.Write("Not connected");
      }
    }
    [ConnectionConsumer("Table")]
    public void SetConnectionInterface(IWebPartTable
 provider)
    {
      _provider = provider;
    }

    public class TableConsumerConnectionPoint
 : ConsumerConnectionPoint
    {
      public TableConsumerConnectionPoint(MethodInfo callbackMethod,
 Type interfaceType, Type controlType,
      string name, string id, bool
 allowsMultipleConnections)
        : base(
        callbackMethod, interfaceType, controlType,
        name, id, allowsMultipleConnections)
      {
      }
    }
  }
}

コード例2 番目の部分は、静的 Web パーツ接続カスタム コントロールホストする Web ページです。ページの一番上には、カスタム コントロールプレフィックス名前空間宣言する Register ディレクティブあります接続<asp:webpartconnection> 要素使用して宣言されプロバイダ コントロールコンシューマ コントロール<asp:webpartzone> 要素内で宣言されます。

<%@ page language="C#" %>
<%@ register tagprefix="aspSample" 
    namespace="Samples.AspNet.CS.Controls" %>

<html>
<head runat="server">
    <title>IField Test Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:webpartmanager id="WebPartManager1" runat="server">
            <StaticConnections>
                <asp:WebPartConnection id=wp1 ProviderID=provider1 ConsumerID=consumer1>
                </asp:WebPartConnection>
            </StaticConnections>
        </asp:webpartmanager>
        <asp:webpartzone id="WebPartZone1" runat="server">
          <zoneTemplate>
            <aspSample:TableProviderWebPart ID=provider1 runat=Server 
              title="Web Parts Table Provider Control" />
            <aspSample:TableConsumer ID=consumer1 runat=Server 
              title="Web Parts Table Consumer Control"/>
          </zoneTemplate>
        </asp:webpartzone>
    </div>
    </form>
</body>
</html>

ブラウザページ読み込みます。コントロール間の接続が既に存在し接続ページ内で静的接続として宣言されているため、コンシューマプロバイダからのデータ表示します

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ProviderConnectionPoint クラス
ProviderConnectionPoint メンバ
System.Web.UI.WebControls.WebParts 名前空間
GetProviderConnectionPoints
その他の技術情報
ASP.NET Web パーツ ページ



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ProviderConnectionPoint コンストラクタ」の関連用語

ProviderConnectionPoint コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ProviderConnectionPoint コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS