Example #1
0
 internal override bool WriteClrTypeInfo(XmlWriterDelegator xmlWriter, Type dataContractType, SerializationInfo serInfo)
 {
     if (mode == SerializationMode.SharedType)
     {
         NetDataContractSerializer.WriteClrTypeInfo(xmlWriter, dataContractType, binder, serInfo);
         return(true);
     }
     return(false);
 }
Example #2
0
 internal override bool WriteClrTypeInfo(XmlWriterDelegator xmlWriter, Type dataContractType, string clrTypeName, string clrAssemblyName)
 {
     if (mode == SerializationMode.SharedType)
     {
         NetDataContractSerializer.WriteClrTypeInfo(xmlWriter, dataContractType, binder, clrTypeName, clrAssemblyName);
         return(true);
     }
     return(false);
 }
Example #3
0
 internal XmlObjectSerializerWriteContextComplex(NetDataContractSerializer serializer, Hashtable surrogateDataContracts)
     : base(serializer)
 {
     mode = SerializationMode.SharedType;
     preserveObjectReferences = true;
     streamingContext         = serializer.Context;
     binder                      = serializer.Binder;
     surrogateSelector           = serializer.SurrogateSelector;
     this.surrogateDataContracts = surrogateDataContracts;
 }
        internal override DataContract GetDataContract(RuntimeTypeHandle typeHandle, Type type)
        {
            DataContract dataContract = null;

            if (mode == SerializationMode.SharedType && surrogateSelector != null)
            {
                dataContract = NetDataContractSerializer.GetDataContractFromSurrogateSelector(surrogateSelector, GetStreamingContext(), typeHandle, type, ref surrogateDataContracts);
            }

            if (dataContract != null)
            {
                if (IsGetOnlyCollection && dataContract is SurrogateDataContract)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new System.Runtime.Serialization.InvalidDataContractException(SR.Format(SR.SurrogatesWithGetOnlyCollectionsNotSupportedSerDeser,
                                                                                                                                                      DataContract.GetClrTypeFullName(dataContract.UnderlyingType))));
                }
                return(dataContract);
            }

            return(base.GetDataContract(typeHandle, type));
        }
 protected XmlObjectSerializerWriteContext(NetDataContractSerializer serializer)
     : base(serializer)
 {
     unsafeTypeForwardingEnabled = NetDataContractSerializer.UnsafeTypeForwardingEnabled;
 }
 internal static XmlObjectSerializerWriteContext CreateContext(NetDataContractSerializer serializer, Hashtable surrogateDataContracts)
 {
     return(new XmlObjectSerializerWriteContextComplex(serializer, surrogateDataContracts));
 }