Exemplo n.º 1
0
        public bool CanViewVar(ConGroupIndex groupIndex)
        {
            if (_groups.TryGetValue(groupIndex, out var group))
            {
                return(group.CanViewVar);
            }

            _logger.Error($"Unknown groupIndex: {groupIndex}");
            return(false);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        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}");
            }
        }
Exemplo n.º 5
0
 public bool GroupExists(ConGroupIndex index)
 {
     return(_groups.ContainsKey(index));
 }
Exemplo n.º 6
0
        public string?GetGroupName(ConGroupIndex index)
        {
            var groupDict = _groups.Groups;

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