internal static bool CanCreateTypeInXaml(IProjectContext projectContext, IType valueTypeId) { if (valueTypeId.PlatformMetadata == projectContext.PlatformMetadata && valueTypeId.RuntimeType != (Type)null) { return(TypeUtilities.CanCreateTypeInXaml((ITypeResolver)projectContext, valueTypeId.RuntimeType)); } return(false); }
private IEnumerable <IType> AllXamlRelevantTypesInAssembly(IAssembly assembly) { IProjectContext project = this.ProjectContext; bool supportInternal = assembly.Equals((object)project.ProjectAssembly); Type[] assemblyTypes = Type.EmptyTypes; try { assemblyTypes = AssemblyHelper.GetTypes(assembly); } catch (ReflectionTypeLoadException ex) { assemblyTypes = Type.EmptyTypes; } IAttachedPropertiesProvider attachedPropertiesProvider = this.AttachedPropertiesProvider; if (attachedPropertiesProvider == null) { throw new NotSupportedException(); } Type[] allTypesWithAttachedProperties = (Type[])null; using (IAttachedPropertiesAccessToken token = attachedPropertiesProvider.AttachedProperties.Access()) { CodeAidProvider.EnsurePreloadKnownAttachedProperties(token, project); allTypesWithAttachedProperties = Enumerable.ToArray <Type>(Enumerable.Select <IGrouping <Type, IAttachedPropertyMetadata>, Type>(Enumerable.GroupBy <IAttachedPropertyMetadata, Type>((IEnumerable <IAttachedPropertyMetadata>)token.AttachedPropertiesForAssembly(assembly.Name), (Func <IAttachedPropertyMetadata, Type>)(property => property.OwnerType)), (Func <IGrouping <Type, IAttachedPropertyMetadata>, Type>)(type => type.Key))); } foreach (Type type3 in assemblyTypes) { IType yieldedTypeId = (IType)null; try { if (!type3.IsGenericType) { if (type3.IsVisible) { if (!type3.IsNested) { if (!typeof(Attribute).IsAssignableFrom(type3)) { if (!typeof(Exception).IsAssignableFrom(type3)) { if (type3.IsPublic) { if (TypeUtilities.HasDefaultConstructor(type3, supportInternal) && TypeUtilities.CanCreateTypeInXaml((ITypeResolver)project, type3)) { IType type1 = project.GetType(type3); if (JoltHelper.TypeSupported((ITypeResolver)project, (ITypeId)type1)) { yieldedTypeId = type1; } } else if (allTypesWithAttachedProperties != null) { if (OrderedListExtensions.GenericBinarySearch <Type, Type>(allTypesWithAttachedProperties, type3, (Func <Type, Type, int>)((type1, type2) => type1.Name.CompareTo(type2.Name))) >= 0) { yieldedTypeId = project.GetType(type3); } } } } } } } } } catch (FileNotFoundException ex) { } if (yieldedTypeId != null) { yield return(yieldedTypeId); } } }