Share via


ProfileProviderAttribute(String) コンストラクター

定義

指定したプロファイル プロバイダー名を使用して 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 継承し、 プロファイル 構成要素で指定されていないユーザー プロファイルのプロパティを定義するクラスです。

適用対象

こちらもご覧ください