Share via


PropertyDataTypeCollection - Classe

Représente une collection d'objets de PropertyDataType .

Hiérarchie d’héritage

System.Object
  Microsoft.Office.Server.UserProfiles.PropertyDataTypeCollection

Espace de noms :  Microsoft.Office.Server.UserProfiles
Assembly :  Microsoft.Office.Server.UserProfiles (dans Microsoft.Office.Server.UserProfiles.dll)

Syntaxe

'Déclaration
<SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel := True)> _
Public NotInheritable Class PropertyDataTypeCollection _
    Implements ICollection, IEnumerable
'Utilisation
Dim instance As PropertyDataTypeCollection
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel = true)]
public sealed class PropertyDataTypeCollection : ICollection, 
    IEnumerable

Remarques

L'objet PropertyDataTypeCollection est dans le contexte de site et stocke les types de données de propriété pris en charge dans la base de données de profil utilisateur pour un site spécifique.

Exemples

L'exemple de code suivant illustre l'utilisation de la classe PropertyDataTypeCollection .

static public void PropertyTypeAndMappingSample()
{
 
  using (SPSite site = new SPSite("site url"))
  {
    SPServiceContext context = SPServiceContext.GetContext(site);
//Initialize user profile config manager object.
    UserProfileConfigManager upcm = new UserProfileConfigManager(context);
    ConnectionManager cm = upcm.ConnectionManager;
 
//Sample to get a property type.
    PropertyDataTypeCollection pdtc = upcm.GetPropertyDataTypes();
    PropertyDataType ptype = null;
 
    foreach (PropertyDataType datatype in pdtc)
    {
      if (datatype.Name.Equals("string"))
      {
        ptype = datatype;
        break;
      }
    }
 
//Sample to create a new custom property.
    ProfilePropertyManager ppm = upcm.ProfilePropertyManager;
    CorePropertyManager cpm = ppm.GetCoreProperties();
    ProfileTypePropertyManager ptpm = ppm.GetProfileTypeProperties(ProfileType.User);
    ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
    ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
    ProfileSubtypePropertyManager pspm = ps.Properties;
 
    CoreProperty coreProp = cpm.Create(false);
    coreProp.Name = "division";
    coreProp.DisplayName = "my custom division";
    coreProp.Type = ptype.Name;
    coreProp.Length = ptype.MaxCharCount;
    coreProp.Commit();
    ProfileTypeProperty profileTypeProp = ptpm.Create(coreProp);
    profileTypeProp.IsVisibleOnEditor = true;
    profileTypeProp.IsVisibleOnViewer = true;
    profileTypeProp.Commit();
    ProfileSubtypeProperty profileSubTypeProp = pspm.Create(profileTypeProp);
    profileSubTypeProp.DefaultPrivacy = Privacy.Private;
    profileSubTypeProp.IsUserEditable = true;
    profileSubTypeProp.Commit();
    pspm.SetDisplayOrderByPropertyName(profileSubTypeProp.Name, 1);
    pspm.CommitDisplayOrder();
 
//Edit property sample.
    CoreProperty ptitle = cpm.GetPropertyByName(PropertyConstants.Title);
// Or get property by URI.
    ptitle = cpm.GetPropertyByURI(Property.URI_Title);
    ptitle.DisplayName = "Designation";
    ptitle.Commit();
//Property map sample.
    string connectionName = "Test Connection";
    Connection connection = cm[connectionName];
    PropertyMapCollection pmc = connection.PropertyMapping;
    pmc.AddNewMapping(ProfileType.User, profileSubTypeProp.Name, "division");
 
//Remove property sample.
    cpm.RemovePropertyByName("division");
    ptpm.RemovePropertyByName("division");
    pspm.RemovePropertyByName("division");
  }
}

Cohérence de thread

Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.

Voir aussi

Référence

PropertyDataTypeCollection - Membres

Microsoft.Office.Server.UserProfiles - Espace de noms