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


C# JsonArray.Stringify方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            SyndicationClient client = new SyndicationClient();
            JsonArray jsonArray = new JsonArray();

            foreach (string key in keys)
            {
                string uriString = "http://social.msdn.microsoft.com/Forums/en-US/" + key + "/threads?outputAs=rss";
                Uri uri = new Uri(uriString);
                Task<SyndicationFeed> task = client.RetrieveFeedAsync(uri).AsTask();
                task.Wait();
                SyndicationFeed feed = task.Result;
                Console.WriteLine(key);
                Console.WriteLine(feed.Title.Text);
                Console.WriteLine(feed.Subtitle.Text);
                Console.WriteLine();

                JsonObject jsonObject = new JsonObject();
                jsonObject.AddStringValue("favicon_url", "http://social.microsoft.com/Forums/GlobalResources/images/Msdn/favicon.ico");
                jsonObject.AddStringValue("icon_url", "http://kiewic.com/questions/icon/" + key);
                jsonObject.AddStringValue("audience", feed.Subtitle.Text);
                jsonObject.AddStringValue("site_url", uriString);
                jsonObject.AddStringValue("api_site_parameter", key);
                jsonObject.AddStringValue("name", feed.Title.Text);

                jsonArray.Add(jsonObject);
            }

            File.WriteAllText("msdn.json", jsonArray.Stringify());
            Console.WriteLine(jsonArray.Stringify());
        }
开发者ID:kiewic,项目名称:Projects,代码行数:31,代码来源:Program.cs

示例2: getAndSaveResults

        private void getAndSaveResults()
        {
            // get all results to a List<List<int>>, both completed and uncompleted
            JsonArray newResults = new JsonArray();

            for (int i = 0; i < pivot.Items.Count; ++i)
            {
                //Debug.WriteLine("pivot.Items.Count: " + pivot.Items.Count + "i: " + i);
                
                PivotItem item = pivot.Items[i] as PivotItem;
                CXPivotItem CXitem = item.Content as CXPivotItem;
                
                int currentPlayerIn = CXitem.getThrowsIn();
                int currentPlayerOut = CXitem.getThrowsOut();
                
                if (currentPlayerIn + currentPlayerOut == 100)
                {
                    // player has completed the game
                    JsonObject newResult = new JsonObject();
                    newResult.Add("ResultId", JsonValue.CreateStringValue(DateTime.Now.ToString()));
                    newResult.Add("ResultPlayerName", JsonValue.CreateStringValue(item.Header.ToString()));
                    newResult.Add("ResultGameModeId", JsonValue.CreateStringValue("1"));
                    newResult.Add("Score", JsonValue.CreateNumberValue(currentPlayerIn));
                    newResult.Add("ResultDateTime", JsonValue.CreateStringValue(DateTime.Now.ToString("G")));
                    newResults.Add(newResult);
                    
                    //Debug.WriteLine("New result added for: " + item.Header.ToString());
                }
            }
            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            localSettings.Values["NewResults"] = newResults.Stringify();

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
            }
            this.Frame.BackStack.RemoveAt(1);
            this.navigationHelper.GoBack();
        }
开发者ID:markus-j,项目名称:puttgamesUWP,代码行数:39,代码来源:CXGamePage.xaml.cs

示例3: SaveExistingEvents

        private void SaveExistingEvents()
        {
            JsonArray jsonArray = new JsonArray();

            foreach (var eventDescriptor in eventCollection)
            {
                jsonArray.Add(JsonValue.CreateStringValue(eventDescriptor.ToString()));
            }

            string jsonString = jsonArray.Stringify();
            var settings = ApplicationData.Current.LocalSettings;
            settings.Values["ForegroundGeofenceEventCollection"] = jsonString;
        }
开发者ID:RasmusTG,项目名称:Windows-universal-samples,代码行数:13,代码来源:Scenario4_ForegroundGeofenceHelpers.cs

示例4: ContentDialog_PrimaryButtonClick

        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) {
            var selected = new List<object>(TileList.SelectedItems);

            var picker = new FileSavePicker();
            picker.SuggestedFileName = $"export_{DateTime.Now.ToString(DateTimeFormatInfo.CurrentInfo.ShortDatePattern)}";
            picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            picker.FileTypeChoices.Add("Tiles file", new List<string>() { ".tiles" });
            var file = await picker.PickSaveFileAsync();
            if (file != null) {
                CachedFileManager.DeferUpdates(file);

                await FileIO.WriteTextAsync(file, "");
                
                using (var stream = await file.OpenStreamForWriteAsync())
                using (var zip = new ZipArchive(stream, ZipArchiveMode.Update)) {

                    while (zip.Entries.Count > 0) {
                        zip.Entries[0].Delete();
                    }

                    using (var metaStream = zip.CreateEntry("tiles.json").Open())
                    using (var writer = new StreamWriter(metaStream)) {
                        var array = new JsonArray();

                        selected.ForEachWithIndex<SecondaryTile>((item, index) => {
                            var objet = new JsonObject();
                            objet.Add("Name", item.DisplayName);
                            objet.Add("Arguments", item.Arguments);
                            objet.Add("TileId", item.TileId);
                            objet.Add("IconNormal", item.VisualElements.ShowNameOnSquare150x150Logo);
                            objet.Add("IconWide", item.VisualElements.ShowNameOnWide310x150Logo);
                            objet.Add("IconBig", item.VisualElements.ShowNameOnSquare310x310Logo);
                            
                            array.Add(objet);

                            if (item.VisualElements.Square150x150Logo.LocalPath != DEFAULT_URI) {
                                var path = ApplicationData.Current.LocalFolder.Path + Uri.UnescapeDataString(item.VisualElements.Square150x150Logo.AbsolutePath.Substring(6));
                                
                                zip.CreateEntryFromFile(path, item.TileId + "/normal");
                            }
                        });
                        writer.WriteLine(array.Stringify());
                        
                    }

                    FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);

                    if(status == FileUpdateStatus.Complete) {
                        var folder = await file.GetParentAsync();
                        await new MessageDialog("Speichern erfolgreich").ShowAsync();
                    } else {
                        await new MessageDialog("Speichern fehlgeschlagen").ShowAsync();
                    }

                    Debug.WriteLine(status);
                }
            }
        }
开发者ID:KaiDevelopment,项目名称:TileManager,代码行数:58,代码来源:ExportDialog.xaml.cs

示例5: getAndSaveResults

        // saves both the scores and the full JYLY scores for further use in future (export, graphs, statisctics, etc.)
        private void getAndSaveResults()
        {
            JsonArray newResults = new JsonArray();
            JsonArray newJYLYResults = new JsonArray();

            for (int i = 0; i < pivot.Items.Count; ++i)
            {
                PivotItem item = pivot.Items[i] as PivotItem;
                JYLYPivotItem pivotItem = item.Content as JYLYPivotItem;

                int currentPlayerScore = pivotItem.getScore();

                JsonObject newResult = new JsonObject();
                newResult.Add("ResultId", JsonValue.CreateStringValue(DateTime.Now.ToString()));
                newResult.Add("ResultPlayerName", JsonValue.CreateStringValue(item.Header.ToString()));
                newResult.Add("ResultGameModeId", JsonValue.CreateStringValue("3"));
                newResult.Add("Score", JsonValue.CreateNumberValue(currentPlayerScore));
                newResult.Add("ResultDateTime", JsonValue.CreateStringValue(DateTime.Now.ToString("G")));
                newResults.Add(newResult);

                // Add JYLY results to a separate json object
                JsonObject newJYLYResult = new JsonObject();
                newJYLYResult.Add("Serie", JsonValue.CreateStringValue(pivotItem.getState()));
                newJYLYResult.Add("PlayerName", JsonValue.CreateStringValue(item.Header.ToString()));
                newJYLYResult.Add("Score", JsonValue.CreateNumberValue(currentPlayerScore));
                newJYLYResult.Add("DateTime", JsonValue.CreateStringValue(DateTime.Now.ToString("G")));
                newJYLYResults.Add(newJYLYResult);
            }
            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            localSettings.Values["NewResults"] = newResults.Stringify();
            localSettings.Values["NewJYLYResults"] = newJYLYResults.Stringify();
            
            Debug.WriteLine(newResults.Stringify());
            Debug.WriteLine(newJYLYResults.Stringify());

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
            }
            this.Frame.BackStack.RemoveAt(1);
            this.navigationHelper.GoBack();
        }
开发者ID:markus-j,项目名称:puttgamesUWP,代码行数:43,代码来源:JYLYGamePage.xaml.cs


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