/// <summary> /// Reads the generic collection. /// </summary> public object ReadGeneric(PortableReaderImpl reader) { Debug.Assert(reader != null); Debug.Assert(_readFunc != null); return(_readFunc(reader, null)); }
/** * <summary>Read dictionary.</summary> */ private static object ReadDictionary(PortableReaderImpl ctx, Type type) { PortableCollectionInfo info = PortableCollectionInfo.Info(type); return(info.IsGenericDictionary ? info.ReadGeneric(ctx) : PortableUtils.ReadDictionary(ctx, null)); }
/// <summary> /// Reads an object of predefined type. /// </summary> public static T ReadSystemType <T>(byte typeId, PortableReaderImpl ctx) { var handler = ReadHandlers[typeId]; Debug.Assert(handler != null, "Cannot find predefined read handler: " + typeId); return(handler.Read <T>(ctx)); }
/** <inheritdoc /> */ public T Read <T>(PortableReaderImpl ctx) { // Can't use "as" because of variance. // For example, IPortableSystemReader<byte[]> can be cast to IPortableSystemReader<sbyte[]>, which // will cause incorrect behavior. if (typeof(T) == typeof(T2)) { return(((IPortableSystemReader <T>) this).Read(ctx)); } return(TypeCaster <T> .Cast(_readDelegate1(ctx.Stream))); }
/** <inheritdoc /> */ public object ReadInstance(PortableReaderImpl reader) { return(_ctor(reader)); }
/** <inheritdoc /> */ T2 IPortableSystemReader <T2> .Read(PortableReaderImpl ctx) { return(_readDelegate2(ctx.Stream)); }
public TResult Read <TResult>(PortableReaderImpl ctx) { return(TypeCaster <TResult> .Cast(PortableUtils.ReadGenericArray <T>(ctx, false))); }
/** <inheritdoc /> */ public T Read <T>(PortableReaderImpl ctx) { return((T)_readDelegate(ctx, typeof(T))); }
/** * <summary>Read map entry.</summary> */ private static object ReadMapEntry(PortableReaderImpl ctx, Type type) { return(PortableUtils.ReadMapEntry(ctx)); }
/** * <summary>Read array.</summary> */ private static object ReadArray(PortableReaderImpl ctx, Type type) { var elemType = type.IsArray ? type.GetElementType() : typeof(object); return(PortableUtils.ReadArray(ctx, true, elemType)); }
/** * <summary>Read enum array.</summary> */ private static object ReadEnumArray(PortableReaderImpl ctx, Type type) { return(PortableUtils.ReadArray(ctx, true, type.GetElementType())); }