本文整理汇总了C#中JabbR.Models.ChatUser.EnsureAllowed方法的典型用法代码示例。如果您正苦于以下问题:C# ChatUser.EnsureAllowed方法的具体用法?C# ChatUser.EnsureAllowed怎么用?C# ChatUser.EnsureAllowed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JabbR.Models.ChatUser
的用法示例。
在下文中一共展示了ChatUser.EnsureAllowed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args)
{
if (String.IsNullOrEmpty(callerContext.RoomName))
{
throw new InvalidOperationException("This command cannot be invoked from the Lobby.");
}
string targetRoomName = args.Length > 0 ? args[0] : callerContext.RoomName;
if (String.IsNullOrEmpty(targetRoomName))
{
throw new InvalidOperationException("Which room?");
}
ChatRoom targetRoom = context.Repository.VerifyRoom(targetRoomName, mustBeOpen: false);
// ensure the user could join the room if they wanted to
callingUser.EnsureAllowed(targetRoom);
if (String.IsNullOrEmpty(targetRoom.InviteCode))
{
context.Service.SetInviteCode(callingUser, targetRoom, RandomUtils.NextInviteCode());
}
ChatRoom callingRoom = context.Repository.GetRoomByName(callerContext.RoomName);
context.NotificationService.PostNotification(callingRoom, callingUser, String.Format("Invite Code for {0}: {1}", targetRoomName, targetRoom.InviteCode));
}
示例2: Execute
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args)
{
if (String.IsNullOrEmpty(callerContext.RoomName))
{
throw new HubException(LanguageResources.InvokeFromRoomRequired);
}
string targetRoomName = args.Length > 0 ? args[0] : callerContext.RoomName;
if (String.IsNullOrEmpty(targetRoomName))
{
throw new HubException(LanguageResources.InviteCode_RoomRequired);
}
ChatRoom targetRoom = context.Repository.VerifyRoom(targetRoomName, mustBeOpen: false);
// ensure the user could join the room if they wanted to
callingUser.EnsureAllowed(targetRoom);
if (String.IsNullOrEmpty(targetRoom.InviteCode))
{
context.Service.SetInviteCode(callingUser, targetRoom, RandomUtils.NextInviteCode());
}
ChatRoom callingRoom = context.Repository.GetRoomByName(callerContext.RoomName);
context.NotificationService.PostNotification(callingRoom, callingUser, String.Format(LanguageResources.InviteCode_Success, targetRoomName, targetRoom.InviteCode));
}
示例3: Execute
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args)
{
string targetRoomName = args.Length > 0 ? args[0] : callerContext.RoomName;
if (String.IsNullOrEmpty(targetRoomName) || targetRoomName.Equals("Lobby", StringComparison.InvariantCultureIgnoreCase))
{
throw new InvalidOperationException("Which room?");
}
ChatRoom room = context.Repository.VerifyRoom(targetRoomName, mustBeOpen: false);
// ensure the user could join the room if they wanted to
callingUser.EnsureAllowed(room);
context.NotificationService.ListAllowedUsers(room);
}
示例4: Execute
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args)
{
string targetRoomName = args.Length > 0 ? args[0] : callerContext.RoomName;
if (String.IsNullOrEmpty(targetRoomName))
{
throw new HubException(LanguageResources.Owners_RoomRequired);
}
ChatRoom room = context.Repository.VerifyRoom(targetRoomName, mustBeOpen: false);
// ensure the user could join the room if they wanted to
callingUser.EnsureAllowed(room);
context.NotificationService.ListOwners(room);
}
示例5: Execute
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args)
{
string roomName = args.Length > 0 ? args[0] : callerContext.RoomName;
if (String.IsNullOrEmpty(roomName))
{
throw new InvalidOperationException("Which room do you want to list the current users of?");
}
ChatRoom room = context.Repository.VerifyRoom(roomName);
// ensure the user could join the room if they wanted to
callingUser.EnsureAllowed(room);
var names = context.Repository.GetOnlineUsers(room).Select(s => s.Name);
context.NotificationService.ListUsers(room, names);
}
示例6: Execute
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args)
{
string roomName = args.Length > 0 ? args[0] : callerContext.RoomName;
if (String.IsNullOrEmpty(roomName))
{
throw new HubException(LanguageResources.List_RoomRequired);
}
ChatRoom room = context.Repository.VerifyRoom(roomName);
// ensure the user could join the room if they wanted to
callingUser.EnsureAllowed(room);
var names = context.Repository.GetOnlineUsers(room).Select(s => s.Name);
context.NotificationService.ListUsers(room, names);
}