WebPartTransformerAttributeとは? わかりやすく解説

WebPartTransformerAttribute クラス

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

トランスフォーマがサポートするコネクション ポイントの型を識別します。

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

<AttributeUsageAttribute(AttributeTargets.Class)> _
Public NotInheritable Class
 WebPartTransformerAttribute
    Inherits Attribute
Dim instance As WebPartTransformerAttribute
[AttributeUsageAttribute(AttributeTargets.Class)] 
public sealed class WebPartTransformerAttribute
 : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] 
public ref class WebPartTransformerAttribute
 sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class) */ 
public final class WebPartTransformerAttribute
 extends Attribute
AttributeUsageAttribute(AttributeTargets.Class) 
public final class WebPartTransformerAttribute
 extends Attribute
解説解説

トランスフォーマは、互換性のないコネクション ポイントを持つ 2 つの Web パーツ コントロール間でのデータ変換に使用されます。コネクション ポイントが異なるインターフェイスを通じてデータを提供または利用する場合、それらのコネクション ポイントの間に互換性はありません。たとえば、IWebPartRow 型のプロバイダ コネクション ポイントを実装しているプロバイダは、IWebPartTable 型のプロバイダ コネクション ポイントを要求するコンシューマに直接接続できません。代わりに、トランスフォーマを使用して 2 つのコネクション ポイントを接続する必要があります。WebPartTransformer クラスからクラスを派生させることにより、カスタマイズされたトランスフォーマを作成できます。

WebPartTransformerAttribute 属性は、WebPartTransformer クラスに適用されます。これは、トランスフォーマがサポートするプロバイダ コネクション ポイントの型とコンシューマ接続ポイントの型を定義します。コンシューマ Web パーツ コントロールとプロバイダ Web パーツ コントロールの間の接続を確立するためには、トランスフォーマがサポートするコンシューマ接続ポイントとプロバイダ コネクション ポイントの型が、これらのコントロールのコネクション ポイントと一致している必要があります。実行時には、特定のトランスフォーマがサポートするコネクション ポイントの型を、GetConsumerType メソッドおよび GetProviderType メソッドによって取得できます。

使用例使用例

カスタマイズされた WebPartTransformer クラスへの WebPartTransformerAttribute 属性の使用方法を示すコード例を次に示します。この属性は、RowToStringTransformer クラスが IWebPartRow 型のプロバイダ コネクション ポイントを IString 型のコンシューマ接続ポイントに変換できることを示します。

このコード例は WebPartTransformer クラスの概要で取り上げているコード例の一部分です。

' A transformer that transforms a row to a string.
<AspNetHostingPermission(SecurityAction.Demand, _
   Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
   Level:=AspNetHostingPermissionLevel.Minimal)> _
<WebPartTransformer(GetType(IWebPartRow), GetType(IString))>
 _
Public Class RowToStringTransformer
    Inherits WebPartTransformer
    Implements IString

    Private _provider As IWebPartRow
    Private _callback As StringCallback

    Private Sub GetRowData(ByVal
 rowData As Object)
        Dim props As PropertyDescriptorCollection
 = _provider.Schema

        If ((Not (props Is
 Nothing)) AndAlso (props.Count > 0) _
          AndAlso (Not (rowData Is
 Nothing))) Then
            Dim returnValue As String
 = String.Empty
            For Each prop As
 PropertyDescriptor In props
                If Not (prop Is
 props(0)) Then
                    returnValue += ", "
                End If
                returnValue += prop.DisplayName.ToString() + ":
 " + _
                    prop.GetValue(rowData).ToString()
            Next
            _callback(returnValue)
        Else
            _callback(Nothing)
        End If
    End Sub

    Public Overrides Function
 Transform(ByVal providerData As Object)
 As Object
        _provider = CType(providerData, IWebPartRow)
        Return Me
    End Function


    Sub GetStringValue(ByVal callback As
 StringCallback) _
       Implements IString.GetStringValue
        If (callback Is Nothing)
 Then
            Throw New ArgumentNullException("callback")
        End If

        If (Not (_provider Is
 Nothing)) Then
            _callback = callback
            _provider.GetRowData(New RowCallback(AddressOf
 GetRowData))
        Else
            callback(Nothing)
        End If
    End Sub
End Class
// A transformer that transforms a row to a string.
[AspNetHostingPermission(SecurityAction.Demand,
  Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
  Level = AspNetHostingPermissionLevel.Minimal)]
[WebPartTransformer(typeof(IWebPartRow), typeof(IString))]
public class RowToStringTransformer : WebPartTransformer,
 IString
{

    private IWebPartRow _provider;
    private StringCallback _callback;

    private void GetRowData(object rowData)
    {
        PropertyDescriptorCollection props = _provider.Schema;
        if (props != null && props.Count
 > 0 && rowData != null)
        {
            string returnValue = String.Empty;
            foreach (PropertyDescriptor prop in
 props)
            {
                if (prop != props[0])
                {
                    returnValue += ", ";
                }
                returnValue += prop.DisplayName + ": " + prop.GetValue(rowData);
            }
            _callback(returnValue);
        }
        else
        {
            _callback(null);
        }
    }
    
    public override object Transform(object providerData)
    {
        _provider = (IWebPartRow)providerData;
        return this;
    }

    void IString.GetStringValue(StringCallback callback)
    {
        if (callback == null)
        {
            throw new ArgumentNullException("callback");
        }

        if (_provider != null)
        {
            _callback = callback;
            _provider.GetRowData(new RowCallback(GetRowData));
        }
        else
        {
            callback(null);
        }
    }
}
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
   System.Attribute
    System.Web.UI.WebControls.WebParts.WebPartTransformerAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebPartTransformerAttribute メンバ
System.Web.UI.WebControls.WebParts 名前空間

WebPartTransformerAttribute コンストラクタ

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

WebPartTransformerAttribute クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    consumerType As Type, _
    providerType As Type _
)
Dim consumerType As Type
Dim providerType As Type

Dim instance As New WebPartTransformerAttribute(consumerType,
 providerType)
public WebPartTransformerAttribute (
    Type consumerType,
    Type providerType
)
public:
WebPartTransformerAttribute (
    Type^ consumerType, 
    Type^ providerType
)
public WebPartTransformerAttribute (
    Type consumerType, 
    Type providerType
)
public function WebPartTransformerAttribute
 (
    consumerType : Type, 
    providerType : Type
)

パラメータ

consumerType

コンシューマ接続ポイントでサポートされているインターフェイスの Type。

providerType

プロバイダ コネクション ポイントでサポートされているインターフェイスの Type。

例外例外
例外の種類条件

ArgumentNullException

consumerType または providerType が指定されていない。

InvalidOperationException

consumerType と providerType は等しい。

解説解説

WebPartTransformerAttribute コンストラクタは、トランスフォーマのコンシューマ接続ポイントの型とプロバイダ コネクション ポイントの型を設定します。これらの値は、それぞれ ConsumerType プロパティと ProviderType プロパティによって取得できます。

使用例使用例

カスタマイズされた WebPartTransformer クラスへの WebPartTransformerAttribute 属性の使用方法を示すコード例を次に示します。この属性は、RowToStringTransformer クラスが IWebPartRow 型のプロバイダ コネクション ポイントを IString 型のコンシューマ接続ポイントに変換できることを示します。

このコード例は WebPartTransformer クラスの概要で取り上げているコード例の一部分です。

' A transformer that transforms a row to a string.
<AspNetHostingPermission(SecurityAction.Demand, _
   Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
   Level:=AspNetHostingPermissionLevel.Minimal)> _
<WebPartTransformer(GetType(IWebPartRow), GetType(IString))>
 _
Public Class RowToStringTransformer
    Inherits WebPartTransformer
    Implements IString

    Private _provider As IWebPartRow
    Private _callback As StringCallback

    Private Sub GetRowData(ByVal
 rowData As Object)
        Dim props As PropertyDescriptorCollection
 = _provider.Schema

        If ((Not (props Is
 Nothing)) AndAlso (props.Count > 0) _
          AndAlso (Not (rowData Is
 Nothing))) Then
            Dim returnValue As String
 = String.Empty
            For Each prop As
 PropertyDescriptor In props
                If Not (prop Is
 props(0)) Then
                    returnValue += ", "
                End If
                returnValue += prop.DisplayName.ToString() + ":
 " + _
                    prop.GetValue(rowData).ToString()
            Next
            _callback(returnValue)
        Else
            _callback(Nothing)
        End If
    End Sub

    Public Overrides Function
 Transform(ByVal providerData As Object)
 As Object
        _provider = CType(providerData, IWebPartRow)
        Return Me
    End Function


    Sub GetStringValue(ByVal callback As
 StringCallback) _
       Implements IString.GetStringValue
        If (callback Is Nothing)
 Then
            Throw New ArgumentNullException("callback")
        End If

        If (Not (_provider Is
 Nothing)) Then
            _callback = callback
            _provider.GetRowData(New RowCallback(AddressOf
 GetRowData))
        Else
            callback(Nothing)
        End If
    End Sub
End Class
// A transformer that transforms a row to a string.
[AspNetHostingPermission(SecurityAction.Demand,
  Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
  Level = AspNetHostingPermissionLevel.Minimal)]
[WebPartTransformer(typeof(IWebPartRow), typeof(IString))]
public class RowToStringTransformer : WebPartTransformer,
 IString
{

    private IWebPartRow _provider;
    private StringCallback _callback;

    private void GetRowData(object rowData)
    {
        PropertyDescriptorCollection props = _provider.Schema;
        if (props != null && props.Count
 > 0 && rowData != null)
        {
            string returnValue = String.Empty;
            foreach (PropertyDescriptor prop in
 props)
            {
                if (prop != props[0])
                {
                    returnValue += ", ";
                }
                returnValue += prop.DisplayName + ": " + prop.GetValue(rowData);
            }
            _callback(returnValue);
        }
        else
        {
            _callback(null);
        }
    }
    
    public override object Transform(object providerData)
    {
        _provider = (IWebPartRow)providerData;
        return this;
    }

    void IString.GetStringValue(StringCallback callback)
    {
        if (callback == null)
        {
            throw new ArgumentNullException("callback");
        }

        if (_provider != null)
        {
            _callback = callback;
            _provider.GetRowData(new RowCallback(GetRowData));
        }
        else
        {
            callback(null);
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebPartTransformerAttribute クラス
WebPartTransformerAttribute メンバ
System.Web.UI.WebControls.WebParts 名前空間

WebPartTransformerAttribute プロパティ


WebPartTransformerAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetConsumerType コネクション ポイントでトランスフォーマが受け入れることができるコンシューマの型を返します。
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。)
パブリック メソッド GetProviderType コネクション ポイントでトランスフォーマが受け入れることができるプロバイダの型を返します。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

WebPartTransformerAttribute クラス
System.Web.UI.WebControls.WebParts 名前空間

WebPartTransformerAttribute メンバ

トランスフォーマがサポートするコネクション ポイントの型を識別します。

WebPartTransformerAttribute データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド WebPartTransformerAttribute WebPartTransformerAttribute クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetConsumerType コネクション ポイントでトランスフォーマが受け入れることができるコンシューマの型を返します。
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。)
パブリック メソッド GetProviderType コネクション ポイントでトランスフォーマが受け入れることができるプロバイダの型を返します。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

WebPartTransformerAttribute クラス
System.Web.UI.WebControls.WebParts 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「WebPartTransformerAttribute」の関連用語

WebPartTransformerAttributeのお隣キーワード
検索ランキング

   

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



WebPartTransformerAttributeのページの著作権

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

©2026 GRAS Group, Inc.RSS