本文整理汇总了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;
}
示例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>();
}
}
示例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);
}
示例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);
}
示例5: ReadProject
private static XProject ReadProject(ZipArchiveEntry projectEntry, IFileSystem fileIO, IJsonSerializer serializer)
{
using (var entryStream = projectEntry.Open())
{
return serializer.Deserialize<XProject>(fileIO.ReadUtf8Text(entryStream));
}
}