Пример #1
0
        private IEnumerable <KeyValuePair <object, SyndicationItem> > ConvertDataItems(OpdsData data)
        {
            // Assuming every item is of different type.
            // PropertyAdapter should be retreived for every item.
            foreach (var item in data.Data ?? new IOpdsDataTypeHost[] { })
            {
                var accessor = AccessorFactory.GetAccessor(item);
                var dataType = TypeDetector.DetectType(item);
                if (dataType == OpdsDataType.Category)
                {
                    var syndicationItem = CreateBasicDataItems(accessor, item);
                    var navigationLink  = LinkGenerator.Generate(item, OpdsRelations.Alternate, OpdsMediaType.NavigationFeed, accessor, Names);
                    if (navigationLink != null)
                    {
                        var count = item.GetProperty(Names.Count, accessor);
                        if (count != null)
                        {
                            navigationLink.Count = Convert.ToInt32(count);
                        }
                        syndicationItem.Links.Add(navigationLink);
                    }
                    OnSyndicationItemCreated(syndicationItem, item);

                    yield return(new KeyValuePair <object, SyndicationItem>(item, syndicationItem));
                }
                else
                {
                    yield return(new KeyValuePair <object, SyndicationItem>(item, BuildEntity(data, accessor, item, dataType == OpdsDataType.Detial)));
                }
            }
        }