public bool CanViewVar(ConGroupIndex groupIndex)
        {
            if (_groups.TryGetValue(groupIndex, out var group))
            {
                return(group.CanViewVar);
            }

            _logger.Error($"Unknown groupIndex: {groupIndex}");
            return(false);
        }
        /// <summary>
        /// Tests if a console group has a command defined.
        /// </summary>
        /// <param name="groupIndex">Group to test.</param>
        /// <param name="cmdName">Name of command to test for.</param>
        /// <returns>Result of test.</returns>
        public bool HasCommand(ConGroupIndex groupIndex, string cmdName)
        {
            if (_groups.TryGetValue(groupIndex, out var group))
            {
                return(group.Commands.Contains(cmdName));
            }

            _logger.Error($"Unknown groupIndex: {groupIndex}");
            return(false);
        }
示例#3
0
        public void SetGroup(IPlayerSession session, ConGroupIndex newGroup)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            if (!_groups.GroupExists(newGroup))
            {
                return;
            }

            _sessions.SetSessionGroup(session, newGroup);
        }
        private void LoadGroupYamlStream(Stream stream)
        {
            try
            {
                using (var reader = new StreamReader(stream))
                {
                    var groupList = new Deserializer().Deserialize <List <ConGroup> >(reader);

                    foreach (var permGroup in groupList)
                    {
                        var grpIndex = new ConGroupIndex(permGroup.Index);
                        if (!_groups.ContainsKey(grpIndex))
                        {
                            _groups.Add(grpIndex, permGroup);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _logger.Error($"Could not parse the yaml group file! {e.Message}");
            }
        }
 public bool GroupExists(ConGroupIndex index)
 {
     return(_groups.ContainsKey(index));
 }
示例#6
0
        public string?GetGroupName(ConGroupIndex index)
        {
            var groupDict = _groups.Groups;

            return(groupDict.TryGetValue(index, out var group) ? group?.Name : null);
        }