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


C# Role类代码示例

本文整理汇总了C#中Role的典型用法代码示例。如果您正苦于以下问题:C# Role类的具体用法?C# Role怎么用?C# Role使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Role类属于命名空间,在下文中一共展示了Role类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _Setup

 private void _Setup()
 {
     Role role1 = new Role("Role1");
     Role role2 = new Role("Role2");
     Role role3 = new Role("Role3");
     _roles = new List<Role> {role1, role2, role3};
 }
开发者ID:Skookum,项目名称:Hero,代码行数:7,代码来源:RoleControllerTests.cs

示例2: AddPerson

        public bool AddPerson(PersonModel person, Role role, string password)
        {
            if (person.Email == "")
                return false;

            return true;
        }
开发者ID:maglunde,项目名称:Tankshop,代码行数:7,代码来源:AccountRepoStub.cs

示例3: RoleIndexModel

        public RoleIndexModel(Role role)
        {
            this.Role = role;

            IFunctionRepository repository = RepositoryFactory.GetRepository<IFunctionRepository, Function>();

            IRoleRepository rolerepository = RepositoryFactory.GetRepository<IRoleRepository, Role>();

            if (this.Role == null)
                return;

            this.AssignedFunctions = repository.FindByRole(this.Role).ToHashSet();

            //找到父功能的权限

            this.Role.Parent = rolerepository.FindParent(this.Role);

            if (this.Role.Parent == null)
            {
                this.UnAssignedFuncitons = repository.FindAll().ToHashSet().Except(this.AssignedFunctions).ToHashSet();
            }
            else
            {
                this.UnAssignedFuncitons = repository.FindByRole(this.Role.Parent).ToHashSet().Except(this.AssignedFunctions).ToHashSet();
            }
        }
开发者ID:dalinhuang,项目名称:cy-pdcpms,代码行数:26,代码来源:RoleIndexModel.cs

示例4: clone

        public static Anysim clone(Role toClone, SimDescription actor)
        {
            Anysim newRole = new Anysim(toClone.Data, actor, toClone.RoleGivingObject);
            newRole.StartRole();

            return newRole;
        }
开发者ID:markmanching,项目名称:virtual-artisan-s3mods,代码行数:7,代码来源:Anysim.cs

示例5: Add

    void Add(HttpContext context)
    {
        context.Response.ContentType = "application/json";
        string name = context.Request["text"];
        string msg = string.Empty;
        if (!string.IsNullOrWhiteSpace(name)) {
            try {
                Guid id= System.Guid.NewGuid() ;
                IList<Module> modules = RepositoryFactory<Modules>.Get().GetAll();
                var query = from p in modules
                            select new Right { ModuleId = p.Id , Permission = 0 , RoleId = id };

                Role obj = new Role { Id =id, Name = context.Server.UrlDecode(name),Rights=query.ToList() };
                RepositoryFactory<RolesRepository>.Get().Add(obj);
                context.Response.Write("{\"id\":\"" + obj.Id.ToString() + "\"}");

                AppLog.Write("创建角色", AppLog.LogMessageType.Info,"name="+obj.Name,this.GetType());
            } catch (Exception ex) {

                AppLog.Write("创建角色 出错" , AppLog.LogMessageType.Error , "name=" + name , ex , this.GetType());

                msg = ex.Message;
            }
        } else {
            msg = "角色名不能为空";
        }
        if (!string.IsNullOrWhiteSpace(msg)) {
            context.Response.Write("{\"msg\":\""+msg+"\"}");
        }
    }
开发者ID:HuGuo,项目名称:TSS,代码行数:30,代码来源:RoleHandler.cs

示例6: SaveToDB

 public void SaveToDB(int matchNo, DateTime matchDay, Location location, Role role, MatchDayShort matchDayShort, char matchType, int round, string row, DrivingInfo drivingInfo, Team homeTeam, Team awayTeam)
 {
     using (var conn = new MySqlConnection(ConnectionString))
     {
         conn.Open();
         var locationId = GetLocationId(location);
         var homeTeamId = GetTeamId(homeTeam);
         var awayTeamId = GetTeamId(awayTeam);
         var cmd = new MySqlCommand(
             "INSERT INTO DbuGrabber_Game " +
             "(GameNo, Round, GameDayShort, GameDay, Row, LocationId, HomeTeamId, AwayTeamId, Role, DrivingHours, DrivingMinutes, MatchType) " +
             "VALUES " +
             "(@GameNo, @Round, @GameDayShort, @GameDay, @Row, @LocationId, @HomeTeamId, @AwayTeamId, @Role, @DrivingHours, @DrivingMinutes, @MatchType)" +
             " ON DUPLICATE KEY UPDATE Round = @Round, GameDayShort = @GameDayShort, GameDay = @GameDay, Row = @Row, LocationId = @LocationId, HomeTeamId= @HomeTeamId, AwayTeamId = @AwayTeamId, Role = @Role, DrivingHours = CASE WHEN (DrivingHours <> @DrivingHours) THEN @DrivingHours ELSE DrivingHours END, DrivingMinutes = CASE WHEN (DrivingMinutes <> @DrivingMinutes) THEN @DrivingMinutes ELSE DrivingMinutes END, MatchType= @MatchType, Sent = CASE WHEN (DrivingHours <> @DrivingHours OR DrivingMinutes <> @DrivingMinutes) THEN 0 ELSE Sent END", conn);
         cmd.Parameters.AddWithValue("@GameNo", matchNo);
         cmd.Parameters.AddWithValue("@Round", round);
         cmd.Parameters.AddWithValue("@GameDayShort", matchDayShort.ToString());
         cmd.Parameters.AddWithValue("@GameDay", matchDay);
         cmd.Parameters.AddWithValue("@Row", row);
         cmd.Parameters.AddWithValue("@LocationId", locationId);
         cmd.Parameters.AddWithValue("@HomeTeamId", homeTeamId);
         cmd.Parameters.AddWithValue("@AwayTeamId", awayTeamId);
         cmd.Parameters.AddWithValue("@Role", role.ToString());
         cmd.Parameters.AddWithValue("@DrivingHours", drivingInfo.Hours);
         cmd.Parameters.AddWithValue("@DrivingMinutes", drivingInfo.Minutes);
         cmd.Parameters.AddWithValue("@MatchType", matchType);
         cmd.ExecuteNonQuery();
     }
 }
开发者ID:woodbase,项目名称:Woodbase.RefereeToolkit,代码行数:29,代码来源:MySqlConnector.cs

示例7: Given_all_required_fields_are_available_Then_create_user_method_creates_an_object

        public void Given_all_required_fields_are_available_Then_create_user_method_creates_an_object()
        {
            //Given
            Guid userId = Guid.NewGuid();
            const long companyId = 33749;
            const long siteId = 324234L;
            var role = new Role() { Id = new Guid("BACF7C01-D210-4DBC-942F-15D8456D3B92") };
            var user = new UserForAuditing() { Id = new Guid("B03C83EE-39F2-4F88-B4C4-7C276B1AAD99") };
            var site = new Site() {Id = siteId};
            var employeeContactDetail = new EmployeeContactDetail {Email = "[email protected]"};
            var employee = new Employee {Forename = "Gary", Surname = "Green",ContactDetails = new List<EmployeeContactDetail> {employeeContactDetail}};

            //When
            var result = User.CreateUser(userId, companyId, role, site, employee, user);

            //Then
            Assert.That(result.Id, Is.EqualTo(userId));
            Assert.That(result.CompanyId, Is.EqualTo(companyId));
            Assert.That(result.Site.Id, Is.EqualTo(siteId));
            Assert.That(result.Employee, Is.Not.Null);
            Assert.That(result.Employee.Forename, Is.EqualTo("Gary"));
            Assert.That(result.Employee.Surname, Is.EqualTo("Green"));
            Assert.That(result.Employee.ContactDetails, Is.Not.Null);
            Assert.That(result.Employee.ContactDetails.Count, Is.EqualTo(1));
            Assert.That(result.Employee.ContactDetails[0].Email, Is.EqualTo("[email protected]"));
        }
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:26,代码来源:RegisterAdminTests.cs

示例8: btnUpdate_Click

    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string loginID = "1";
        try
        {
            if (Session["Login"] == null) { Session["PreviousPage"] = HttpContext.Current.Request.Url.AbsoluteUri; Response.Redirect("../LoginPage.aspx"); }
            loginID = ((Login)Session["Login"]).LoginID.ToString();
        }
        catch (Exception ex)
        { }

        Role role = new Role();
        role = RoleManager.GetRoleByID(Int32.Parse(Request.QueryString["roleID"]));
        Role tempRole = new Role();
        tempRole.RoleID = role.RoleID;

        tempRole.RoleName = txtRoleName.Text;
        tempRole.RoleDescription = txtRoleDescription.Text;
        tempRole.AddedDate = DateTime.Now;
        tempRole.AddedBy = loginID;
        tempRole.ModifyDate = DateTime.Now;
        tempRole.ModifyBy = loginID;
        tempRole.RowStatusID = Int32.Parse(ddlRowStatus.SelectedValue);
        bool result = RoleManager.UpdateRole(tempRole);
        Response.Redirect("AdminRoleDisplay.aspx");
    }
开发者ID:anam,项目名称:gp-HO,代码行数:26,代码来源:AdminRoleInsertUpdate.aspx.cs

示例9: Get

        public static IUser Get(Command cmd, string id, Role role)
        {
            string table = null;
            string columns = null;
            switch (role)
            {
                case Role.Administrator:
                    table = Administrator.Table;
                    columns = string.Join(",", Administrator.Properties.Select(p => p.Name).ToArray());
                    break;
                case Role.Teacher:
                    table = Teacher.Table;
                    columns = string.Join(",", Teacher.Properties.Select(p => p.Name).ToArray());
                    break;
                case Role.Student:
                    table = Student.Table;
                    columns = string.Join(",", Student.Properties.Select(p => p.Name).ToArray());
                    break;
            }
            string sql = string.Format(@"select {0} from {1} where lower(Id)=lower(@Id)", columns, table);
            cmd.CommandText = sql;
            cmd.AddParameter("@Id", id);
            SqlCeDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                IUser user = ReaderFactory.Reader(reader, role.ToEntity()) as IUser;
                reader.Close();
                return user;
            }
            reader.Close();
            return null;
        }
开发者ID:baikangwang,项目名称:April,代码行数:33,代码来源:UserGateway.cs

示例10: TcpipClient

 public TcpipClient(string host, int port, Role? requestRole)
 {
     this.host = host;
     this.port = port;
     this.RequestRole = requestRole;
     Running = false;
 }
开发者ID:AIWolfSharp,项目名称:AIWolfSharp,代码行数:7,代码来源:TcpipClient.cs

示例11: LoginWindow

 public LoginWindow(Role[] roles, ApplicationManager appMgr)
 {
     InitializeComponent();
     this.appMgr = appMgr;
     this.authRoles = roles;
     this.isRoleAuth = true;
 }
开发者ID:hubasky,项目名称:oe-nik-softtech2-private-hospital,代码行数:7,代码来源:LoginWindow.xaml.cs

示例12: User

 public User(string username, string password, Role role)
 {
     this.Username = username;
     this.PasswordHash = password;
     this.Role = role;
     this.Bookings = new List<Booking>();
 }
开发者ID:LyuboslavLyubenov,项目名称:High-quality-Code,代码行数:7,代码来源:User.cs

示例13: AddRole

        /// <summary>
        /// Add Role in database
        /// </summary>
        /// <param name="pRole"></param>
        /// <returns>Role id</returns>
        public int AddRole(Role pRole)
        {
            const string q = @"INSERT INTO [Roles]
                                     ([deleted], [code], [description], [role_of_loan], [role_of_saving], [role_of_teller])
                                     VALUES(@deleted, @code, @description, @role_of_loan, @role_of_saving, @role_of_teller)
                                     SELECT SCOPE_IDENTITY()";

            using (SqlConnection conn = GetConnection())
            {
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                {
                    c.AddParam("@deleted", false);
                    c.AddParam("@code", pRole.RoleName);
                    c.AddParam("@description", pRole.Description);
                    c.AddParam("@role_of_loan", pRole.IsRoleForLoan);
                    c.AddParam("@role_of_saving", pRole.IsRoleForSaving);
                    c.AddParam("@role_of_teller", pRole.IsRoleForTeller);

                    pRole.Id = int.Parse(c.ExecuteScalar().ToString());
                    SaveRoleMenu(pRole);
                    SaveAllowedActionsForRole(pRole);
                }
            }
            return pRole.Id;
        }
开发者ID:TalasZh,项目名称:opencbs,代码行数:30,代码来源:RoleManager.cs

示例14: Validate

        public static Boolean Validate(String Token, Role pRole)
        {
            if (Role.ALL == pRole) {
                return true;
            }

            var boolResult = false;

            try {
                using(var sessionManagerDal = new SessionManagerDAL(Util.GetConnection())) {
                    var lstObjSessionManager = sessionManagerDal.SessionManagerDAL_ById(Token).ToList();
                    if (lstObjSessionManager.Count() == 1) {
                        switch ((Role)lstObjSessionManager[0].UserRole) {
                            case Role.ADMIN: case Role.CLIENT:
                                    boolResult = true;
                                break;
                            case Role.NONE:
                                boolResult = false;
                                break;
                            default:
                                throw new Exception("Not accessible, unknow userRole");
                        }
                    }
                }
            } catch (Exception ex) {
                throw;
            }

            return boolResult;
        }
开发者ID:rsilvestre,项目名称:WebserviceLibraryManager,代码行数:30,代码来源:Autorization.cs

示例15: AddRole

        public void AddRole(Role role)
        {
            if (RoleExists(role))
                throw new ArgumentException(TooManyRole);

            entities.Roles.Add(role);
        }
开发者ID:hasanIqbalAnik,项目名称:store-survey,代码行数:7,代码来源:StoreSurveyRepository.cs


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