Esempio n. 1
0
        public XamlType ResolveType(ushort id)
        {
            if (typeMap.TryGetValue(id, out var xamlType))
            {
                return(xamlType);
            }

            IType   type;
            IModule assembly;

            if (id > 0x7fff)
            {
                type     = Baml.KnownThings.Types((KnownTypes)(short)-unchecked ((short)id));
                assembly = type.GetDefinition().ParentModule;
            }
            else
            {
                var typeRec = Baml.TypeIdMap[id];
                assembly = Baml.ResolveAssembly(typeRec.AssemblyId);
                type     = ReflectionHelper.ParseReflectionName(typeRec.TypeFullName).Resolve(new SimpleTypeResolveContext(TypeSystem));
            }

            var clrNs = type.Namespace;
            var xmlNs = XmlNs.LookupXmlns(assembly, clrNs);

            typeMap[id] = xamlType = new XamlType(assembly, clrNs, type.Name, GetXmlNamespace(xmlNs))
            {
                ResolvedType = type
            };

            return(xamlType);
        }
Esempio n. 2
0
        public XamlType ResolveType(ushort id)
        {
            XamlType xamlType;

            if (typeMap.TryGetValue(id, out xamlType))
            {
                return(xamlType);
            }

            ITypeDefOrRef type;
            IAssembly     assembly;

            if (id > 0x7fff)
            {
                type     = Baml.KnownThings.Types((KnownTypes)(-id));
                assembly = type.DefinitionAssembly;
            }
            else
            {
                var typeRec = Baml.TypeIdMap[id];
                assembly = Baml.ResolveAssembly(typeRec.AssemblyId);
                type     = TypeNameParser.ParseReflectionThrow(Module, typeRec.TypeFullName, new DummyAssemblyRefFinder(assembly));
            }

            var clrNs = type.ReflectionNamespace;
            var xmlNs = XmlNs.LookupXmlns(assembly, clrNs);

            typeMap[id] = xamlType = new XamlType(assembly, clrNs, type.ReflectionName, GetXmlNamespace(xmlNs))
            {
                ResolvedType = type
            };

            return(xamlType);
        }
Esempio n. 3
0
        void BuildPIMappings(BamlDocument document)
        {
            foreach (var record in document)
            {
                var piMap = record as PIMappingRecord;
                if (piMap is null)
                {
                    continue;
                }

                XmlNs.SetPIMapping(piMap.XmlNamespace, piMap.ClrNamespace, Baml.ResolveAssembly(piMap.AssemblyId));
            }
        }