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


C# IDataReader.GetMemoryStream方法代码示例

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


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

示例1: GetItem

        private BaseItem GetItem(IDataReader reader)
        {
            var typeString = reader.GetString(0);

            var type = _typeMapper.GetType(typeString);

            if (type == null)
            {
                _logger.Debug("Unknown type {0}", typeString);

                return null;
            }

            BaseItem item;

            using (var stream = reader.GetMemoryStream(1))
            {
                try
                {
                    item = _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;

                    if (item == null)
                    {
                        return null;
                    }
                }
                catch (SerializationException ex)
                {
                    _logger.ErrorException("Error deserializing item", ex);
                    return null;
                }
            }

            if (!reader.IsDBNull(2))
            {
                var hasStartDate = item as IHasStartDate;
                if (hasStartDate != null)
                {
                    hasStartDate.StartDate = reader.GetDateTime(2).ToUniversalTime();
                }
            }

            if (!reader.IsDBNull(3))
            {
                item.EndDate = reader.GetDateTime(3).ToUniversalTime();
            }

            if (!reader.IsDBNull(4))
            {
                item.IsOffline = reader.GetBoolean(4);
            }

            if (!reader.IsDBNull(5))
            {
                item.ChannelId = reader.GetString(5);
            }

            var hasProgramAttributes = item as IHasProgramAttributes;
            if (hasProgramAttributes != null)
            {
                if (!reader.IsDBNull(6))
                {
                    hasProgramAttributes.IsMovie = reader.GetBoolean(6);
                }

                if (!reader.IsDBNull(7))
                {
                    hasProgramAttributes.IsSports = reader.GetBoolean(7);
                }

                if (!reader.IsDBNull(8))
                {
                    hasProgramAttributes.IsKids = reader.GetBoolean(8);
                }

                if (!reader.IsDBNull(9))
                {
                    hasProgramAttributes.IsSeries = reader.GetBoolean(9);
                }

                if (!reader.IsDBNull(10))
                {
                    hasProgramAttributes.IsLive = reader.GetBoolean(10);
                }

                if (!reader.IsDBNull(11))
                {
                    hasProgramAttributes.IsNews = reader.GetBoolean(11);
                }

                if (!reader.IsDBNull(12))
                {
                    hasProgramAttributes.IsPremiere = reader.GetBoolean(12);
                }

                if (!reader.IsDBNull(13))
                {
                    hasProgramAttributes.EpisodeTitle = reader.GetString(13);
                }

//.........这里部分代码省略.........
开发者ID:RavenB,项目名称:Emby,代码行数:101,代码来源:SqliteItemRepository.cs

示例2: GetItem

        private BaseItem GetItem(IDataReader reader)
        {
            var typeString = reader.GetString(0);

            var type = _typeMapper.GetType(typeString);

            if (type == null)
            {
                _logger.Debug("Unknown type {0}", typeString);

                return null;
            }

            BaseItem item;

            using (var stream = reader.GetMemoryStream(1))
            {
                try
                {
                    item = _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;

                    if (item == null)
                    {
                        return null;
                    }
                }
                catch (SerializationException ex)
                {
                    _logger.ErrorException("Error deserializing item", ex);
                    return null;
                }
            }

            if (!reader.IsDBNull(2))
            {
                item.IsOffline = reader.GetBoolean(2);
            }

            return item;
        }
开发者ID:raven-au,项目名称:Emby,代码行数:40,代码来源:SqliteItemRepository.cs

示例3: GetItem

        private BaseItem GetItem(IDataReader reader)
        {
            var typeString = reader.GetString(0);

            var type = _typeMapper.GetType(typeString);

            if (type == null)
            {
                _logger.Debug("Unknown type {0}", typeString);

                return null;
            }

            using (var stream = reader.GetMemoryStream(1))
            {
                try
                {
                    return _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;
                }
                catch (SerializationException ex)
                {
                    _logger.ErrorException("Error deserializing item", ex);
                    return null;
                }
            }
        }
开发者ID:redteamcpu,项目名称:Emby,代码行数:26,代码来源:SqliteItemRepository.cs

示例4: GetItem

        private BaseItem GetItem(IDataReader reader)
        {
            var typeString = reader.GetString(0);

            var type = _typeMapper.GetType(typeString);

            if (type == null)
            {
                Logger.Debug("Unknown type {0}", typeString);

                return null;
            }

            BaseItem item = null;

            using (var stream = reader.GetMemoryStream(1))
            {
                try
                {
                    item = _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;
                }
                catch (SerializationException ex)
                {
                    Logger.ErrorException("Error deserializing item", ex);
                }

                if (item == null)
                {
                    try
                    {
                        item = Activator.CreateInstance(type) as BaseItem;
                    }
                    catch
                    {
                    }
                }

                if (item == null)
                {
                    return null;
                }
            }

            if (!reader.IsDBNull(2))
            {
                var hasStartDate = item as IHasStartDate;
                if (hasStartDate != null)
                {
                    hasStartDate.StartDate = reader.GetDateTime(2).ToUniversalTime();
                }
            }

            if (!reader.IsDBNull(3))
            {
                item.EndDate = reader.GetDateTime(3).ToUniversalTime();
            }

            if (!reader.IsDBNull(4))
            {
                item.IsOffline = reader.GetBoolean(4);
            }

            if (!reader.IsDBNull(5))
            {
                item.ChannelId = reader.GetString(5);
            }

            var hasProgramAttributes = item as IHasProgramAttributes;
            if (hasProgramAttributes != null)
            {
                if (!reader.IsDBNull(6))
                {
                    hasProgramAttributes.IsMovie = reader.GetBoolean(6);
                }

                if (!reader.IsDBNull(7))
                {
                    hasProgramAttributes.IsSports = reader.GetBoolean(7);
                }

                if (!reader.IsDBNull(8))
                {
                    hasProgramAttributes.IsKids = reader.GetBoolean(8);
                }

                if (!reader.IsDBNull(9))
                {
                    hasProgramAttributes.IsSeries = reader.GetBoolean(9);
                }

                if (!reader.IsDBNull(10))
                {
                    hasProgramAttributes.IsLive = reader.GetBoolean(10);
                }

                if (!reader.IsDBNull(11))
                {
                    hasProgramAttributes.IsNews = reader.GetBoolean(11);
                }

//.........这里部分代码省略.........
开发者ID:paul-777,项目名称:Emby,代码行数:101,代码来源:SqliteItemRepository.cs

示例5: GetItem

        private BaseItem GetItem(IDataReader reader)
        {
            var typeString = reader.GetString(0);

            var type = _typeMapper.GetType(typeString);

            if (type == null)
            {
                _logger.Debug("Unknown type {0}", typeString);

                return null;
            }

            using (var stream = reader.GetMemoryStream(1))
            {
                return _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;
            }
        }
开发者ID:bigjohn322,项目名称:MediaBrowser,代码行数:18,代码来源:SqliteItemRepository.cs

示例6: GetItem

        private BaseItem GetItem(IDataReader reader, InternalItemsQuery query)
        {
            var typeString = reader.GetString(0);

            var type = _typeMapper.GetType(typeString);

            if (type == null)
            {
                //Logger.Debug("Unknown type {0}", typeString);

                return null;
            }

            BaseItem item = null;

            if (TypeRequiresDeserialization(type))
            {
                using (var stream = reader.GetMemoryStream(1, _memoryStreamProvider))
                {
                    try
                    {
                        item = _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;
                    }
                    catch (SerializationException ex)
                    {
                        Logger.ErrorException("Error deserializing item", ex);
                    }
                }
            }

            if (item == null)
            {
                try
                {
                    item = Activator.CreateInstance(type) as BaseItem;
                }
                catch
                {
                }
            }

            if (item == null)
            {
                return null;
            }

            if (!reader.IsDBNull(2))
            {
                var hasStartDate = item as IHasStartDate;
                if (hasStartDate != null)
                {
                    hasStartDate.StartDate = reader.GetDateTime(2).ToUniversalTime();
                }
            }

            if (!reader.IsDBNull(3))
            {
                item.EndDate = reader.GetDateTime(3).ToUniversalTime();
            }

            if (!reader.IsDBNull(4))
            {
                item.IsOffline = reader.GetBoolean(4);
            }

            if (!reader.IsDBNull(5))
            {
                item.ChannelId = reader.GetString(5);
            }

            var hasProgramAttributes = item as IHasProgramAttributes;
            if (hasProgramAttributes != null)
            {
                if (!reader.IsDBNull(6))
                {
                    hasProgramAttributes.IsMovie = reader.GetBoolean(6);
                }

                if (!reader.IsDBNull(7))
                {
                    hasProgramAttributes.IsSports = reader.GetBoolean(7);
                }

                if (!reader.IsDBNull(8))
                {
                    hasProgramAttributes.IsKids = reader.GetBoolean(8);
                }

                if (!reader.IsDBNull(9))
                {
                    hasProgramAttributes.IsSeries = reader.GetBoolean(9);
                }

                if (!reader.IsDBNull(10))
                {
                    hasProgramAttributes.IsLive = reader.GetBoolean(10);
                }

                if (!reader.IsDBNull(11))
                {
//.........这里部分代码省略.........
开发者ID:t-andre,项目名称:Emby,代码行数:101,代码来源:SqliteItemRepository.cs


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