Пример #1
0
        public static PvpRole Parse(string roleString)
        {
            PvpRole role = new PvpRole();

            string[] parts = roleString.Split('(', ')');
            if (parts.Length > 0)
            {
                role._name = parts[0];
            }
            if (parts.Length > 2)
            {
                string[] parameters = parts[1].Split(',');
                foreach (string parameter in parameters)
                {
                    string[] keyvalue = parameter.Split('=');
                    string   key      = string.Empty;
                    string   val      = string.Empty;
                    if (keyvalue.Length > 0)
                    {
                        key = keyvalue[0];
                    }
                    if (keyvalue.Length > 1)
                    {
                        val = keyvalue[1];
                    }
                    role._parameters.Add(key, val);
                }
            }
            return(role);
        }
Пример #2
0
        public void Merge(PvpRole role)
        {
            PvpRole existingRole = GetRole(role.Name);

            if (existingRole == null)
            {
                Roles.Add(role);
            }
            else
            {
                existingRole.Merge(role.Parameters);
            }
        }
Пример #3
0
        public static PvpAuthorization Parse(string authorizationString)
        {
            string[]       roleStrings = authorizationString.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            List <PvpRole> roles       = new List <PvpRole>();

            foreach (string roleString in roleStrings)
            {
                roles.Add(PvpRole.Parse(roleString));
            }

            PvpAuthorization auth = new PvpAuthorization();

            auth._roles = roles;

            return(auth);
        }