private MetaType RecogniseCommonTypes(Type type) { #if !NO_GENERICS if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(System.Collections.Generic.KeyValuePair <,>)) { MetaType mt = new MetaType(this, type); //#pragma warning disable 618 // we're *allowed* to do this; user code isn't (we might roll this as a bespoke serializer rather than a surrogate at some point) Type surrogate = typeof(KeyValuePairSurrogate <,>).MakeGenericType(type.GetGenericArguments()); //#pragma warning restore 618 mt.SetSurrogate(surrogate); mt.IncludeSerializerMethod = false; mt.Freeze(); MetaType surrogateMeta = (MetaType)types[FindOrAddAuto(surrogate, true, true, true)]; // this forcibly adds it if needed if (surrogateMeta.IncludeSerializerMethod) { // don't blindly set - it might be frozen surrogateMeta.IncludeSerializerMethod = false; } surrogateMeta.Freeze(); return(mt); } #endif return(null); }
private MetaType RecogniseCommonTypes(Type type) { #if !NO_GENERICS if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(System.Collections.Generic.KeyValuePair <,>)) { MetaType mt = new MetaType(this, type); Type surrogate = typeof(KeyValuePairSurrogate <,>).MakeGenericType(type.GetGenericArguments()); mt.SetSurrogate(surrogate); mt.IncludeSerializerMethod = false; mt.Freeze(); MetaType surrogateMeta = (MetaType)types[FindOrAddAuto(surrogate, true, true, true)]; // this forcibly adds it if needed if (surrogateMeta.IncludeSerializerMethod) { // don't blindly set - it might be frozen surrogateMeta.IncludeSerializerMethod = false; } surrogateMeta.Freeze(); return(mt); } #endif return(null); }
private MetaType RecogniseCommonTypes(Type type) { #if !NO_GENERICS if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(System.Collections.Generic.KeyValuePair<,>)) { MetaType mt = new MetaType(this, type); Type surrogate = typeof (KeyValuePairSurrogate<,>).MakeGenericType(type.GetGenericArguments()); mt.SetSurrogate(surrogate); mt.IncludeSerializerMethod = false; mt.Freeze(); MetaType surrogateMeta = (MetaType)types[FindOrAddAuto(surrogate, true, true, true)]; // this forcibly adds it if needed if(surrogateMeta.IncludeSerializerMethod) { // don't blindly set - it might be frozen surrogateMeta.IncludeSerializerMethod = false; } surrogateMeta.Freeze(); return mt; } #endif return null; }
private MetaType RecogniseCommonTypes(Type type) { #if !NO_GENERICS if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(System.Collections.Generic.KeyValuePair<,>)) { MetaType mt = new MetaType(this, type); //#pragma warning disable 618 // we're *allowed* to do this; user code isn't (we might roll this as a bespoke serializer rather than a surrogate at some point) Type surrogate = typeof (KeyValuePairSurrogate<,>).MakeGenericType(type.GetGenericArguments()); //#pragma warning restore 618 mt.SetSurrogate(surrogate); mt.IncludeSerializerMethod = false; mt.Freeze(); MetaType surrogateMeta = (MetaType)types[FindOrAddAuto(surrogate, true, true, true)]; // this forcibly adds it if needed if(surrogateMeta.IncludeSerializerMethod) { // don't blindly set - it might be frozen surrogateMeta.IncludeSerializerMethod = false; } surrogateMeta.Freeze(); return mt; } #endif return null; }