internal override Type GetSurrogatedType(Type type)
        {
            if (this.dataContractSurrogate == null)
            {
                return(base.GetSurrogatedType(type));
            }
            type = DataContract.UnwrapNullableType(type);
            Type surrogatedType = DataContractSerializer.GetSurrogatedType(this.dataContractSurrogate, type);

            if (this.IsGetOnlyCollection && (surrogatedType != type))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(System.Runtime.Serialization.SR.GetString("SurrogatesWithGetOnlyCollectionsNotSupportedSerDeser", new object[] { DataContract.GetClrTypeFullName(type) })));
            }
            return(surrogatedType);
        }
Ejemplo n.º 2
0
 internal override Type GetSurrogatedType(Type type)
 {
     if (_serializationSurrogateProvider == null)
     {
         return(base.GetSurrogatedType(type));
     }
     else
     {
         type = DataContract.UnwrapNullableType(type);
         Type surrogateType = DataContractSerializer.GetSurrogatedType(_serializationSurrogateProvider, type);
         if (this.IsGetOnlyCollection && surrogateType != type)
         {
             throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.SurrogatesWithGetOnlyCollectionsNotSupportedSerDeser,
                                                                                                                                               DataContract.GetClrTypeFullName(type))));
         }
         else
         {
             return(surrogateType);
         }
     }
 }