// Token: 0x060020E2 RID: 8418 RVA: 0x00096E2C File Offset: 0x0009502C
        bool IParserHelper.GetElementType(bool extensionFirst, string localName, string namespaceURI, ref string assemblyName, ref string typeFullName, ref Type baseType, ref Type serializerType)
        {
            bool result = false;

            assemblyName   = string.Empty;
            typeFullName   = string.Empty;
            serializerType = null;
            baseType       = null;
            if (namespaceURI == null || localName == null)
            {
                return(false);
            }
            TypeAndSerializer typeAndSerializer = this._xamlTypeMapper.GetTypeAndSerializer(namespaceURI, localName, null);

            if (typeAndSerializer == null)
            {
                typeAndSerializer = this._xamlTypeMapper.GetTypeAndSerializer(namespaceURI, localName + "Extension", null);
            }
            if (typeAndSerializer != null && typeAndSerializer.ObjectType != null)
            {
                serializerType = typeAndSerializer.SerializerType;
                baseType       = typeAndSerializer.ObjectType;
                typeFullName   = baseType.FullName;
                assemblyName   = baseType.Assembly.FullName;
                result         = true;
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// Create a TypeAndSerializer object for the passed data, if a valid Type
        /// is found.
        /// </summary>
        private TypeAndSerializer CreateTypeAndSerializer(
                string    xmlNamespace,     // xml namespace for the type
                string    localName)        // local name of the type without any '.'
        {
            TypeAndSerializer typeAndSerializer = null;
            NamespaceMapEntry[] namespaceMaps = GetNamespaceMapEntries(xmlNamespace);

            if (namespaceMaps != null)
            {
                // We'll do a first pass with only known types
                // and then do a second pass with full reflection
                bool knownTypesOnly = true;
                for (int count = 0; count < namespaceMaps.Length;)
                {
                    NamespaceMapEntry namespaceMap = namespaceMaps[count];
                    if (null != namespaceMap)
                    {
                        Type objectType = GetObjectType(namespaceMap, localName, knownTypesOnly);
                        if (null != objectType)
                        {
                            // A non-public type is never allowable, except for internal types
                            // in local or friend assemblies, so catch it here.
                            if (!ReflectionHelper.IsPublicType(objectType))
                            {
#if PBTCOMPILER
                                // Don't allow internal known types in case we have any.
                                if (knownTypesOnly ||
                                    !ReflectionHelper.IsInternalType(objectType) ||
                                    !IsInternalAllowedOnType(namespaceMap))
#else
                                // Give Full Trust callers a chance to resolve legitimate internal types.
                                // This can be used by tools like designers and localizers running in FT.
                                if (!IsInternalTypeAllowedInFullTrust(objectType))
#endif
                                {
                                    ThrowException(SRID.ParserPublicType, objectType.Name);
                                }
                            }
                            // Create new data structure to store information for the current type
                            typeAndSerializer = new TypeAndSerializer();
                            typeAndSerializer.ObjectType = objectType;

                            break;
                        }
                    }

                    count++;
                    if (knownTypesOnly && (count == namespaceMaps.Length))
                    {
                        // Reset for second pass
                        knownTypesOnly = false;
                        count = 0;
                    }
                }
            }
            return typeAndSerializer;
        }