Share via


PropertyCollection Class

Represents a collection of Property objects. Use the PropertyCollection class to enumerate all properties defined at a site.

Inheritance Hierarchy

System.Object
  Microsoft.Office.Server.UserProfiles.PropertyCollection

Namespace:  Microsoft.Office.Server.UserProfiles
Assembly:  Microsoft.Office.Server (in Microsoft.Office.Server.dll)

Syntax

'Declaration
<SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class PropertyCollection _
    Implements ICollection
'Usage
Dim instance As PropertyCollection
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class PropertyCollection : ICollection

Examples

The following code example shows the use of the PropertyCollection class.

[Visual Basic]

      Public Sub SectionSample()
         'get portal site context from topology
         Dim strUrl As String = "http://SampleName"
         Dim tm As New TopologyManager()
         Dim ps As PortalSite = tm.PortalSites(New Uri(strUrl))
         Dim pc As PortalContext = PortalApplication.GetContext(ps)

         'initialize user profile config manager object
         Dim upcm As New UserProfileConfigManager(pc)

         'sample to create a new section
         Dim pcol As PropertyCollection = upcm.GetPropertiesWithSection()
         Dim mysection As [Property] = pcol.Create(True)
         mysection.Name = "my section"
         mysection.Commit()
         pcol.SetDisplayOrderBySectionName(mysection.Name, 0)
         pcol.CommitDisplayOrder()
      End Sub 'SectionSample

[C#]

public void SectionSample()
{
//get portal site context from topology
string strUrl = "http://SampleName";
TopologyManager tm = new TopologyManager();
PortalSite ps = tm.PortalSites[new Uri(strUrl)];
PortalContext pc = PortalApplication.GetContext(ps);

//initialize user profile config manager object
UserProfileConfigManager upcm = new UserProfileConfigManager(pc);

//sample to create a new section
PropertyCollection pcol = upcm.GetPropertiesWithSection();
Property mysection = pcol.Create(true);
mysection.Name = "my section";
mysection.Commit();
pcol.SetDisplayOrderBySectionName(mysection.Name, 0);
pcol.CommitDisplayOrder();
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

PropertyCollection Members

Microsoft.Office.Server.UserProfiles Namespace