Example #1
0
 public static string ToDescriptionString(this RoleType val)
 {
     DescriptionAttribute[] attributes = (DescriptionAttribute[])val
                                         .GetType()
                                         .GetField(val.ToString())
                                         .GetCustomAttributes(typeof(DescriptionAttribute), false);
     return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
 }
    public Column AddRole(RoleType role)
    {
        int col = firstcol; //first role column

        RoleSortKey newKey = new RoleSortKey(role);

        foreach (RoleSortKey t in Roles.Keys)
        {
            if (t.CompareTo(newKey) == 1)
            {
                if (col - firstcol < Roles.Count)
                {
                    this.InsertColumnAt(col);
                }
                break;
            }
            ++col;
        }

        Column newColumn = this.Columns[col];

        Roles.Add(newKey, newColumn);

        if (col > firstcol)
        {
            this[0, firstcol].JoinCell(CellJoinDirection.RIGHT);
        }
        else
        {
            this[0, firstcol].AddClass("topLock").AddClass("gridCell").AddClass("rolecell");
        }

        string[] name = SplitInWords(Enum.GetName(role.GetType(), role));

        newColumn[1].Cell.InnerHtml = name[0];
        name[0] = "";
        newColumn[2].Cell.InnerHtml            = (string.Join("<br />", name) + "       ").Substring(6).Trim();
        newColumn[2].Cell.Attributes["roleID"] = ((int)role).ToString();
        newColumn[2].Cell.ID = "R" + ((int)role).ToString();
        //CellAdressableCell c = this._Cells[3, col];
        //string cbName = "cb_" + ((int)role).ToString() + "_all";
        //c.Cell.InnerHtml = "<input type='checkbox' id='" + cbName + "' name='cbRoleAll' class='cb' value='" + cbName + "' ";
        //c.Cell.InnerHtml += " onclick='cbRoleClick(this," + ((int)role).ToString() + ")'";

        //c.Cell.InnerHtml += " >";
        //c.AddClass("rolecell");



        return(newColumn);
    }
Example #3
0
        public static string GetText(this RoleType roleType)
        {
            Type type = roleType.GetType();

            MemberInfo[] memInfo = type.GetMember(roleType.ToString());

            if (memInfo != null && memInfo.Length > 0)
            {
                object[] attrs = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);

                if (attrs != null && attrs.Length > 0)
                {
                    return(((DescriptionAttribute)attrs[0]).Description);
                }
            }

            return(roleType.ToString());
        }