Ejemplo n.º 1
0
        private PermissionItem LoadPermissionItem(XElement xe)
        {
            PermissionItem re = new PermissionItem();

            if (xe.Attribute("Name") != null)
            {
                re.Name = xe.Attribute("Name").Value;
            }
            if (xe.Attribute("Desc") != null)
            {
                re.Desc = xe.Attribute("Desc").Value;
            }
            if (xe.Attribute("EnableWrite") != null)
            {
                re.EnableWrite = bool.Parse(xe.Attribute("EnableWrite").Value);
            }
            if (xe.Attribute("SuperPermission") != null)
            {
                re.SuperPermission = bool.Parse(xe.Attribute("SuperPermission").Value);
            }
            if (xe.Attribute("Group") != null)
            {
                re.Group = xe.Attribute("Group").Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            }
            return(re);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="permission"></param>
 public void Add(PermissionItem permission)
 {
     if (!Permissions.ContainsKey(permission.Name))
     {
         Permissions.Add(permission.Name, permission);
     }
 }
Ejemplo n.º 3
0
        public PermissionDocument()
        {
            var superPermission = new PermissionItem()
            {
                Name = "Super", SuperPermission = true, EnableWrite = true, Desc = "Super Permission"
            };

            Permissions.Add(superPermission.Name, superPermission);
        }
Ejemplo n.º 4
0
        private XElement Save(PermissionItem permission)
        {
            XElement re = new XElement("PermissionItem");

            re.SetAttributeValue("Name", permission.Name);
            re.SetAttributeValue("Desc", permission.Desc);
            re.SetAttributeValue("EnableWrite", permission.EnableWrite);
            re.SetAttributeValue("SuperPermission", permission.SuperPermission);
            if (permission.Group != null)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var vv in permission.Group)
                {
                    sb.Append(vv + ",");
                }
                sb.Length = sb.Length > 0 ? sb.Length - 1:sb.Length;
                re.SetAttributeValue("Group", sb.ToString());
            }
            return(re);
        }