本文整理汇总了C#中RoleType类的典型用法代码示例。如果您正苦于以下问题:C# RoleType类的具体用法?C# RoleType怎么用?C# RoleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RoleType类属于命名空间,在下文中一共展示了RoleType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: User
/// <summary>
/// constructor
/// </summary>
/// <param name="id">id of the user</param>
/// <param name="name">name of the user</param>
/// <param name="username">username of the user (represented by email)</param>
/// <param name="roleId">role represented by the enum</param>
public User(int id, string name, string username, int roleId)
{
this.Id = id;
this.Name = name;
this.Username = username;
Role = (RoleType)roleId;
}
示例2: Create
public static PaperLetter Create(int creatingPersonId, int organizationId, string fromName,
string[] replyAddressLines, DateTime receivedDate, int toPersonId, RoleType toPersonInRole, bool personal)
{
return FromIdentity(SwarmDb.GetDatabaseForWriting().
CreatePaperLetter(organizationId, fromName, String.Join("|", replyAddressLines),
receivedDate, toPersonId, toPersonInRole, personal, creatingPersonId));
}
示例3: AuthorizeRequest
public bool AuthorizeRequest(HttpContext httpContext, RoleType minimumRoleType)
{
try
{
// If global admin services, authentication was handled by IIS
if (ServiceContext.IsAdminServiceHost)
return HttpContext.Current.User.Identity.IsAuthenticated;
// Attempt to obtain token from request
var token = ExtractAuthorizationToken(httpContext.Request);
if (token != null)
{
// Create a user context from the token
var userContext = CreateUserContextFromToken(httpContext, token, minimumRoleType);
if (userContext != null)
{
// Add token to HTTP context for future reference
HttpContext.Current.Items.Add(CommonParameters.UserContext, userContext);
return true;
}
}
}
catch (Exception ex)
{
ServiceContext.Logger.Error("Error while authenticating user", ex);
}
return false;
}
示例4: User
/// <summary>
/// constructor
/// </summary>
/// <param name="id">id of the user</param>
/// <param name="name">name of the user</param>
/// <param name="username">username of the user (represented by email)</param>
/// <param name="roleId">role represented by the enum</param>
public User(int id, string name, string username, int roleId)
{
Allowedpages = new List<string>();
this.Id = id;
this.Name = name;
this.Username = username;
Role = (RoleType)roleId;
if (RoleId == 1)
{
Allowedpages.Add("beheer");
Allowedpages.Add("inuitrij");
Allowedpages.Add("reparatie");
Allowedpages.Add("schoonmaak");
}
if (RoleId == 2)
{
Allowedpages.Add("inuitrij");
}
if (RoleId == 3)
{
Allowedpages.Add("beheer");
}
if (RoleId == 4)
{
Allowedpages.Add("reparatie");
}
if (RoleId == 5)
{
Allowedpages.Add("schoonmaak");
}
}
示例5: ShareDocument
public DocumentShare ShareDocument(Guid dlId, Guid usId, string message = "", RoleType linkRole = RoleType.Viewer)
{
if (dlId.Equals(Guid.Empty))
{
throw new ArgumentException("dlId is required but was an empty Guid", "dlId");
}
if (usId.Equals(Guid.Empty))
{
throw new ArgumentException("dlId is required but was an empty Guid", "usId");
}
switch (linkRole)
{
case RoleType.Owner:
case RoleType.Editor:
linkRole = RoleType.Editor;
break;
default:
linkRole = RoleType.Viewer;
break;
}
dynamic postData = new ExpandoObject();
postData.users = usId;
postData.message = message;
postData.baseUrl = ShareUrl;
postData.isPublic = "true";
postData.linkRole = linkRole.ToString().ToLower();
return HttpHelper.Put<DocumentShare>(VVRestApi.GlobalConfiguration.Routes.DocumentsIdShares, "", GetUrlParts(), this.ClientSecrets, this.ApiTokens, postData, dlId, usId);
}
示例6: AddRoleSyncRoot
private object AddRoleSyncRoot(RoleType roleType)
{
var roleSyncRoot = new object();
RoleSyncRoots.Add(roleType, roleSyncRoot);
return roleSyncRoot;
}
示例7: BasicPersonRole
/// <summary>
/// Normal constructor.
/// </summary>
/// <param name="personId">The person Id.</param>
/// <param name="roleType">The node-specific role.</param>
/// <param name="organizationId">The organization Id.</param>
/// <param name="geographyId">The node Id.</param>
public BasicPersonRole (int roleId, int personId, RoleType type, int organizationId, int geographyId)
{
this.roleId = roleId;
this.personId = personId;
this.type = type;
this.organizationId = organizationId;
this.geographyId = geographyId;
}
示例8: ParseRoleType_ReturnsCorrectString
public void ParseRoleType_ReturnsCorrectString(RoleType roleType, string expected)
{
//act
var result = EnumFactory.ParseRoleType(roleType);
//assert
result.Should().Be(expected);
}
示例9: BusinessAccount
/// <summary>
/// Gets the business account for an Id.
/// It will return one entity as an IQueryable for performance.
/// Returns null if the user does not have access to the BusinessAccount.
/// </summary>
/// <param name="coreEntitiesContainer">The core entities container.</param>
/// <param name="businessAccountId">The businessAccount Id.</param>
/// <param name="allowedRoleTypes">Return null if the user does not have access to one of these role types.</param>
public static IQueryable<BusinessAccount> BusinessAccount(this CoreEntitiesContainer coreEntitiesContainer, Guid businessAccountId, RoleType[] allowedRoleTypes)
{
var ownerParty = from role in RolesCurrentUserHasAccessTo(coreEntitiesContainer, allowedRoleTypes)
where role.OwnerBusinessAccountId == businessAccountId
select role.OwnerBusinessAccount;
return ownerParty;
}
示例10: EnumHelper_Parse_ReturnsCorrectEnum
public void EnumHelper_Parse_ReturnsCorrectEnum(string value, RoleType roleType)
{
//act
var result = EnumHelper<RoleType>.Parse(value);
//assert
result.Should().Be(roleType);
}
示例11: PrintGeography
string PrintGeography (Geography geo)
{
StringBuilder sbl = new StringBuilder();
RoleType[] rolesToShow = new RoleType[] { RoleType.OrganizationChairman, RoleType.OrganizationVice1, RoleType.OrganizationSecretary, RoleType.LocalLead, RoleType.LocalDeputy };
Organizations orgs = Organizations.GetOrganizationsAvailableAtGeography(geo.Identity);
foreach (Organization org in orgs)
{
Dictionary<int, bool> listedPersons = new Dictionary<int, bool>();
if (org.IsOrInherits(Organization.UPSEid))
{
if (org.AnchorGeographyId == geo.Identity || org.UptakeGeographies.Contains(geo))
{
RoleLookup officers = RoleLookup.FromOrganization(org);
bool foundRole = false;
foreach (RoleType rt in rolesToShow)
{
foundRole |= officers[rt].Count > 0;
if (foundRole) break;
}
if (foundRole)
{
sbl.Append("<br><br><b>" + HttpUtility.HtmlEncode(org.Name) + ":</b>");
foreach (RoleType rt in rolesToShow)
foreach (Activizr.Logic.Pirates.PersonRole r in officers[rt])
{
if (!listedPersons.ContainsKey(r.PersonId))
{
sbl.Append(PrintOfficer(r));
listedPersons[r.PersonId] = true;
}
}
sbl.Append("<br>");
}
}
}
else
{
RoleLookup officers = RoleLookup.FromGeographyAndOrganization(geo, org);
if (officers[RoleType.LocalLead].Count > 0 || officers[RoleType.LocalDeputy].Count > 0)
{
sbl.Append("<br><br><b>" + HttpUtility.HtmlEncode(org.Name) + ", " + HttpUtility.HtmlEncode(geo.Name) + ":</b>");
foreach (RoleType rt in rolesToShow)
foreach (Activizr.Logic.Pirates.PersonRole r in officers[rt])
if (!listedPersons.ContainsKey(r.PersonId))
{
sbl.Append(PrintOfficer(r));
listedPersons[r.PersonId] = true;
}
sbl.Append("<br>");
}
}
}
return sbl.ToString();
}
示例12: HasAnyRole
public bool HasAnyRole(RoleType[] types)
{
foreach (var role in types)
{
if (HasRole(role))
return true;
}
return false;
}
示例13: Create
public virtual ViewResult Create(RoleType roleType)
{
if(roleType != RoleType.Admin && roleType != RoleType.Broker && roleType != RoleType.Manager)
{
throw new NotSupportedException();
}
return View();
}
示例14: GetRoleByType
public Role GetRoleByType(RoleType type)
{
using (var db = new BlogContext())
{
return (from p in db.Roles
where p.Type == type
select p).FirstOrDefault();
}
}
示例15: IsInRole
public static bool IsInRole(this IPrincipal principal, RoleType roleType)
{
if (principal == null)
{
throw new ArgumentNullException("principal");
}
return principal.IsInRole(Enum.GetName(typeof(RoleType), roleType));
}