当前位置: 首页>>代码示例>>C#>>正文


C# IUser.IsOnChannel方法代码示例

本文整理汇总了C#中IUser.IsOnChannel方法的典型用法代码示例。如果您正苦于以下问题:C# IUser.IsOnChannel方法的具体用法?C# IUser.IsOnChannel怎么用?C# IUser.IsOnChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUser的用法示例。


在下文中一共展示了IUser.IsOnChannel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveUser

        /// <summary>
        /// Removes a user from the server
        /// </summary>
        /// <param name="user"></param>
        /// <returns>TRUE if the user is succesfully removed</returns>
        public bool RemoveUser(IUser user)
        {
            lock (lockObject)
            {
                if (!users.Remove(user.Numeric))
                {
                    return false;
                }

                foreach (var pair in ChannelEntries.ToArray())
                {
                    if (user.IsOnChannel(pair.Key.Name))
                    {
                        var list = pair.Value as List<ChannelEntry>;
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (list[i].User == user)
                            {
                                (user as User).OnRemoveFromChannel(pair.Key);
                                list.RemoveAt(i);
                                break;
                            }
                        }

                        (pair.Key as Channel).RemoveInvitation(user);

                        if (list.Count < 1)
                        {
                            ChannelEntries.Remove(pair.Key);
                            channels.Remove(pair.Key.Name);
                        }
                    }
                }
                
                return true;
            }
        }
开发者ID:danij,项目名称:IRCService.NET,代码行数:42,代码来源:Server.cs

示例2: InviteUserToChannel

        /// <summary>
        /// Invites a user to a channel
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool InviteUserToChannel(string channel, IUser user)
        {
            if (channel.Length < 2 || channel[0] != '#')
            {
                throw new InvalidChannelException();
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            ChannelEntry currentEntry = User.GetChannelEntry(channel);
            if (currentEntry == null)
            {
                throw new NotOnChannelException();
            }
            if ((currentEntry.Op == false) && (currentEntry.HalfOp == false))
            {
                throw new NotAChannelOperatorException();
            }
            if (user.IsOnChannel(channel))
            {
                throw new UserAlreadyOnChannelException();
            }

            var command =
                Plugin.Service.CommandFactory.CreateInviteUserCommand();
            command.From = User;
            command.User = user;
            command.Channel = currentEntry.Channel;
            Plugin.Service.SendCommand(command);
            return true;
        }        
开发者ID:danij,项目名称:IRCService.NET,代码行数:39,代码来源:UserAction.cs

示例3: AddUser

        /// <summary>
        /// Adds a user to the channel
        /// </summary>
        /// <param name="user"></param>
        /// <param name="op"></param>
        /// <param name="voice"></param>
        /// <param name="halfop"></param>
        /// <returns>TRUE if the user is successfully added</returns>
        public bool AddUser(IUser user, bool op, bool voice, bool halfop)
        {
            lock (lockObject)
            {
                if (user.IsOnChannel(Name))
                {
                    return false;
                }
                ChannelEntry entry = new ChannelEntry(this, user);
                entry.Op = op;
                entry.Voice = voice;
                entry.HalfOp = halfop;

                var list = user.Server.ChannelEntries[this] as List<ChannelEntry>;
                list.Add(entry);
                (user as User).OnAddToChannel(entry);

                if (Service.BurstCompleted)
                {
                    RemoveInvitation(user);
                }
                return true;
            }
        }
开发者ID:danij,项目名称:IRCService.NET,代码行数:32,代码来源:Channel.cs


注:本文中的IUser.IsOnChannel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。