本文整理汇总了C#中IJsonSerializer.DeserializeFromStream方法的典型用法代码示例。如果您正苦于以下问题:C# IJsonSerializer.DeserializeFromStream方法的具体用法?C# IJsonSerializer.DeserializeFromStream怎么用?C# IJsonSerializer.DeserializeFromStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IJsonSerializer
的用法示例。
在下文中一共展示了IJsonSerializer.DeserializeFromStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRegistrationStatus
public static async Task<MBRegistrationRecord> GetRegistrationStatus(IHttpClient httpClient, IJsonSerializer jsonSerializer, string feature, string mb2Equivalent = null, string version = null)
{
//check the reg file first to alleviate strain on the MB admin server - must actually check in every 30 days tho
var reg = new RegRecord {registered = LicenseFile.LastChecked(feature) > DateTime.UtcNow.AddDays(-30)};
if (!reg.registered)
{
var mac = _networkManager.GetMacAddress();
var data = new Dictionary<string, string> { { "feature", feature }, { "key", SupporterKey }, { "mac", mac }, { "mb2equiv", mb2Equivalent }, { "legacykey", LegacyKey }, { "ver", version }, { "platform", Environment.OSVersion.VersionString } };
try
{
using (var json = await httpClient.Post(MBValidateUrl, data, CancellationToken.None).ConfigureAwait(false))
{
reg = jsonSerializer.DeserializeFromStream<RegRecord>(json);
}
if (reg.registered)
{
LicenseFile.AddRegCheck(feature);
}
else
{
LicenseFile.RemoveRegCheck(feature);
}
}
catch (Exception e)
{
_logger.ErrorException("Error checking registration status of {0}", e, feature);
}
}
return new MBRegistrationRecord {IsRegistered = reg.registered, ExpirationDate = reg.expDate, RegChecked = true};
}
示例2: GetChannels
public IEnumerable<ChannelInfo> GetChannels(Stream stream, IJsonSerializer json,ILogger logger)
{
var root = json.DeserializeFromStream<RootObject>(stream);
if (root.channelsJSONObject.rtn != null && root.channelsJSONObject.rtn.Error)
{
logger.Error(root.channelsJSONObject.rtn.Message ?? "Failed to download channel information.");
throw new ApplicationException(root.channelsJSONObject.rtn.Message ?? "Failed to download channel information.");
}
if (root.channelsJSONObject != null && root.channelsJSONObject.Channels != null)
{
UtilsHelper.DebugInformation(logger,string.Format("[NextPvr] ChannelResponse: {0}", json.SerializeToString(root)));
return root.channelsJSONObject.Channels.Select(i => new ChannelInfo
{
Name = i.channel.channelName,
Number = i.channel.channelFormattedNumber.ToString(_usCulture),
Id = i.channel.channelOID.ToString(_usCulture),
ImageUrl = string.IsNullOrEmpty(i.channel.channelIcon) ? null : (_baseUrl + "/" + i.channel.channelIcon),
HasImage = !string.IsNullOrEmpty(i.channel.channelIcon)
});
}
return new List<ChannelInfo>();
}
示例3: GetRegistrationStatus
public static async Task<MBRegistrationRecord> GetRegistrationStatus(IHttpClient httpClient, IJsonSerializer jsonSerializer, string feature, string mb2Equivalent = null)
{
var mac = GetMacAddress();
var data = new Dictionary<string, string> {{"feature", feature}, {"key",SupporterKey}, {"mac",mac}, {"mb2equiv",mb2Equivalent}, {"legacykey", LegacyKey} };
var reg = new RegRecord();
try
{
using (var json = await httpClient.Post(MBValidateUrl, data, CancellationToken.None).ConfigureAwait(false))
{
reg = jsonSerializer.DeserializeFromStream<RegRecord>(json);
}
if (reg.registered)
{
LicenseFile.AddRegCheck(feature);
}
}
catch (Exception)
{
//if we have trouble obtaining from web - allow it if we've validated in the past 30 days
reg.registered = LicenseFile.LastChecked(feature) > DateTime.UtcNow.AddDays(-30);
}
return new MBRegistrationRecord {IsRegistered = reg.registered, ExpirationDate = reg.expDate, RegChecked = true};
}
示例4: GetPrograms
public IEnumerable<ProgramInfo> GetPrograms(Stream stream, IJsonSerializer json, string channelId, ILogger logger)
{
var root = json.DeserializeFromStream<RootObject>(stream);
logger.Debug("[NextPvr] GetPrograms Response: {0}",json.SerializeToString(root));
var listings = root.Guide.Listings;
return listings.Where(i => string.Equals(i.Channel.channelOID.ToString(_usCulture), channelId, StringComparison.OrdinalIgnoreCase))
.SelectMany(i => i.EPGEvents.Select(e => GetProgram(i.Channel, e.epgEventJSONObject.epgEvent)));
}
示例5: RecordingError
public bool? RecordingError(Stream stream, IJsonSerializer json,ILogger logger)
{
var root = json.DeserializeFromStream<RootObject>(stream);
if (root.epgEventJSONObject != null && root.epgEventJSONObject.rtn != null)
{
UtilsHelper.DebugInformation(logger,string.Format("[NextPvr] RecordingError Response: {0}", json.SerializeToString(root)));
return root.epgEventJSONObject.rtn.Error;
}
return null;
}
示例6: LoggedIn
public bool LoggedIn(Stream stream, IJsonSerializer json, ILogger logger)
{
var root = json.DeserializeFromStream<RootObject>(stream);
if (root.SIDValidation != null)
{
logger.Debug("[NextPvr] connection validation: {0}", json.SerializeToString(root));
return root.SIDValidation.validated;
}
logger.Error("[NextPvr] Failed to validate your connection with NextPvr.");
throw new ApplicationException("Failed to validate your connection with NextPvr.");
}
示例7: GetClientKeys
public ClientKeys GetClientKeys(Stream stream, IJsonSerializer json,ILogger logger)
{
var root = json.DeserializeFromStream<RootObject>(stream);
if (root.clientKeys != null && root.clientKeys.sid != null && root.clientKeys.salt != null)
{
logger.Debug("[NextPvr] ClientKeys: {0}", json.SerializeToString(root));
return root.clientKeys;
}
logger.Error("[NextPvr] Failed to load the ClientKeys from NextPvr.");
throw new ApplicationException("Failed to load the ClientKeys from NextPvr.");
}
示例8: GetVLCResponse
public VLCObj GetVLCResponse(Stream stream, IJsonSerializer json, ILogger logger)
{
var root = json.DeserializeFromStream<RootObject>(stream);
if (root.JSONVlcObject.VLC_Obj != null && root.JSONVlcObject.VLC_Obj.isVlcAvailable == true)
{
UtilsHelper.DebugInformation(logger,string.Format("[NextPvr] VLC Response: {0}", json.SerializeToString(root)));
return root.JSONVlcObject.VLC_Obj;
}
logger.Error("[NextPvr] Failed to load the VLC from NEWA");
throw new ApplicationException("Failed to load the VLC from NEWA.");
}
示例9: GetSeriesTimers
public IEnumerable<SeriesTimerInfo> GetSeriesTimers(Stream stream, IJsonSerializer json,ILogger logger)
{
if (stream == null)
{
logger.Error("[NextPvr] GetSeriesTimers stream == null");
throw new ArgumentNullException("stream");
}
var root = json.DeserializeFromStream<RootObject>(stream);
UtilsHelper.DebugInformation(logger,string.Format("[NextPvr] GetSeriesTimers Response: {0}", json.SerializeToString(root)));
return root.ManageResults
.EPGEvents
.Select(i => i.epgEventJSONObject)
// Seeing epgEventJSONObject coming back null for some responses
.Where(i => i != null)
// Seeing recurring parents coming back with these reponses, for some reason
.Where(i => i.recurr != null)
.Select(GetSeriesTimerInfo);
}
示例10: ParseRecRules
private static RecRuleListRoot ParseRecRules(Stream stream, IJsonSerializer json)
{
return json.DeserializeFromStream<RecRuleListRoot>(stream);
}
示例11: ParseProgramList
public static ProgramList ParseProgramList(Stream stream, IJsonSerializer json, ILogger logger)
{
var root = json.DeserializeFromStream<RootProgramListObject>(stream);
return root.ProgramList;
}
示例12: TunerResponse
public TunerResponse(Stream stream, IJsonSerializer json)
{
_root = json.DeserializeFromStream<RootObject>(stream);
}
示例13: ParseRecorded
internal static Program ParseRecorded(Stream stream, IJsonSerializer json, ILogger logger)
{
var root = json.DeserializeFromStream<RootProgramObject>(stream);
return root.Program;
}
示例14: VersionCheckResponse
public VersionCheckResponse(Stream stream, IJsonSerializer json)
{
_root = json.DeserializeFromStream<RootObject>(stream);
}
示例15: GetVLCReturn
public Rtn GetVLCReturn(Stream stream, IJsonSerializer json, ILogger logger)
{
var root = json.DeserializeFromStream<RootObject>(stream);
UtilsHelper.DebugInformation(logger,string.Format("[NextPvr] VLC Return: {0}", json.SerializeToString(root)));
return root.JSONVlcObject.rtn;
}