This topic has not yet been rated - Rate this topic

PeopleEditorEntityDataKeys Class

Represents keys that can be used as indexers against the PickerEntity.EntityDataHashTable object to expose picker information.

System.Object
  Microsoft.SharePoint.WebControls.PeopleEditorEntityDataKeys

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
public static class PeopleEditorEntityDataKeys

Using PeopleEditorEntityDataKeys enables the PickerEntity.EntityDataHashTable to be indexed against without using string literals.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
PeopleEditorEntityDataKeys
Description

The Microsoft.SharePoint.WebControls.PeopleEditorEntityDataKeys represents a reusable module that helps surface conventional people information, heavily represented when exposing data from a Microsoft.SharePoint.WebControls.PickerEntity object. The class is significant since the Microsoft.SharePoint.WebControls.PeopleEditor+PeopleInfo structure is marked as internal. This limitation implies that the PeopleEditor+PeopleInfo structure is inaccessible externally due to its protection level. However, using PeopleEditorEntityDataKeys allows the PickerEntity.EntityDataHashTable to be indexed against without reverting to utilization of string literals. 

There are 7 fields that are exposed by the PeopleEditorEntityDataKeys class:

PeopleEditorEntityDataKeys.Department – Mapped to the PeopleEditor.PeopleInfo.Department property

PeopleEditorEntityDataKeys.DisplayName – Mapped to the PeopleEditor.PeopleInfo.DisplayName property

PeopleEditorEntityDataKeys.Email – Mapped to the PeopleEditor.PeopleInfo.Email property

PeopleEditorEntityDataKeys.PrincipalType – Mapped to the PeopleEditor.PeopleInfo.PrincipalType property

PeopleEditorEntityDataKeys.SharePointGroupId -- Mapped to the PeopleEditor.PeopleInfo.SPGroupId property

PeopleEditorEntityDataKeys.SIPAddress -- Mapped to the PeopleEditor.PeopleInfo.SIPAddress property

PeopleEditorEntityDataKeys.UserId – Mapped to the PeopleEditor.PeopleInfo.SPUserId property

The Usage Scenario

The primary usage of the PeopleEditorEntityDataKeys class is as an indexer against the PickerEntity.EntityDataHashTable to expose diverse picker information, often for the manufacture of new objects.

In the below, I am demonstrating having global PeopleEditor object, and how the PeopleEditor.ResolvedEntitiesArrayList can be used in order to construct new SPUserInfo objects. Specifically, the SPUserInfo.Name property is being set by leveraging PeopleEditorEntityDataKeys.DisplayName.

C# Code Example 

private PeopleEditor peopleEditor;
private SPUserInfo ReturnUserInfo()
{
ArrayList resolvedEntities = peopleEditor.ResolvedEntities;
var entity = (PickerEntity)resolvedEntities[0];
var info = new SPUserInfo
{
LoginName = entity.Key,
Name = ((string)entity.EntityData[PeopleEditorEntityDataKeys.DisplayName])
};
return info;
}

Visual Basic .NET Code Example

Private peopleEditor As PeopleEditor
Private Function ReturnUserInfo() As SPUserInfo
Dim resolvedEntities As ArrayList = peopleEditor.ResolvedEntities
Dim entity As var = DirectCast(resolvedEntities(0), PickerEntity)
Dim info As var
LoginName = entity.Key
End Function

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com