Sdílet prostřednictvím


ProfileProviderAttribute(String) Konstruktor

Definice

Vytvoří novou instanci ProfileProviderAttribute třídy se zadaným názvem zprostředkovatele profilu.

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)

Parametry

providerName
String

Název poskytovatele profilu pro vlastnost.

Příklady

Následující příklad kódu definuje třídu, která dědí z ProfileBase třídy a vytvoří vlastní profil. Typ vlastního profilu je určen v atributu inherits konfiguračního prvku profilu v souboru Web.config pro aplikaci. Příklad konfiguračního souboru, který určuje implementaci vlastního profilu, najdete v přehledu ProfileProviderAttribute třídy.

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

Poznámky

Třída ProfileProviderAttribute slouží k identifikaci zprostředkovatele profilu pro vlastnost vlastní implementace profilu. Implementace vlastního profilu je třída, která dědí z ProfileBase abstraktní třídy a definuje vlastnosti profilu uživatele, které nejsou zadány v elementu konfigurace profilu .

Platí pro

Viz také