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


C# IJsonSerializer.Deserialize方法代码示例

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


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

示例1: MainWindow

        public MainWindow()
        {
            InitializeComponent();
            ConnectionsListView.ItemsSource = _storageAccountConnections;
            IDeploymentRepositoryFactory deploymentRepositoryFactory = new DeploymentRepositoryFactory();
            _deploymentRepositoryManager = new DeploymentRepositoryManager(deploymentRepositoryFactory);
            _jsonSerializer = new JsonSerializer(new DiagnosticsTraceWriter());
            _deploymentConfigSerializer = new JsonDeploymentConfigSerializer(_jsonSerializer);
            if (File.Exists(SettingsFilePath))
            {
                string json = File.ReadAllText(SettingsFilePath);
                _storageAccountConnections = _jsonSerializer.Deserialize<List<StorageAccountConnectionInfo>>(json);
                ConnectionsListView.ItemsSource = _storageAccountConnections;
            }

            if (!Directory.Exists(DeploymentsConfigsDirPath))
            {
                Directory.CreateDirectory(DeploymentsConfigsDirPath);
            }

	        _deploymentConfigFileWatcher = new FileSystemWatcher
	        {
		        Path = Path.GetFullPath(DeploymentsConfigsDirPath),
		        NotifyFilter = NotifyFilters.LastWrite,
		        Filter = "*.json"
	        };
	        _deploymentConfigFileWatcher.Changed += OnDeploymentConfigFileChanged;
            _deploymentConfigFileWatcher.EnableRaisingEvents = true;
        }
开发者ID:Microsoft,项目名称:Yams,代码行数:29,代码来源:MainWindow.xaml.cs

示例2: FilesEventPersistence

        public FilesEventPersistence(
            ILog log,
            IJsonSerializer jsonSerializer,
            IFilesEventStoreConfiguration configuration,
            IFilesEventLocator filesEventLocator)
        {
            _log = log;
            _jsonSerializer = jsonSerializer;
            _filesEventLocator = filesEventLocator;
            _logFilePath = Path.Combine(configuration.StorePath, "Log.store");

            if (File.Exists(_logFilePath))
            {
                var json = File.ReadAllText(_logFilePath);
                var eventStoreLog = _jsonSerializer.Deserialize<EventStoreLog>(json);
                _globalSequenceNumber = eventStoreLog.GlobalSequenceNumber;
                _eventLog = eventStoreLog.Log ?? new Dictionary<long, string>();

                if (_eventLog.Count != _globalSequenceNumber)
                {
                    eventStoreLog = RecreateEventStoreLog(configuration.StorePath);
                    _globalSequenceNumber = eventStoreLog.GlobalSequenceNumber;
                    _eventLog = eventStoreLog.Log;
                }
            }
            else
            {
                _eventLog = new Dictionary<long, string>();
            }
        }
开发者ID:liemqv,项目名称:EventFlow,代码行数:30,代码来源:FilesEventPersistence.cs

示例3: GetSettings

        public SettingsResponse GetSettings(ExceptionlessConfiguration config, IJsonSerializer serializer) {
            HttpWebResponse response;
            try {
                var request = CreateHttpWebRequest(config, "projects/config");
                response = request.GetJsonAsync().Result as HttpWebResponse;
            } catch (Exception ex) {
                var message = String.Concat("Unable to retrieve configuration settings. Exception: ", ex.GetMessage());
                return new SettingsResponse(false, message: message);
            }

            if (response == null || response.StatusCode != HttpStatusCode.OK)
                return new SettingsResponse(false, message: String.Format("Unable to retrieve configuration settings: {0}", GetResponseMessage(response)));

            var json = response.GetResponseText();
            if (String.IsNullOrWhiteSpace(json))
                return new SettingsResponse(false, message: "Invalid configuration settings.");

            var settings = serializer.Deserialize<ClientConfiguration>(json);
            return new SettingsResponse(true, settings.Settings, settings.Version);
        }
开发者ID:mgnslndh,项目名称:Exceptionless.Net,代码行数:20,代码来源:SubmissionClient.cs

示例4: GetSettings

        public SettingsResponse GetSettings(ExceptionlessConfiguration config, int version, IJsonSerializer serializer) {
            if (!config.IsValid)
                return new SettingsResponse(false, message: "Invalid client configuration settings.");

            string url = String.Format("{0}/projects/config?v={1}", GetServiceEndPoint(config), version);

            HttpResponseMessage response;
            try {
                _client.Value.AddAuthorizationHeader(config.ApiKey);
                response = _client.Value.GetAsync(url).ConfigureAwait(false).GetAwaiter().GetResult();
            } catch (Exception ex) {
                var message = String.Concat("Unable to retrieve configuration settings. Exception: ", ex.GetMessage());
                return new SettingsResponse(false, message: message);
            }

            if (response != null && response.StatusCode == HttpStatusCode.NotModified)
                return new SettingsResponse(false, message: "Settings have not been modified.");

            if (response == null || response.StatusCode != HttpStatusCode.OK)
                return new SettingsResponse(false, message: String.Concat("Unable to retrieve configuration settings: ", GetResponseMessage(response)));

            var json = GetResponseText(response);
            if (String.IsNullOrWhiteSpace(json))
                return new SettingsResponse(false, message: "Invalid configuration settings.");

            var settings = serializer.Deserialize<ClientConfiguration>(json);
            return new SettingsResponse(true, settings.Settings, settings.Version);
        }
开发者ID:InlineAsm,项目名称:Exceptionless.Net,代码行数:28,代码来源:DefaultSubmissionClient.cs

示例5: ReadProject

 private static XProject ReadProject(ZipArchiveEntry projectEntry, IFileSystem fileIO, IJsonSerializer serializer)
 {
     using (var entryStream = projectEntry.Open())
     {
         return serializer.Deserialize<XProject>(fileIO.ReadUtf8Text(entryStream));
     }
 }
开发者ID:Core2D,项目名称:Core2D,代码行数:7,代码来源:XProject.IO.cs


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