当前位置: 首页>>代码示例>>C#>>正文


C# RoleType类代码示例

本文整理汇总了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;
 }
开发者ID:marouanopen,项目名称:ICT4Reals,代码行数:14,代码来源:User.cs

示例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));
 }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:7,代码来源:PaperLetter.cs

示例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;
        }
开发者ID:rickeygalloway,项目名称:Test,代码行数:31,代码来源:AuthManager.cs

示例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");
     }
 }
开发者ID:marouanopen,项目名称:ICT4RealsWebForms,代码行数:38,代码来源:User.cs

示例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);
        }
开发者ID:kcruzado,项目名称:csdotnet-rest-client-library,代码行数:31,代码来源:DocumentShareManager.cs

示例6: AddRoleSyncRoot

        private object AddRoleSyncRoot(RoleType roleType)
        {
            var roleSyncRoot = new object();

            RoleSyncRoots.Add(roleType, roleSyncRoot);

            return roleSyncRoot;
        }
开发者ID:bhaktapk,项目名称:com-prerit,代码行数:8,代码来源:RoleService.cs

示例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;
 }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:15,代码来源:BasicPersonRole.cs

示例8: ParseRoleType_ReturnsCorrectString

        public void ParseRoleType_ReturnsCorrectString(RoleType roleType, string expected)
        {
            //act
            var result = EnumFactory.ParseRoleType(roleType);

            //assert
            result.Should().Be(expected);
        }
开发者ID:letmeproperty,项目名称:Applications,代码行数:8,代码来源:EnumFactory_TestFixture.cs

示例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;
        }
开发者ID:FoundOPS,项目名称:server,代码行数:16,代码来源:AuthenticationLogic.cs

示例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);
        }
开发者ID:letmeproperty,项目名称:Applications,代码行数:8,代码来源:EnumHelper_TestFixture.cs

示例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();
    }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:58,代码来源:GeographyOfficers.aspx.cs

示例12: HasAnyRole

 public bool HasAnyRole(RoleType[] types)
 {
     foreach (var role in types)
     {
         if (HasRole(role))
             return true;
     }
     return false;
 }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:9,代码来源:Login.cs

示例13: Create

		public virtual ViewResult Create(RoleType roleType)
		{
			if(roleType != RoleType.Admin && roleType != RoleType.Broker && roleType != RoleType.Manager)
			{
				throw new NotSupportedException();
			}

			return View();
		}
开发者ID:UHgEHEP,项目名称:test,代码行数:9,代码来源:UserController.cs

示例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();
     }
 }
开发者ID:pabloperfalc,项目名称:TallerDiseno,代码行数:9,代码来源:RoleDataAccess.cs

示例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));
        }
开发者ID:bhaktapk,项目名称:com-prerit,代码行数:9,代码来源:IPrincipalExtensions.cs


注:本文中的RoleType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。