38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
namespace ln.identities
|
|
{
|
|
public class AssignedRoles : IEnumerable<AssignedRole>
|
|
{
|
|
IIdentityProvider identityProvider;
|
|
public IIdentityProvider IdentityProvider => identityProvider;
|
|
|
|
Dictionary<Guid, AssignedRole> assignedRoles = new Dictionary<Guid, AssignedRole>();
|
|
|
|
public AssignedRoles(IIdentityProvider identityProvider)
|
|
{
|
|
this.identityProvider = identityProvider;
|
|
}
|
|
|
|
public AssignedRole this[Identity identity]
|
|
{
|
|
get
|
|
{
|
|
if (!assignedRoles.ContainsKey(identity.UniqueID))
|
|
{
|
|
assignedRoles.Add(identity.UniqueID, new AssignedRole(identityProvider, identity));
|
|
}
|
|
return assignedRoles[identity.UniqueID];
|
|
}
|
|
}
|
|
|
|
public IEnumerator<AssignedRole> GetEnumerator()
|
|
{
|
|
return assignedRoles.Values.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
}
|
|
}
|