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

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > 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 名前空間



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

辞書ショートカット

すべての辞書の索引

「WebPartTransformerAttribute クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS