/// <summary>
 /// Initializes a new instance of the <see cref="ShareLink"/> class.
 /// </summary>
 /// <param name="streamStore">
 ///     The stream store.
 /// </param>
 /// <param name="subscriptionStore"></param>
 public ShareLink(IStreamStore streamStore, SubscriptionStore subscriptionStore)
 {
     this.streamStore = streamStore;
     this.subscriptionStore = subscriptionStore;
     this.InitializeComponent();
     this.viewModel = this.DataContext as ShareLinkViewModel;
 }
 /// <summary>
 /// The process.
 /// </summary>
 /// <param name="content">
 /// The content.
 /// </param>
 /// <param name="showNotifications">
 /// The show notifications.
 /// </param>
 public void Process(string content, bool showNotifications)
 {
     dynamic jsonObject = JsonConvert.DeserializeObject(content);
     
     if (jsonObject.ObjectType == "submittedlink")
     {
         SendLinkNotification(content, showNotifications);
     }
     else if (jsonObject.ObjectType == "subscription")
     {
         this.AddSubscription(content);
     }
     else if (jsonObject.streamKey != null)
     {
         var store = new SubscriptionStore();
         store.Remove((string)jsonObject.streamKey);
     }
 }
Exemple #3
0
        /// <summary>
        /// The on activated.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            if (args.Kind == ActivationKind.Protocol)
            {
                var protocalArgs = (ProtocolActivatedEventArgs)args;
                var url = protocalArgs.Uri;

                var queryString = ParseQueryString(url.Query);

                if (queryString.ContainsKey("streamKey"))
                {
                    var subscriptionStore = new SubscriptionStore();
                    var subscription = await subscriptionStore.Add(queryString["streamKey"]);

                    var rootFrame = Window.Current.Content as Frame;
                    var page = rootFrame.Content as Page;
                    var subscriptionViewModel = Mapper.Map<Subscription, SubscriptionViewModel>(subscription);
                    
                    page.Frame.Navigate(typeof(ViewStream), subscriptionViewModel);
                }
            }

            base.OnActivated(args);
        }
        /// <summary>
        /// The add subscription.
        /// </summary>
        /// <param name="content">
        /// The content.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private bool AddSubscription(string content)
        {
            Subscription subscription;
            try
            {
                subscription = JsonConvert.DeserializeObject<Subscription>(content);
            }
            catch (Exception exception)
            {
                return false;
            }

            var store = new SubscriptionStore();

            if (store.GetSubsriptions().Any(s => s.Id == subscription.Id))
            {
                return false;
            }

            store.AddSubscription(subscription);

            return true;
        }