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


C# IChatService.CreateFriendsAsync方法代码示例

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


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

示例1: FriendsViewModel

        public FriendsViewModel()
        {
            chatService = ServiceLocator.Current.GetInstance<IChatService>();
            notificationService = ServiceLocator.Current.GetInstance<INotificationService>();
            authenticationService = ServiceLocator.Current.GetInstance<IAuthenticationService>();

            Contacts contacts = new Contacts();
            contacts.SearchCompleted += contacts_SearchCompleted;
            contacts.SearchAsync(String.Empty, FilterKind.None, null);

            InviteContacts = new RelayCommand(async () =>
            {
                if (CurrentUser != null)
                {
                    StringBuilder emailAddresses = new StringBuilder();
                    foreach (User contact in Contacts)
                    {
                        emailAddresses.Append(contact.EmailAddresses).Append(" ");
                    }
                    emailAddresses.Remove(emailAddresses.Length - 1, 1);

                    await chatService.CreateFriendsAsync(CurrentUser.UserId, 
                        emailAddresses.ToString());

                    ReadFriends();
                }
            });


            RegisterPushCommand = new RelayCommand(() =>
            {
                /// Holds the push channel that is created or found.
                HttpNotificationChannel pushChannel;

                // The name of our push channel.
                string channelName = "slapchat";

                // Try to find the push channel.
                pushChannel = HttpNotificationChannel.Find(channelName);

                // If the channel was not found, then create a new connection to the push service.
                if (pushChannel == null)
                {
                    pushChannel = new HttpNotificationChannel(channelName);

                    // Register for all the events before attempting to open the channel.
                    pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                    pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                    pushChannel.Open();

                    // Bind this new channel for Tile events.
                    pushChannel.BindToShellToast();

                }
                else
                {
                    // The channel was already open, so just register for all the events.
                    pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                    pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                    Debug.WriteLine(pushChannel.ChannelUri.ToString());
                    PushChannel = pushChannel.ChannelUri;

                }

            });

            RefreshCommand = new RelayCommand(() =>
            {
                ReadFriends();
            });

            PropertyChanged += FriendsViewModel_PropertyChanged;

        }
开发者ID:yeenfei,项目名称:samples,代码行数:76,代码来源:FriendsViewModel.cs


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