public static IEnumerable <Type> FindTypes(TypeIncludes flags, Type baseType) { if (baseType == null) { throw new ArgumentNullException("baseType", "Must be set to a type"); } Func <Type, bool> predicate = BuildPredicate(flags); var foundTypes = from containedType in FindTypes(baseType) where predicate(containedType) select containedType; if (!(IsSet(flags, TypeIncludes.ConcreteTypes) && IsConcreteType(baseType))) { if (foundTypes.Contains(baseType)) { IList <Type> b = new List <Type>(); b.Add(baseType); foundTypes = foundTypes.Except(b.AsQueryable()); } } if (IsSet(flags, TypeIncludes.PrimitiveTypes)) { foundTypes = foundTypes.Concat(FindPrimitiveTypes()); } return(foundTypes); }
public static IEnumerable<Type> FindTypes(TypeIncludes flags, Type baseType) { if (baseType == null) throw new ArgumentNullException("baseType", "Must be set to a type"); Func<Type, bool> predicate = BuildPredicate(flags); var foundTypes = from containedType in FindTypes(baseType) where predicate(containedType) select containedType; if (!(IsSet(flags, TypeIncludes.ConcreteTypes) && IsConcreteType(baseType))) { if(foundTypes.Contains(baseType)) { IList<Type> b = new List<Type>(); b.Add(baseType); foundTypes = foundTypes.Except(b.AsQueryable()); } } if (IsSet(flags, TypeIncludes.PrimitiveTypes)) { foundTypes = foundTypes.Concat(FindPrimitiveTypes()); } return foundTypes; }
private static Func <Type, bool> BuildPredicate(TypeIncludes flags) { IList <Func <Type, bool> > functions = SelectFuntions(flags); Func <Func <Type, bool>, Func <Type, bool>, Func <Type, bool> > or = (f1, f2) => (t => f1(t) || f2(t)); Func <Type, bool> current = (x => false); foreach (Func <Type, bool> func in functions) { current = or(func, current); } return(current); }
private static IList <Func <Type, bool> > SelectFuntions(TypeIncludes flags) { bool includeAllInterfaces = IsSet(flags, TypeIncludes.InterfaceTypes); bool includeConcreteTypes = IsSet(flags, TypeIncludes.ConcreteTypes); List <Func <Type, bool> > functions = new List <Func <Type, bool> >(); if (includeAllInterfaces) { functions.Add(x => x.IsInterface); } if (includeConcreteTypes) { functions.Add(x => (IsConcreteType(x))); } return(functions); }
private IEnumerable <Type> EnumerateWithCompositeSelector() { TypeIncludes includes = new TypeIncludes(); if (IsSet(Mode, UiControlTypeSelectorMode.ConcreteTypes)) { includes = TypeIncludes.ConcreteTypes; } if (IsSet(Mode, UiControlTypeSelectorMode.InterfaceTypes)) { includes = includes | TypeIncludes.InterfaceTypes; } if (IsSet(Mode, UiControlTypeSelectorMode.PrimitiveTypes)) { includes = includes | TypeIncludes.PrimitiveTypes; } return(TypeLocator.FindTypes(includes, this.AssignableTo)); }
public async Task <BaseDTO> FindByIdAsync(int id, int templateId) { //1. get template var template = await _templateRepository.FindByIdAsync(templateId, new string[] { "TemplateIncludes", "TemplateType" }); if (template == null) { return(null); } string typeName = template.TemplateType.Route; //2. Getdata T data = await _dataRepository.FindByIdAsync(id, TypeIncludes.GetIncludes(typeName.ToLower())); if (data == null) { return(null); } //3. map and return return(_mapper.map(data, template.TemplateIncludes.Select(p => p.Include).ToArray())); }
private IEnumerable<Type> EnumerateWithCompositeSelector() { TypeIncludes includes = new TypeIncludes(); if (IsSet(Mode, UiControlTypeSelectorMode.ConcreteTypes)) { includes = TypeIncludes.ConcreteTypes; } if (IsSet(Mode, UiControlTypeSelectorMode.InterfaceTypes)) { includes = includes | TypeIncludes.InterfaceTypes; } if (IsSet(Mode, UiControlTypeSelectorMode.PrimitiveTypes)) { includes = includes | TypeIncludes.PrimitiveTypes; } return TypeLocator.FindTypes(includes, this.AssignableTo); }
public static IEnumerable<Type> FindTypes(TypeIncludes flags) { return FindTypes(flags, typeof(object)); }
public BaseTypeIncludesAttribute(Type baseType, TypeIncludes includes) { _baseType = baseType; _includes = includes; }
private static bool IsSet(TypeIncludes flags, TypeIncludes compareFlag) { return ((flags & compareFlag) == compareFlag); }
private static Func<Type, bool> BuildPredicate(TypeIncludes flags) { IList<Func<Type, bool>> functions = SelectFuntions(flags); Func<Func<Type, bool>, Func<Type, bool>, Func<Type, bool>> or = (f1, f2) => (t => f1(t) || f2(t)); Func<Type, bool> current = (x => false); foreach (Func<Type, bool> func in functions) { current = or(func, current); } return current; }
private static IList<Func<Type, bool>> SelectFuntions(TypeIncludes flags) { bool includeAllInterfaces = IsSet(flags, TypeIncludes.InterfaceTypes); bool includeConcreteTypes = IsSet(flags, TypeIncludes.ConcreteTypes); List<Func<Type, bool>> functions = new List<Func<Type, bool>>(); if (includeAllInterfaces) { functions.Add(x => x.IsInterface); } if (includeConcreteTypes) { functions.Add(x => (IsConcreteType(x))); } return functions; }
public static IEnumerable <Type> FindTypes(TypeIncludes flags) { return(FindTypes(flags, typeof(object))); }
private static bool IsSet(TypeIncludes flags, TypeIncludes compareFlag) { return((flags & compareFlag) == compareFlag); }