internal DataContract GetDataContract(Type clrType)
{
#if SUPPORT_SURROGATE
if (_dataContractSurrogate == null)
return DataContract.GetDataContract(clrType);
#endif
DataContract dataContract = DataContract.GetBuiltInDataContract(clrType);
if (dataContract != null)
return dataContract;
#if SUPPORT_SURROGATE
Type dcType = DataContractSurrogateCaller.GetDataContractType(_dataContractSurrogate, clrType);
if (clrType.IsValueType != dcType.IsValueType)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.GetString(SR.ValueTypeMismatchInSurrogatedType, dcType, clrType)));
#endif
Type dcType = clrType;
dataContract = DataContract.GetDataContract(dcType);
#if SUPPORT_SURROGATE
if (!SurrogateDataTable.Contains(dataContract))
{
object customData = DataContractSurrogateCaller.GetCustomDataToExport(
_dataContractSurrogate, clrType, dcType);
if (customData != null)
SurrogateDataTable.Add(dataContract, customData);
}
#endif
return dataContract;
}