private Type GetTypeFromCode(string typeCode)
        {
            RuntimeTypeHandle typeHandle;

            if (!this._typeHandleMap.TryGetValue(typeCode, out typeHandle))
            {
                SerializationExceptions.ThrowSerializationException(
                    String.Format(CultureInfo.CurrentCulture, "Unknown type {0}.", StringEscape.ForDisplay(typeCode))
                    );
            }

            return(Type.GetTypeFromHandle(typeHandle));
        }
Esempio n. 2
0
        protected internal override T UnpackFromCore(Unpacker unpacker)
        {
            return
                (TypeInfoEncoder.Decode(
                     unpacker,
                     u =>
            {
                var typeCode = u.LastReadData.AsString();

                RuntimeTypeHandle typeHandle;
                if (!this._typeHandleMap.TryGetValue(typeCode, out typeHandle))
                {
                    throw new SerializationException(
                        String.Format(CultureInfo.CurrentCulture, "Unknown type {0}.", StringEscape.ForDisplay(typeCode))
                        );
                }

                return Type.GetTypeFromHandle(typeHandle);
            },
                     (t, u) => ( T )this.GetActualTypeSerializer(t).UnpackFrom(u)
                     ));
        }