ProfileProviderAttribute(String) コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定したプロファイル プロバイダー名を使用して、 ProfileProviderAttribute クラスの新しいインスタンスを作成します。
public:
ProfileProviderAttribute(System::String ^ providerName);
public ProfileProviderAttribute(string providerName);
new System.Web.Profile.ProfileProviderAttribute : string -> System.Web.Profile.ProfileProviderAttribute
Public Sub New (providerName As String)
パラメーター
- providerName
- String
プロパティのプロファイル プロバイダーの名前。
例
次のコード例では、 ProfileBase クラスから継承してカスタム プロファイルを作成するクラスを定義します。 カスタム プロファイルの種類は、アプリケーションの Web.config ファイルのinherits構成要素の属性で指定されます。 カスタム プロファイルの実装を指定する構成ファイルの例については、 ProfileProviderAttribute クラスの概要を参照してください。
using System;
using System.Web.Profile;
namespace Samples.AspNet.Profile
{
public class EmployeeProfile : ProfileBase
{
[SettingsAllowAnonymous(false)]
[ProfileProvider("EmployeeInfoProvider")]
public string Department
{
get { return base["EmployeeDepartment"].ToString(); }
set { base["EmployeeDepartment"] = value; }
}
[SettingsAllowAnonymous(false)]
[ProfileProvider("EmployeeInfoProvider")]
public EmployeeInfo Details
{
get { return (EmployeeInfo)base["EmployeeInfo"]; }
set { base["EmployeeInfo"] = value; }
}
}
public class EmployeeInfo
{
public string Name;
public string Address;
public string Phone;
public string EmergencyContactName;
public string EmergencyContactAddress;
public string EmergencyContactPhone;
}
}
Imports System.Web.Profile
Namespace Samples.AspNet.Profile
Public Class EmployeeProfile
Inherits ProfileBase
<SettingsAllowAnonymous(False)> _
<ProfileProvider("EmployeeInfoProvider")> _
Public Property Department As String
Get
Return MyBase.Item("EmployeeDepartment").ToString()
End Get
Set
MyBase.Item("EmployeeDepartment") = value
End Set
End Property
<SettingsAllowAnonymous(False)> _
<ProfileProvider("EmployeeInfoProvider")> _
Public Property Details As EmployeeInfo
Get
Return CType(MyBase.Item("EmployeeInfo"), EmployeeInfo)
End Get
Set
MyBase.Item("EmployeeInfo") = value
End Set
End Property
End Class
Public Class EmployeeInfo
Public Name As String
Public Address As String
Public Phone As String
Public EmergencyContactName As String
Public EmergencyContactAddress As String
Public EmergencyContactPhone As String
End Class
End Namespace
注釈
ProfileProviderAttribute クラスは、カスタム プロファイル実装のプロパティのプロファイル プロバイダーを識別するために使用されます。 カスタム プロファイル実装は、 ProfileBase 抽象クラスから継承し、 プロファイル 構成要素で指定されていないユーザー プロファイルのプロパティを定義するクラスです。