protected override XamlType GetXamlType(string xamlNamespace, string name, params XamlType[] typeArguments) { if (!string.IsNullOrEmpty(this.localAssemblyNsPostfix) && IsClrNamespaceWithNoAssembly(xamlNamespace)) { xamlNamespace = AddLocalAssembly(xamlNamespace); } var xamlType = base.GetXamlType(xamlNamespace, name, typeArguments); if (xamlType == null && environmentAssembliesLoaded == false && editingContext != null) { // Failed to find the type, this might because the namespace is a custom namespace // and the dependent assembly hasn't been loaded yet. Load all dependent assemblies // and try to load the same xaml type again. AssemblyContextControlItem assemblyItem = this.editingContext.Items.GetValue <AssemblyContextControlItem>(); var environmentAssemblies = assemblyItem.GetEnvironmentAssemblies(null); if (assemblyItem.LocalAssemblyName != null) { AssemblyContextControlItem.GetAssembly(assemblyItem.LocalAssemblyName, null); } environmentAssembliesLoaded = true; xamlType = base.GetXamlType(xamlNamespace, name, typeArguments); } if (xamlType == null || xamlType.UnderlyingType == null || this.editingContext == null) { return(xamlType); } MultiTargetingSupportService multiTargetingService = editingContext.Services.GetService <IMultiTargetingSupportService>() as MultiTargetingSupportService; DesignerConfigurationService config = editingContext.Services.GetService <DesignerConfigurationService>(); if (multiTargetingService == null || config == null) { return(xamlType); } // do not filter out new types and new properties if targeting to current framework and it's a full SKU if (config.TargetFrameworkName.Version == CurrentFramework.Version && config.TargetFrameworkName.IsFullProfile()) { return(xamlType); } // Filter out new types and new properties if (this.resolverCache == null) { this.resolverCache = new ResolverCache(); } if (supportedTypes.Contains(xamlType.UnderlyingType)) { return(xamlType); } // only check if conversion is needed when target framework is less than 4.5 if (config.TargetFrameworkName.Version < CurrentFramework.Version) { if (conversionRequiredTypes.Contains(xamlType.UnderlyingType)) { this.ContainsConversionRequiredType = true; return(xamlType); } } ResolverResult resolverResult = this.resolverCache.Lookup(xamlType.UnderlyingType); if (resolverResult == null) { resolverResult = MultiTargetingTypeResolver.Resolve(multiTargetingService, xamlType.UnderlyingType); this.resolverCache.Update(xamlType.UnderlyingType, resolverResult); } return(MultiTargetingTypeResolver.GetXamlType(resolverResult, xamlType)); }
protected override XamlType GetXamlType(string xamlNamespace, string name, params XamlType[] typeArguments) { if (!string.IsNullOrEmpty(this.localAssemblyNsPostfix) && IsClrNamespaceWithNoAssembly(xamlNamespace)) { xamlNamespace = AddLocalAssembly(xamlNamespace); } var xamlType = base.GetXamlType(xamlNamespace, name, typeArguments); if (xamlType == null && environmentAssembliesLoaded == false && editingContext != null) { // Failed to find the type, this might because the namespace is a custom namespace // and the dependent assembly hasn't been loaded yet. Load all dependent assemblies // and try to load the same xaml type again. AssemblyContextControlItem assemblyItem = this.editingContext.Items.GetValue<AssemblyContextControlItem>(); var environmentAssemblies = assemblyItem.GetEnvironmentAssemblies(null); if (assemblyItem.LocalAssemblyName != null) { AssemblyContextControlItem.GetAssembly(assemblyItem.LocalAssemblyName, null); } environmentAssembliesLoaded = true; xamlType = base.GetXamlType(xamlNamespace, name, typeArguments); } if (xamlType == null || xamlType.UnderlyingType == null || this.editingContext == null) { return xamlType; } MultiTargetingSupportService multiTargetingService = editingContext.Services.GetService<IMultiTargetingSupportService>() as MultiTargetingSupportService; DesignerConfigurationService config = editingContext.Services.GetService<DesignerConfigurationService>(); if (multiTargetingService == null || config == null) { return xamlType; } // do not filter out new types and new properties if targeting to current framework and it's a full SKU if (config.TargetFrameworkName.Version == CurrentFramework.Version && config.TargetFrameworkName.IsFullProfile()) { return xamlType; } // Filter out new types and new properties if (this.resolverCache == null) { this.resolverCache = new ResolverCache(); } if (supportedTypes.Contains(xamlType.UnderlyingType)) { return xamlType; } // only check if conversion is needed when target framework is less than 4.5 if (config.TargetFrameworkName.Version < CurrentFramework.Version) { if (conversionRequiredTypes.Contains(xamlType.UnderlyingType)) { this.ContainsConversionRequiredType = true; return xamlType; } } ResolverResult resolverResult = this.resolverCache.Lookup(xamlType.UnderlyingType); if (resolverResult == null) { resolverResult = MultiTargetingTypeResolver.Resolve(multiTargetingService, xamlType.UnderlyingType); this.resolverCache.Update(xamlType.UnderlyingType, resolverResult); } return MultiTargetingTypeResolver.GetXamlType(resolverResult, xamlType); }