Example #1
0
        private object Convert(ODataCollectionReader reader, IEdmCollectionTypeReference collectionType, ODataDeserializerContext readContext)
        {
            IEdmTypeReference elementType = collectionType.ElementType();
            Type  clrElementType          = EdmLibHelpers.GetClrType(elementType, readContext.Model);
            IList list = Activator.CreateInstance(typeof(List <>).MakeGenericType(clrElementType)) as IList;

            while (reader.Read())
            {
                switch (reader.State)
                {
                case ODataCollectionReaderState.Value:
                    object element = Convert(reader.Item, elementType, readContext);
                    list.Add(element);
                    break;

                default:
                    break;
                }
            }
            return(list);
        }
        internal static ODataCollectionValue ReadCollection(ODataCollectionReader reader)
        {
            ArrayList items    = new ArrayList();
            string    typeName = null;

            while (reader.Read())
            {
                if (ODataCollectionReaderState.Value == reader.State)
                {
                    items.Add(reader.Item);
                }
                else if (ODataCollectionReaderState.CollectionStart == reader.State)
                {
                    typeName = reader.Item.ToString();
                }
            }

            return(new ODataCollectionValue {
                Items = items, TypeName = typeName
            });
        }
Example #3
0
        public static ODataCollectionValue ReadCollectionParameterValue(ODataCollectionReader collectionReader)
        {
            List <object> collectionItems = new List <object>();

            while (collectionReader.Read())
            {
                if (collectionReader.State == ODataCollectionReaderState.Completed)
                {
                    break;
                }

                if (collectionReader.State == ODataCollectionReaderState.Value)
                {
                    collectionItems.Add(collectionReader.Item);
                }
            }

            ODataCollectionValue result = new ODataCollectionValue();

            result.Items = collectionItems;
            return(result);
        }
Example #4
0
        private static ODataCollectionValue ReadCollection(ODataCollectionReader collectionReader)
        {
            var items = new List <Object>();

            while (collectionReader.Read())
            {
                if (collectionReader.State == ODataCollectionReaderState.Completed)
                {
                    break;
                }

                if (collectionReader.State == ODataCollectionReaderState.Value)
                {
                    items.Add(collectionReader.Item);
                }
            }

            return(new ODataCollectionValue()
            {
                Items = items
            });
        }
        private ODataCollectionValue ReadCollection(ODataMessageReader messageReader)
        {
            Contract.Assert(messageReader != null);

            ODataCollectionReader reader = messageReader.CreateODataCollectionReader(_edmCollectionType.ElementType());
            ArrayList             items  = new ArrayList();
            string typeName = null;

            while (reader.Read())
            {
                if (ODataCollectionReaderState.Value == reader.State)
                {
                    items.Add(reader.Item);
                }
                else if (ODataCollectionReaderState.CollectionStart == reader.State)
                {
                    typeName = reader.Item.ToString();
                }
            }

            return(new ODataCollectionValue {
                Items = items, TypeName = typeName
            });
        }