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

consumerTypeproviderType等しい。

解説解説

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 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からWebPartTransformerAttributeを検索した結果を表示しています。
Weblioに収録されているすべての辞書からWebPartTransformerAttributeを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からWebPartTransformerAttribute を検索

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

辞書ショートカット

すべての辞書の索引

「WebPartTransformerAttribute」の関連用語

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

   

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



WebPartTransformerAttributeのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS