Ejemplo n.º 1
0
        private void Accept_Click(object sender, RoutedEventArgs e)
        {
            ValueSet result = new ValueSet();

            result["Status"]      = "Success";
            result["ProductName"] = productName;
            operation.ReportCompleted(result);
        }
Ejemplo n.º 2
0
        private void CancelClicked(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            var result = new ValueSet();

            result["Success"] = false;
            result["Reason"]  = "Cancelled";

            operation.ReportCompleted(result);
        }
Ejemplo n.º 3
0
        private void SendResults_Click(object sender, RoutedEventArgs e)
        {
            var values = new ValueSet();

            values["Answer"] = 42;
            _protocolForResultsOperation.ReportCompleted(values);
        }
Ejemplo n.º 4
0
        private void BtnCheckout_Click(object sender, RoutedEventArgs e)
        {
            ValueSet result = new ValueSet();

            result["ReturnData"] = totalAmount;
            operation.ReportCompleted(result);
        }
Ejemplo n.º 5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var ResultSet = new ValueSet();

            ResultSet.Add("price", "299");
            _op.ReportCompleted(ResultSet);
        }
Ejemplo n.º 6
0
        // 返回数据
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            ValueSet result = new ValueSet();

            result["ReturnData"] = "return data";

            _protocolForResultsOperation.ReportCompleted(result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs;

            this.operation = protocolForResultsArgs.ProtocolForResultsOperation;
            var callerPfn = protocolForResultsArgs.CallerPackageFamilyName;

            // We only want certain, approved apps to use our checkout functionality so check the caller is one
            // This is, of course, optional. You don't have to do this.
            if (this.validCallers.Any(c => c.Item1.Equals(callerPfn)))
            {
                if (protocolForResultsArgs.Data.Keys.Count == 2 &&
                    protocolForResultsArgs.Data.ContainsKey("Transaction") &&
                    protocolForResultsArgs.Data.ContainsKey("Items"))
                {
                    // This is a bit hacky - you could put this into a view model if you wanted
                    this.transaction = protocolForResultsArgs.Data["Transaction"] as string;
                    var items = protocolForResultsArgs.Data["Items"] as string;

                    var allItems = JsonConvert.DeserializeObject <List <Item> >(items);

                    this.ItemsInOrder.ItemsSource = allItems;

                    this.totalAmount      = allItems.Select(i => i.UnitPrice * i.Quantity).Sum().ToString();
                    this.TotalAmount.Text = this.totalAmount;
                }
                else
                {
                    var result = new ValueSet();
                    result["Success"] = false;
                    result["Reason"]  = "Invalid payload";

                    operation.ReportCompleted(result);
                }
            }
            else
            {
                var result = new ValueSet();
                result["Success"] = false;
                result["Reason"]  = "Application not approved";

                operation.ReportCompleted(result);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var protocolForResultsArgs = e.Parameter as ProtocolForResultsActivatedEventArgs;
            this.operation = protocolForResultsArgs.ProtocolForResultsOperation;
            var callerPfn = protocolForResultsArgs.CallerPackageFamilyName;

            // We only want certain, approved apps to use our checkout functionality so check the caller is one
            // This is, of course, optional. You don't have to do this.
            if (this.validCallers.Any(c => c.Item1.Equals(callerPfn)))
            {
                if (protocolForResultsArgs.Data.Keys.Count == 2
                    && protocolForResultsArgs.Data.ContainsKey("Transaction")
                    && protocolForResultsArgs.Data.ContainsKey("Items"))
                {
                    // This is a bit hacky - you could put this into a view model if you wanted
                    this.transaction = protocolForResultsArgs.Data["Transaction"] as string;
                    var items = protocolForResultsArgs.Data["Items"] as string;

                    var allItems = JsonConvert.DeserializeObject<List<Item>>(items);

                    this.ItemsInOrder.ItemsSource = allItems;

                    this.totalAmount = allItems.Select(i => i.UnitPrice * i.Quantity).Sum().ToString();
                    this.TotalAmount.Text = this.totalAmount;
                }
                else
                {
                    var result = new ValueSet();
                    result["Success"] = false;
                    result["Reason"] = "Invalid payload";

                    operation.ReportCompleted(result);
                }
            }
            else
            {
                var result = new ValueSet();
                result["Success"] = false;
                result["Reason"] = "Application not approved";

                operation.ReportCompleted(result);
            }
        }
        public void ReportResults(IDictionary <string, object> results)
        {
            var data = new ValueSet();

            foreach (var item in results)
            {
                data.Add(item.Key, item.Value);
            }
            operation.ReportCompleted(data);
        }
Ejemplo n.º 10
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ProtocolForResultsOperation ro = ((App)App.Current).mem["ResultsOperation"] as ProtocolForResultsOperation;

            // wait for user input oder simply return a value
            var resultData = new ValueSet();

            resultData.Add("Result", "Hello from Result Target");
            ro.ReportCompleted(resultData);
        }
Ejemplo n.º 11
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter is ProtocolForResultsActivatedEventArgs protocolForResultsArgs)
            {
                // Set the ProtocolForResultsOperation field.
                operation = protocolForResultsArgs.ProtocolForResultsOperation;

                if (protocolForResultsArgs.Data.ContainsKey("TestData"))
                {
                    string dataFromCaller = protocolForResultsArgs.Data["TestData"] as string;
                    //response to the calling app
                    var result = new ValueSet();
                    result["ReturnedData"] = "The returned result";
                    operation.ReportCompleted(result);
                }
            }
        }