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()); })); }
public async Task <IReadOnlyCollection <IPropertyInfo> > GetPropertiesForTypeAsync(ITypeInfo type) { Type realType = ReflectionEditorProvider.GetRealType(type); if (realType == null) { return(Array.Empty <IPropertyInfo>()); } return(ReflectionEditorProvider.GetPropertiesForType(realType)); }
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)); }