/// <summary> /// Creates an instance of the build plan's type by creating a WCF channel that implements it /// </summary> /// <param name="context">Context used to build up the object.</param> public void BuildUp(IBuilderContext context) { if (context.Existing == null) { IChannelManager channelManager = context.Lifetime.OfType <IChannelManager>().Single(); if (BuildKey.GetType(context.BuildKey).IsAssignableFrom(_ServiceInterfaceType) == false) { throw new Exception("A WcfProxyBuildPlanPolicy has been paired with an incorrect BuildKey. Its build key type is not assignable from the service interface type."); } context.Existing = channelManager.CreateChannel(_ServiceInterfaceType, _ChannelFactoryFactory); } }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var channelName = request.Data.GetOrDefault <string>(k.channel); _channelManager.GetChannelByName(channelName).ThrowIfNotNull(ErrorCodes.ChannelAlreadyExists); _channelManager.CreateChannel(ChannelType.Public, channelName); _channelManager.JoinChannel(channelName, character, PresetChannelRoles.ROLE_GOD, null); Message.Builder.FromRequest(request).WithOk().Send(); scope.Complete(); } }
public ChannelsViewModel(IChannelManager channelManager) { RefreshCommand = new MvxCommand(() => { channelManager.RequestPrivateChannels(); channelManager.RequestPublicChannels(); }); if (channelManager.PublicChannels.Count == 0) { RefreshCommand.Execute(null); } Func <ChannelListItem, ListItem> mapper = item => new ListItem(channelManager, item); Tabs = new[] { new Tab(Strings.Channels_Public, new MappingObservableList <ChannelListItem, ListItem>(channelManager.PublicChannels, mapper)), new Tab(Strings.Channels_Private, new MappingObservableList <ChannelListItem, ListItem>(channelManager.PrivateChannels, mapper)) }; SelectedTab = Tabs[0]; TabSelectedCommand = new MvxCommand <Tab>(tab => SelectedTab = tab); CreateCommand = new MvxCommand <string>(name => { channelManager.CreateChannel(name); channelManager.RequestPrivateChannels(); }); }
public static void CreateAndJoinChannel(this IChannelManager channelManager, ChannelType channelType, string name, Character member) { channelManager.CreateChannel(channelType, name); channelManager.JoinChannel(name, member, PresetChannelRoles.ROLE_GOD, null); }