Ejemplo n.º 1
0
        public IEnumerable <ICodeAidTypeInfo> GetAttachedPropertyTypesInClrNamespace(string assembly, string namespaceName)
        {
            IProjectContext project = this.ProjectContext;

            if (string.IsNullOrEmpty(assembly))
            {
                assembly = this.ProjectContext.ProjectAssembly.Name;
            }
            IAttachedPropertiesProvider propertiesProvider = this.AttachedPropertiesProvider;

            if (propertiesProvider == null)
            {
                throw new NotSupportedException();
            }
            using (IAttachedPropertiesAccessToken propertiesAccessToken = propertiesProvider.AttachedProperties.Access())
                return(Enumerable.Select <IGrouping <Type, IAttachedPropertyMetadata>, ICodeAidTypeInfo>(Enumerable.GroupBy <IAttachedPropertyMetadata, Type>((IEnumerable <IAttachedPropertyMetadata>)propertiesAccessToken.AttachedPropertiesForAssemblyAndNamespace(assembly, namespaceName), (Func <IAttachedPropertyMetadata, Type>)(property => property.OwnerType)), (Func <IGrouping <Type, IAttachedPropertyMetadata>, ICodeAidTypeInfo>)(typeGroup => (ICodeAidTypeInfo) new CodeAidTypeInfo(this, project.GetType(typeGroup.Key)))));
        }
Ejemplo n.º 2
0
        private IEnumerable <IType> GetAllAttachedPropertyTypesInProject()
        {
            IProjectContext             project            = this.ProjectContext;
            IAttachedPropertiesProvider propertiesProvider = this.AttachedPropertiesProvider;

            if (propertiesProvider == null)
            {
                throw new NotSupportedException();
            }
            using (IAttachedPropertiesAccessToken token = propertiesProvider.AttachedProperties.Access())
            {
                CodeAidProvider.EnsurePreloadKnownAttachedProperties(token, project);
                return((IEnumerable <IType>)Enumerable.ToArray <IType>(Enumerable.Select(Enumerable.Where(Enumerable.Select(Enumerable.GroupBy <IAttachedPropertyMetadata, Type>((IEnumerable <IAttachedPropertyMetadata>)token.AllAttachedProperties(), (Func <IAttachedPropertyMetadata, Type>)(property => property.OwnerType)), typeGroup => new
                {
                    typeGroup = typeGroup,
                    type = project.GetType(typeGroup.Key)
                }), param0 => param0.type != null), param0 => param0.type)));
            }
        }
Ejemplo n.º 3
0
        public IEnumerable <ICodeAidMemberInfo> FilteredAttachedProperties(ICodeAidTypeInfo parentTypeInfo, IEnumerable <ICodeAidTypeInfo> ancestorTypeInfos)
        {
            if (parentTypeInfo == null)
            {
                return(Enumerable.Empty <ICodeAidMemberInfo>());
            }
            IAttachedPropertiesProvider propertiesProvider = this.AttachedPropertiesProvider;

            if (propertiesProvider == null)
            {
                throw new NotSupportedException();
            }
            using (IAttachedPropertiesAccessToken propertiesAccessToken = propertiesProvider.AttachedProperties.Access())
            {
                CodeAidTypeInfo    realParentTypeInfo    = parentTypeInfo as CodeAidTypeInfo;
                IEnumerable <Type> realAncestorTypeInfos = ancestorTypeInfos != null?Enumerable.Select <CodeAidTypeInfo, Type>(Enumerable.Cast <CodeAidTypeInfo>((IEnumerable)ancestorTypeInfos), (Func <CodeAidTypeInfo, Type>)(ti => ti.type.RuntimeType)) : (IEnumerable <Type>)null;

                return(Enumerable.Cast <ICodeAidMemberInfo>((IEnumerable)Enumerable.Select <IAttachedPropertyMetadata, CodeAidAttachedPropertyInfo>(Enumerable.Where <IAttachedPropertyMetadata>((IEnumerable <IAttachedPropertyMetadata>)propertiesAccessToken.AttachedPropertiesForType(this.type), (Func <IAttachedPropertyMetadata, bool>)(property => property.IsBrowsable(realParentTypeInfo.type.RuntimeType, realAncestorTypeInfos))), (Func <IAttachedPropertyMetadata, CodeAidAttachedPropertyInfo>)(property => new CodeAidAttachedPropertyInfo(this.owner, property.Name, property.PropertyType)))));
            }
        }
Ejemplo n.º 4
0
        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);
                }
            }
        }