Ejemplo n.º 1
0
            private XamlType GetInternalType(Type type, XamlType sharedSchemaXamlType)
            {
                lock (syncObject)
                {
                    if (_allowedInternalTypes == null)
                    {
                        _allowedInternalTypes = new Dictionary <Type, XamlType>();
                    }

                    XamlType result;
                    if (!_allowedInternalTypes.TryGetValue(type, out result))
                    {
                        WpfSharedXamlSchemaContext.RequireRuntimeType(type);
                        if (_typeMapper.IsInternalTypeAllowedInFullTrust(type))
                        {
                            // Return a type that claims to be public, so that XXR doesn't filter it out.
                            result = new VisibilityMaskingXamlType(type, _sharedSchemaContext);
                        }
                        else
                        {
                            result = sharedSchemaXamlType ?? _sharedSchemaContext.GetXamlType(type);
                        }
                        _allowedInternalTypes.Add(type, result);
                    }
                    return(result);
                }
            }
Ejemplo n.º 2
0
            internal XamlTypeMapperSchemaContext(XamlTypeMapper typeMapper)
                : base()
            {
                _typeMapper          = typeMapper;
                _sharedSchemaContext = (WpfSharedXamlSchemaContext)XamlReader.GetWpfSchemaContext();

                // Copy all the NamespaceMapEntrys from our parent into _nsDefinitions
                if (typeMapper._namespaceMaps != null)
                {
                    _nsDefinitions = new Dictionary <string, FrugalObjectList <string> >();
                    foreach (NamespaceMapEntry mapEntry in _typeMapper._namespaceMaps)
                    {
                        FrugalObjectList <string> clrNsList;
                        if (!_nsDefinitions.TryGetValue(mapEntry.XmlNamespace, out clrNsList))
                        {
                            clrNsList = new FrugalObjectList <string>(1);
                            _nsDefinitions.Add(mapEntry.XmlNamespace, clrNsList);
                        }
                        string clrNs = GetClrNsUri(mapEntry.ClrNamespace, mapEntry.AssemblyName);
                        clrNsList.Add(clrNs);
                    }
                }

                // Copy all the PIs from our parent into _piNamespaces
                if (typeMapper.PITable.Count > 0)
                {
                    _piNamespaces = new Dictionary <string, string>(typeMapper.PITable.Count);
                    foreach (DictionaryEntry entry in typeMapper.PITable)
                    {
                        ClrNamespaceAssemblyPair pair = (ClrNamespaceAssemblyPair)entry.Value;
                        string clrNs = GetClrNsUri(pair.ClrNamespace, pair.AssemblyName);
                        _piNamespaces.Add((string)entry.Key, clrNs);
                    }
                }

                _clrNamespaces = new HashSet <string>();
            }