ProfileProviderAttribute クラス

定義

ユーザープロファイル プロパティのプロファイル プロバイダーを識別します。

public ref class ProfileProviderAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
public sealed class ProfileProviderAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
type ProfileProviderAttribute = class
    inherit Attribute
Public NotInheritable Class ProfileProviderAttribute
Inherits Attribute
継承
ProfileProviderAttribute
属性

次のコード例では、カスタム プロファイルを作成するためにクラスから ProfileBase 継承するクラスを定義します。 カスタム プロファイルの種類は、アプリケーションのWeb.config ファイルのプロファイル構成要素の属性で指定されますinherits

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 継承し、 プロファイル 構成要素で指定されていないユーザー プロファイルのプロパティを定義するクラスです。 次の例に示すように、アプリケーションのWeb.config ファイル内のプロファイル構成要素の属性を使用して inherits 、ユーザー プロファイル のカスタムの種類を指定できます。

<configuration>  
  <connectionStrings>  
    <add name="SqlServices" connectionString=  
      "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />  
  </connectionStrings>  

  <system.web>  
    <authentication mode="Forms" >  
      <forms loginUrl="login.aspx"  
        name=".ASPXFORMSAUTH" />  
    </authentication>  

    <authorization>  
      <deny users="?" />  
    </authorization>  

    <profile inherits="Samples.AspNet.Profile.EmployeeProfile"  
      defaultProvider="SqlProvider">  
      <providers>  
        <clear />  
        <add  
          name="SqlProvider"  
          type="System.Web.Profile.SqlProfileProvider"   
          connectionStringName="SqlServices"   
          description="SQL Profile Provider for Sample"/>   
        <add  
          name="EmployeeInfoProvider"  
          type="System.Web.Profile.SqlProfileProvider"   
          connectionStringName="SqlServices"   
          description="SQL Profile Provider for Employee Info"/>   
      </providers>  

      <properties>  
        <add name="GarmentSize" />  
      </properties>  
    </profile>  
  </system.web>  
</configuration>  

コンストラクター

ProfileProviderAttribute(String)

指定したプロファイル プロバイダー名を使用して ProfileProviderAttribute クラスの新しいインスタンスを作成します。

プロパティ

ProviderName

ユーザー プロファイル プロパティのプロファイル プロバイダーの名前を取得します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください