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


C# IJsonSerializer.DeserializeFromStream方法代码示例

本文整理汇总了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};
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:35,代码来源:MBRegistration.cs

示例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>();
        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:25,代码来源:ChannelResponse.cs

示例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};
        }
开发者ID:snap608,项目名称:MediaBrowser,代码行数:27,代码来源:MBRegistration.cs

示例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)));
        }
开发者ID:WWWesten,项目名称:MediaBrowser.Plugins,代码行数:10,代码来源:ListingsResponse.cs

示例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;
        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:11,代码来源:CancelRecordingResponse.cs

示例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.");
        }
开发者ID:WWWesten,项目名称:MediaBrowser.Plugins,代码行数:12,代码来源:InitializeResponse.cs

示例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.");
        }
开发者ID:WWWesten,项目名称:MediaBrowser.Plugins,代码行数:12,代码来源:InstantiateResponse.cs

示例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.");
        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:12,代码来源:VLCResponse.cs

示例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);
        }
开发者ID:SvenVandenbrande,项目名称:Emby.Plugins,代码行数:22,代码来源:RecordingResponse.cs

示例10: ParseRecRules

 private static RecRuleListRoot ParseRecRules(Stream stream, IJsonSerializer json)
 {
     return json.DeserializeFromStream<RecRuleListRoot>(stream);
 }
开发者ID:babgvant,项目名称:Emby.MythTv,代码行数:4,代码来源:DvrResponse.cs

示例11: ParseProgramList

 public static ProgramList ParseProgramList(Stream stream, IJsonSerializer json, ILogger logger)
 {
     var root = json.DeserializeFromStream<RootProgramListObject>(stream);
     return root.ProgramList;
 }
开发者ID:babgvant,项目名称:Emby.MythTv,代码行数:5,代码来源:DvrResponse.cs

示例12: TunerResponse

        public TunerResponse(Stream stream, IJsonSerializer json)
        {
            _root = json.DeserializeFromStream<RootObject>(stream);

        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:5,代码来源:TunerResponse.cs

示例13: ParseRecorded

 internal static Program ParseRecorded(Stream stream, IJsonSerializer json, ILogger logger)
 {
     var root = json.DeserializeFromStream<RootProgramObject>(stream);
     return root.Program;
 }
开发者ID:babgvant,项目名称:Emby.MythTv,代码行数:5,代码来源:DvrResponse.cs

示例14: VersionCheckResponse

        public VersionCheckResponse(Stream stream, IJsonSerializer json)
        {
           _root = json.DeserializeFromStream<RootObject>(stream);

        }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:5,代码来源:VersionCheckResponse.cs

示例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;
 }
开发者ID:Inspirony,项目名称:Emby.Plugins,代码行数:6,代码来源:VLCResponse.cs


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