コード例 #1
0
        public Task <AssignableTypesResult> GetAssignableTypesAsync(ITypeInfo type, bool childTypes)
        {
            if (type == KnownTypes[typeof(CommonValueConverter)])
            {
                return(Task.FromResult(new AssignableTypesResult(new[] { type })));
            }

            return(Task.Run(() => {
                var types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes()).AsParallel()
                            .Where(t => t.Namespace != null && !t.IsAbstract && !t.IsInterface && t.IsPublic && t.GetConstructor(Type.EmptyTypes) != null);

                Type realType = ReflectionEditorProvider.GetRealType(type);
                if (childTypes)
                {
                    var generic = realType.GetInterface("ICollection`1");
                    if (generic != null)
                    {
                        realType = generic.GetGenericArguments()[0];
                    }
                    else
                    {
                        realType = typeof(object);
                    }
                }

                types = types.Where(t => realType.IsAssignableFrom(t));

                return new AssignableTypesResult(types.Select(t => {
                    string asmName = t.Assembly.GetName().Name;
                    return new TypeInfo(new AssemblyInfo(asmName, isRelevant: asmName.StartsWith("Xamarin")), t.Namespace, t.Name);
                }).ToList());
            }));
        }
コード例 #2
0
        public async Task <IReadOnlyCollection <IPropertyInfo> > GetPropertiesForTypeAsync(ITypeInfo type)
        {
            Type realType = ReflectionEditorProvider.GetRealType(type);

            if (realType == null)
            {
                return(Array.Empty <IPropertyInfo>());
            }
            return(ReflectionEditorProvider.GetPropertiesForType(realType));
        }
コード例 #3
0
        public async Task <IReadOnlyCollection <IPropertyInfo> > GetPropertiesForTypeAsync(ITypeInfo type)
        {
            Type realType = ReflectionEditorProvider.GetRealType(type);

            if (realType == null)
            {
                return(Array.Empty <IPropertyInfo> ());
            }

            if (typeof(MockControl).IsAssignableFrom(realType))
            {
                object item = await CreateObjectAsync(type);

                IObjectEditor editor = ChooseEditor(item);
                return(editor.Properties);
            }

            return(ReflectionEditorProvider.GetPropertiesForType(realType));
        }