WebPartTransformerAttribute クラス
アセンブリ: System.Web (system.web.dll 内)

<AttributeUsageAttribute(AttributeTargets.Class)> _ Public NotInheritable Class WebPartTransformerAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class)] public sealed class WebPartTransformerAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] public ref class WebPartTransformerAttribute sealed : public 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); } } }


System.Attribute
System.Web.UI.WebControls.WebParts.WebPartTransformerAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からWebPartTransformerAttribute クラスを検索する場合は、下記のリンクをクリックしてください。

- WebPartTransformerAttribute クラスのページへのリンク