System.Runtime.Serialization.Json.XmlObjectSerializerWriteContextComplexJson.XmlObjectSerializerWriteContextComplexJson.VerifyObjectCompatibilityWithInterface C# (CSharp) Method

VerifyObjectCompatibilityWithInterface() static private method

static private VerifyObjectCompatibilityWithInterface ( DataContract contract, object graph, Type declaredType ) : void
contract DataContract
graph object
declaredType System.Type
return void
        internal static void VerifyObjectCompatibilityWithInterface(DataContract contract, object graph, Type declaredType)
        {
            Type contractType = contract.GetType();
            if ((contractType == typeof(XmlDataContract)) && !Globals.TypeOfIXmlSerializable.IsAssignableFrom(declaredType))
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.XmlObjectAssignedToIncompatibleInterface, graph.GetType(), declaredType)));
            }

            if ((contractType == typeof(CollectionDataContract)) && !CollectionDataContract.IsCollectionInterface(declaredType))
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.CollectionAssignedToIncompatibleInterface, graph.GetType(), declaredType)));
            }
        }