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

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

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



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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2025 GRAS Group, Inc.RSS