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


C# ChatRoom.IsUserAllowed方法代码示例

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


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

示例1: EnsureAllowed

 public static void EnsureAllowed(this ChatUser user, ChatRoom room)
 {
     if (room.Private && !room.IsUserAllowed(user))
     {
         throw new InvalidOperationException("You do not have access to " + room.Name);
     }
 }
开发者ID:v-jli,项目名称:jean0603jabbr,代码行数:7,代码来源:ModelExtensions.cs

示例2: EnsureAllowed

 public static void EnsureAllowed(this ChatUser user, ChatRoom room)
 {
     if (room.Private && !room.IsUserAllowed(user))
     {
         throw new HubException(String.Format(LanguageResources.RoomAccessPermission, room.Name));
     }
 }
开发者ID:QuinntyneBrown,项目名称:JabbR,代码行数:7,代码来源:ModelExtensions.cs

示例3: JoinRoom

        public void JoinRoom(ChatUser user, ChatRoom room, string inviteCode)
        {
            // Throw if the room is private but the user isn't allowed
            if (room.Private)
            {
                // First, check if the invite code is correct
                if (!String.IsNullOrEmpty(inviteCode) && String.Equals(inviteCode, room.InviteCode, StringComparison.OrdinalIgnoreCase))
                {
                    // It is, add the user to the allowed users so that future joins will work
                    room.AllowedUsers.Add(user);
                }
                if (!room.IsUserAllowed(user))
                {
                    throw new HubException(String.Format(LanguageResources.Join_LockedAccessPermission, room.Name));
                }
            }

            // Add this user to the room
            _repository.AddUserRoom(user, room);

            ChatUserPreferences userPreferences = user.Preferences;
            userPreferences.TabOrder.Add(room.Name);
            user.Preferences = userPreferences;

            // Clear the cache
            _cache.RemoveUserInRoom(user, room);
        }
开发者ID:Virgil-Imbrea,项目名称:fixitnao,代码行数:27,代码来源:ChatService.cs

示例4: JoinRoom

        public void JoinRoom(ChatUser user, ChatRoom room, string inviteCode)
        {
            // Throw if the room is private but the user isn't allowed
            if (room.Private)
            {
                // First, check if the invite code is correct
                if (!String.IsNullOrEmpty(inviteCode) && String.Equals(inviteCode, room.InviteCode, StringComparison.OrdinalIgnoreCase))
                {
                    // It is, add the user to the allowed users so that future joins will work
                    room.AllowedUsers.Add(user);
                }
                if (!room.IsUserAllowed(user))
                {
                    throw new InvalidOperationException(String.Format("Unable to join {0}. This room is locked and you don't have permission to enter. If you have an invite code, make sure to enter it in the /join command", room.Name));
                }
            }

            // Add this user to the room
            _repository.AddUserRoom(user, room);

            // Clear the cache
            _cache.RemoveUserInRoom(user, room);
        }
开发者ID:phillip-haydon,项目名称:JabbR,代码行数:23,代码来源:ChatService.cs


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