Esempio n. 1
0
        public static PermissionClass Parse(Lexer <PermissionTokenType> lexer, string moduleID)
        {
            PermissionClass     @class          = new PermissionClass(moduleID);
            PermissionGroup     premissionGroup = null;
            PermissionGroupType state           = PermissionGroupType.Class;

            Token <PermissionTokenType> token = lexer.GetToken();

            while (token != null)
            {
                if (token.Type == PermissionTokenType.TargetType)
                {
                    if (state == PermissionGroupType.Class)
                    {
                        @class.AddPermission(ParsePermission(lexer));
                    }
                    else if (premissionGroup != null)
                    {
                        premissionGroup.AddPermission(ParsePermission(lexer));
                    }
                }
                else if (token.Type == PermissionTokenType.Bracket)
                {
                    PermissionGroup group = ParseBracket(lexer, @class);
                    state = group.Type;

                    if (state == PermissionGroupType.Class)
                    {
                        @class.Properties = group.Properties;
                    }
                    else
                    {
                        premissionGroup = group;
                        @class.AddPermissionGroup(group);
                    }
                }
                else
                {
                    lexer.NextToken();
                }

                token = lexer.GetToken();
            }

            return(@class);
        }
Esempio n. 2
0
 public void AddPermissionGroup(PermissionGroup group)
 {
     permissonGroups.Add(group.Name, group);
 }