public void Merge(IAuthenticationInfo other)
{
if (other == null || other.Principals == null || other.Principals.Count == 0)
{
return;
}
if (Principals == null)
{
Principals = other.Principals;
}
else
{
if (!(Principals is IMutablePrincipalCollection))
{
Principals = new SimplePrincipalCollection(Principals);
}
((IMutablePrincipalCollection) Principals).AddAll(other.Principals);
}
if (other.Credentials == null)
{
return;
}
if (Credentials == null)
{
Credentials = other.Credentials;
return;
}
ISet<object> credentials;
if (Credentials is ISet<object>)
{
credentials = (ISet<object>) Credentials;
}
else
{
Credentials = credentials = new HashSet<object>();
}
if (other.Credentials is IEnumerable)
{
var enumerable = (IEnumerable) other.Credentials;
credentials.UnionWith(enumerable.Cast<object>());
}
else
{
credentials.Add(other.Credentials);
}
}