Exemplo n.º 1
0
        /// <summary>Enables users to map a xsi:type name to any type.</summary>
        /// <returns>Type: Returns_Type
        /// The type the xsi:type name and namespace is mapped to.</returns>
        /// <param name="typeNamespace">Returns_String. The xsi:type namespace to map.</param>
        /// <param name="typeName">Returns_String. The xsi:type name to map.</param>
        /// <param name="declaredType">Returns_Type. The type declared in the data contract.</param>
        /// <param name="knownTypeResolver">System.Runtime.Serialization.DataContractResolverhttp://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractresolver.aspx. The known type resolver.</param>
        public override Type ResolveName(
            string typeName,
            string typeNamespace,
            Type declaredType,
            DataContractResolver knownTypeResolver)
        {
            Type type = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, (DataContractResolver)null);

            if (type == (Type)null)
            {
                string key = KnownTypesProvider.QualifiedName(typeName, typeNamespace);
                Dictionary <string, Type> requestResponseTypes = KnownTypesProvider.KnownOrganizationRequestResponseTypes;
                if (requestResponseTypes.ContainsKey(key))
                {
                    return(requestResponseTypes[key]);
                }
                KnownTypesProvider.KnownCustomValueTypes?.TryGetValue(typeName, out type);
            }
            return(type);
        }