src/Shared/EntityFramework/Core/Objects/ProxyDataContractResolver.cs
/// <summary>During serialization, maps actual types to xsi:type information.</summary>
/// <returns>true if the type was resolved; otherwise, false.  </returns>
/// <param name="type">The actual type of the persistence-ignorant object.</param>
/// <param name="declaredType">The declared type.</param>
/// <param name="knownTypeResolver">
/// An instance of <see cref="T:System.Data.Entity.Core.Objects.ProxyDataContractResolver" />.
/// </param>
/// <param name="typeName">When this method returns, contains a list of xsi:type declarations.</param>
/// <param name="typeNamespace">When this method returns, contains a list of namespaces used.</param>
During serialization, maps actual types to xsi:type information.
During serialization maps actual types to xsi : type information .
public override bool TryResolveType(
            Type type, Type declaredType, DataContractResolver knownTypeResolver, out XmlDictionaryString typeName,
            out XmlDictionaryString typeNamespace)
        {
            Check.NotNull(type, "type");
            Check.NotNull(declaredType, "declaredType");
            Check.NotNull(knownTypeResolver, "knownTypeResolver");
            var nonProxyType = ObjectContext.GetObjectType(type);
            if (nonProxyType != type)
            {
                var qualifiedName = _exporter.GetSchemaTypeName(nonProxyType);
                var dictionary = new XmlDictionary(2);
                typeName = new XmlDictionaryString(dictionary, qualifiedName.Name, 0);
                typeNamespace = new XmlDictionaryString(dictionary, qualifiedName.Namespace, 1);
                return true;
            }
            else
            {
                return knownTypeResolver.TryResolveType(type, declaredType, null, out typeName, out typeNamespace);
            }
        }
public override bool TryResolveType ( Type type , Type declaredType , DataContractResolver knownTypeResolver , out XmlDictionaryString typeName , out XmlDictionaryString typeNamespace ) { Check . NotNull ( type , " " ) ; Check . NotNull ( declaredType , " " ) ; Check . NotNull ( knownTypeResolver , " " ) ; var nonProxyType = ObjectContext . GetObjectType ( type ) ; if ( nonProxyType != type ) { var qualifiedName = _exporter . GetSchemaTypeName ( nonProxyType ) ; var dictionary = new XmlDictionary ( 2 ) ; typeName = new XmlDictionaryString ( dictionary , qualifiedName . Name , 0 ) ; typeNamespace = new XmlDictionaryString ( dictionary , qualifiedName . Namespace , 1 ) ; return true ; } else { return knownTypeResolver . TryResolveType ( type , declaredType , null , out typeName , out typeNamespace ) ; } }
During serialization, maps actual types to xsi:type information.
During serialization maps actual types to xsi : type information .
// Type was a proxy type, so map the name to the non-proxy name // Type was not a proxy type, so do the default
true if the type was resolved; otherwise, false.
true if the type was resolved ; otherwise false .
type
Type
The actual type of the persistence-ignorant object.
The actual type of the persistence - ignorant object .
declaredType
Type
The declared type.
The declared type .
knownTypeResolver
DataContractResolver
An instance of .
An instance of .
XmlDictionaryString
out
typeName
When this method returns, contains a list of xsi:type declarations.
When this method returns contains a list of xsi : type declarations .
typeNamespace
When this method returns, contains a list of namespaces used.
When this method returns contains a list of namespaces used .