internal DataContract GetDataContract(Type clrType) { if (dataContractSurrogate == null) { return(DataContract.GetDataContract(clrType)); } DataContract dataContract = DataContract.GetBuiltInDataContract(clrType); if (dataContract != null) { return(dataContract); } Type dcType = DataContractSurrogateCaller.GetDataContractType(dataContractSurrogate, clrType); //if (clrType.IsValueType != dcType.IsValueType) // throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.GetString(SR.ValueTypeMismatchInSurrogatedType, dcType, clrType))); dataContract = DataContract.GetDataContract(dcType); if (!SurrogateDataTable.Contains(dataContract)) { object customData = DataContractSurrogateCaller.GetCustomDataToExport( dataContractSurrogate, clrType, dcType); if (customData != null) { SurrogateDataTable.Add(dataContract, customData); } } return(dataContract); }
void AddClassDataContract(ClassDataContract classDataContract) { if (classDataContract.BaseContract != null) { Add(classDataContract.BaseContract.StableName, classDataContract.BaseContract); } if (!classDataContract.IsISerializable) { if (classDataContract.Members != null) { for (int i = 0; i < classDataContract.Members.Count; i++) { DataMember dataMember = classDataContract.Members[i]; DataContract memberDataContract = GetMemberTypeDataContract(dataMember); if (dataContractSurrogate != null && dataMember.MemberInfo != null) { object customData = DataContractSurrogateCaller.GetCustomDataToExport( dataContractSurrogate, dataMember.MemberInfo, memberDataContract.UnderlyingType); if (customData != null) { SurrogateDataTable.Add(dataMember, customData); } } Add(memberDataContract.StableName, memberDataContract); } } } AddKnownDataContracts(classDataContract.KnownDataContracts); }