示例#1
0
        public bool IsSourceNameTaken(IUserInfo user, string sourceName)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (sourceName == null)
            {
                throw new ArgumentNullException("sourceName");
            }

            return(OwnedSources.Contains(user.UserId) && (OwnedSources[user.UserId].Any(s => s.Name == sourceName)));
        }
示例#2
0
        public AudioSource Create(string name, IUserInfo owner, AudioCodecArgs audioArgs)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }
            if (audioArgs == null)
            {
                throw new ArgumentNullException("audioArgs");
            }

            if (OwnedSources.Contains(owner.UserId))
            {
                if (OwnedSources[owner.UserId].Any(s => s.Name == name))
                {
                    throw new ArgumentException("Duplicate source name", "name");
                }
            }

            int id = 1;

            if (Sources.Keys.Any())
            {
                id = Sources.Keys.Max() + 1;
            }

            var source = new AudioSource(name, id, owner.UserId, audioArgs);

            Sources.Add(source.Id, source);
            OwnedSources.Add(owner.UserId, source);

            return(source);
        }