Exemple #1
0
        private 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 SUPPORT_SURROGATE
                        if (_dataContractSurrogate != null && dataMember.MemberInfo != null)
                        {
                            object customData = DataContractSurrogateCaller.GetCustomDataToExport(
                                _dataContractSurrogate,
                                dataMember.MemberInfo,
                                memberDataContract.UnderlyingType);
                            if (customData != null)
                            {
                                SurrogateDataTable.Add(dataMember, customData);
                            }
                        }
#endif
                        Add(memberDataContract.StableName, memberDataContract);
                    }
                }
            }
            AddKnownDataContracts(classDataContract.KnownDataContracts);
        }
 private void AddClassDataContract(ClassDataContract classDataContract)
 {
     if (classDataContract.BaseContract != null)
     {
         this.Add(classDataContract.BaseContract.StableName, classDataContract.BaseContract);
     }
     if (!classDataContract.IsISerializable && (classDataContract.Members != null))
     {
         for (int i = 0; i < classDataContract.Members.Count; i++)
         {
             DataMember   dataMember             = classDataContract.Members[i];
             DataContract memberTypeDataContract = this.GetMemberTypeDataContract(dataMember);
             if ((this.dataContractSurrogate != null) && (dataMember.MemberInfo != null))
             {
                 object obj2 = DataContractSurrogateCaller.GetCustomDataToExport(this.dataContractSurrogate, dataMember.MemberInfo, memberTypeDataContract.UnderlyingType);
                 if (obj2 != null)
                 {
                     this.SurrogateDataTable.Add(dataMember, obj2);
                 }
             }
             this.Add(memberTypeDataContract.StableName, memberTypeDataContract);
         }
     }
     this.AddKnownDataContracts(classDataContract.KnownDataContracts);
 }
Exemple #3
0
        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);
        }
        internal DataContract GetDataContract(Type clrType)
        {
            if (this.dataContractSurrogate == null)
            {
                return(DataContract.GetDataContract(clrType));
            }
            DataContract builtInDataContract = DataContract.GetBuiltInDataContract(clrType);

            if (builtInDataContract == null)
            {
                Type dataContractType = DataContractSurrogateCaller.GetDataContractType(this.dataContractSurrogate, clrType);
                builtInDataContract = DataContract.GetDataContract(dataContractType);
                if (!this.SurrogateDataTable.Contains(builtInDataContract))
                {
                    object obj2 = DataContractSurrogateCaller.GetCustomDataToExport(this.dataContractSurrogate, clrType, dataContractType);
                    if (obj2 != null)
                    {
                        this.SurrogateDataTable.Add(builtInDataContract, obj2);
                    }
                }
            }
            return(builtInDataContract);
        }
Exemple #5
0
        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);
        }