本文整理汇总了C#中IImmutableSet.DefaultIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# IImmutableSet.DefaultIfNull方法的具体用法?C# IImmutableSet.DefaultIfNull怎么用?C# IImmutableSet.DefaultIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IImmutableSet
的用法示例。
在下文中一共展示了IImmutableSet.DefaultIfNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Role
public Role(int id, string name, string description, IImmutableSet<IRight> rights = null, PermissionsSource source = PermissionsSource.Manual)
{
this.Id = id;
this.Name = name;
this.Description = description;
this.Rights = rights.DefaultIfNull();
this.Source = source;
}
示例2: Permissions
public Permissions(IImmutableSet<IRole> requiredRoles = null,
IImmutableSet<IRole> restrictedRoles = null,
IImmutableSet<IRight> requiredRights = null,
IImmutableSet<IRight> restrictedRights = null,
PermissionsSource source = PermissionsSource.Manual)
{
this.RequiredRoles = requiredRoles.DefaultIfNull();
this.RestrictedRoles = restrictedRoles.DefaultIfNull();
this.RequiredRights = requiredRights.DefaultIfNull();
this.RestrictedRights = restrictedRights.DefaultIfNull();
this.Source = source;
}
示例3: Identity
/// <summary>
/// Creates a new instance of the <see cref="Identity"/> class
/// </summary>
/// <param name="name">The name of this identity</param>
/// <param name="permittedRoles">The permitted roles</param>
/// <param name="deniedRoles">The denied roles</param>
/// <param name="permittedRights">The permitted rights</param>
/// <param name="deniedRights">The denied rights</param>
public Identity(string name,
IImmutableSet<IRole> permittedRoles = null,
IImmutableSet<IRole> deniedRoles = null,
IImmutableSet<IRight> permittedRights = null,
IImmutableSet<IRight> deniedRights = null)
{
this.Name = name;
this.PermittedRoles = permittedRoles.DefaultIfNull();
this.DeniedRoles = deniedRoles.DefaultIfNull();
this.PermittedRights = permittedRights.DefaultIfNull();
this.DeniedRights = deniedRights.DefaultIfNull();
}
示例4: ConsolidateRights
private IImmutableSet<IRight> ConsolidateRights(IImmutableSet<IRight> rights, IImmutableSet<IRole> roles)
{
if (roles == null)
return rights;
foreach (var role in roles)
{
rights = rights.Merge(role.Rights);
}
return rights.DefaultIfNull();
}