示例#1
0
        private ChannelInfoResult GetChannelFromEvent(IrcChannelEventArgs e)
        {
            var network = networks.Where(n => n.Client == e.Channel.Client).First();
            var channel = network.Channels.Where(c => c.Name == e.Channel.Name).FirstOrDefault();

            if (channel == null)
            {
                channel = new Channel()
                {
                    Joined = true,
                    Name   = e.Channel.Name,
                    Id     = idService.NewId()
                };
            }

            return(new ChannelInfoResult()
            {
                Network = network,
                Channel = channel
            });
        }
        public void Set(IRCProfile profile)
        {
            Condition.Requires <string>(profile.Name, "Name").IsNotNullOrWhiteSpace();

            if (profile.Id == null)
            {
                profile.Id = idService.NewId();
            }
            else
            {
                var existing = Get(profile.Id);
                if (existing != null)
                {
                    profiles.Remove(existing);
                }
            }

            profiles.Add(profile);
            mediator.Publish(new AddProfileEvent()
            {
                Profile = profile
            });
            Save();
        }