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


C# JsonSerializer.SerializeToWriter方法代码示例

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


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

示例1: SaveModel

 private void SaveModel(string fileLocation)
 {
     using (var writer = new StreamWriter(fileLocation))
     {
         var serializer = new JsonSerializer<MusicModel>();
         serializer.SerializeToWriter(_musicViewModel.MusicModel, writer);
     }
 }
开发者ID:dmacuk,项目名称:MusicPicker,代码行数:8,代码来源:SaveMusicCommand.cs

示例2: ServiceStackSerialize

        public void ServiceStackSerialize()
        {
            DatabaseCompat db = GetNorthwindObject();
            JsonSerializer<DatabaseCompat> serializer = new JsonSerializer<DatabaseCompat>();
            serializer.SerializeToWriter(db, TextWriter.Null);

            Time(Iterations, () => serializer.SerializeToWriter(db, TextWriter.Null));
        }
开发者ID:ZapTechnology,项目名称:ForSerial,代码行数:8,代码来源:PerformanceTest.cs

示例3: Main


//.........这里部分代码省略.........
                            try
                            {
                                Directory.CreateDirectory(p.Object.DumpDir);
                            }
                            catch (Exception ex)
                            {
                                _logger.Error($"Error creating DumpDir '{p.Object.DumpDir}': {ex.Message}. Exiting");
                                return;
                            }
                        }

                        var key = reg.GetKey(p.Object.DumpKey);

                        if (key == null)
                        {
                            _logger.Warn($"Key not found: {p.Object.DumpKey}. Exiting");
                            return;
                        }
                        
                        var nout = $"{key.KeyName}_dump.json";
                        var fout = Path.Combine(p.Object.DumpDir, nout);

                        _logger.Info("Found key. Dumping data. Be patient as this can take a while...");

                        var jsons = new JsonSerializer<RegistryKey>();

                        //TODO need a way to get a simple representation of things here, like
                        //name, path, date, etc vs EVERYTHING
                        

                        using (var sw = new StreamWriter(fout))
                        {
                            sw.AutoFlush = true;
                            jsons.SerializeToWriter(key,sw);
                        }
                                              
                        _logger.Warn($"'{p.Object.DumpKey}' saved to '{fout}'");

                    }
                    else if (p.Object.KeyName.Length > 0)
                    {
                        var key = reg.GetKey(p.Object.KeyName);

                        if (key == null)
                        {
                            _logger.Warn($"Key '{p.Object.KeyName}' not found.");
                            DumpStopWatchInfo();
                            continue;
                        }

                        if (p.Object.ValueName.Length > 0)
                        {
                            var val = key.Values.SingleOrDefault(c => c.ValueName == p.Object.ValueName);

                            if (val == null)
                            {
                                _logger.Warn($"Value '{p.Object.ValueName}' not found for key '{p.Object.KeyName}'.");

                                DumpStopWatchInfo();
                                continue;
                            }

                            _sw.Stop();
                            totalSeconds += _sw.Elapsed.TotalSeconds;

                            _logger.Info(val);
开发者ID:CyberDefenseInstitute,项目名称:CDIR-A,代码行数:67,代码来源:Program.cs


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