public ReportRegistry(ITypeSource typeSource, IPermissionService permissions, ITextLocalizer localizer) { types = (typeSource ?? throw new ArgumentNullException(nameof(types))) .GetTypesWithAttribute(typeof(ReportAttribute)); this.permissions = permissions ?? throw new ArgumentNullException(nameof(permissions)); this.localizer = localizer ?? throw new ArgumentNullException(nameof(localizer)); }
/// <summary> /// Adds local text translations defined implicitly by Description attributes in /// enumeration classes. Only enum values that has Description attribute are added as /// local text. By default, enums are registered in format: /// "Enums.{EnumerationTypeFullName}.{EnumValueName}". EnumerationTypeFullName, is /// fullname of the enumeration type. This can be overridden by attaching a EnumKey /// attribute. /// </summary> /// <param name="typeSource">Type source to search for enumeration classes in</param> /// <param name="languageID">Language ID texts will be added (default is invariant language)</param> /// <param name="registry">Registry</param> public static void AddEnumTexts(this ILocalTextRegistry registry, ITypeSource typeSource, string languageID = LocalText.InvariantLanguageID) { if (typeSource == null) { throw new ArgumentNullException("assemblies"); } var provider = registry ?? throw new ArgumentNullException(nameof(registry)); foreach (var type in typeSource.GetTypes()) { if (type.IsEnum) { var enumKey = EnumMapper.GetEnumTypeKey(type); foreach (var name in Enum.GetNames(type)) { var member = type.GetMember(name); if (member.Length == 0) { continue; } var descAttr = member[0].GetCustomAttribute <DescriptionAttribute>(); if (descAttr != null) { provider.Add(languageID, "Enums." + enumKey + "." + name, descAttr.Description); } } } } }
public static void RegisterFormScripts(IDynamicScriptManager scriptManager, ITypeSource typeSource, IPropertyItemProvider propertyProvider, IServiceProvider serviceProvider) { if (scriptManager == null) { throw new ArgumentNullException(nameof(scriptManager)); } if (typeSource == null) { throw new ArgumentNullException(nameof(typeSource)); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } var scripts = new List <Func <string> >(); foreach (var type in typeSource.GetTypesWithAttribute(typeof(FormScriptAttribute))) { var attr = type.GetCustomAttribute <FormScriptAttribute>(); var key = attr.Key ?? type.FullName; var script = new FormScript(key, type, propertyProvider, serviceProvider); scriptManager.Register(script); scripts.Add(script.GetScript); } scriptManager.Register("FormBundle", new ConcatenatedScript(scripts)); }
public ImplementationTypesCollection(ITypeSource typeSource, ITypesHelper typesHelper) { this.typeSource = typeSource; this.typesHelper = typesHelper; getImplementationTypes = GetImplementationTypes; }
public TranslationController(IWebHostEnvironment hostEnvironment, ILocalTextRegistry localTextRegistry, ITypeSource typeSource) { HostEnvironment = hostEnvironment ?? throw new ArgumentNullException(nameof(hostEnvironment)); LocalTextRegistry = localTextRegistry ?? throw new ArgumentNullException(nameof(localTextRegistry)); TypeSource = typeSource ?? throw new ArgumentNullException(nameof(typeSource)); }
public DocumentAlteration(ITypeSource typeSource) { var types = typeSource.GetTypes().ToArray(); _hasDocumentIndexes = types.Where(x => typeof(IHasDocumentIndex).IsAssignableFrom(x)); _hasDocumentsIndexes = types.Where(x => typeof(IHasDocumentsIndex).IsAssignableFrom(x)); }
private static ILookup <string, NavigationItemAttribute> GetNavigationItemAttributes( ITypeSource typeSource, IServiceProvider serviceProvider, Func <NavigationItemAttribute, bool> filter) { var list = new List <NavigationItemAttribute>(); foreach (NavigationItemAttribute attr in typeSource .GetAssemblyAttributes <NavigationItemAttribute>()) { if (filter == null || filter(attr)) { list.Add(attr); } } foreach (var navItemType in typeSource.GetTypesWithInterface(typeof(INavigationItemSource)) .Where(x => !x.IsAbstract && !x.IsInterface)) { var navItem = (INavigationItemSource)ActivatorUtilities.CreateInstance( serviceProvider, navItemType); foreach (var item in navItem.GetItems()) { if (filter == null || filter(item)) { list.Add(item); } } } return(ByCategory(list)); }
///<summary> /// constructor that takes a <see cref="ITypeSource"/> that wil be used to build the /// ClassDefinitions. ///</summary> ///<param name="source"></param> ///<exception cref="ArgumentNullException"></exception> public ReflectionClassDefLoader(ITypeSource source) { if (source == null) { throw new ArgumentNullException("source"); } Source = source; }
public FilteredTypeSource(Func<Type, bool> filter, ITypeSource inner) { Guard.IsNotNull(filter, "filter"); Guard.IsNotNull(inner, "inner"); _filter = filter; _inner = inner; }
public TranslationRepository(IRequestContext context, IWebHostEnvironment hostEnvironment, ILocalTextRegistry localTextRegistry, ITypeSource typeSource) : base(context) { HostEnvironment = hostEnvironment; LocalTextRegistry = localTextRegistry; TypeSource = typeSource; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultPropertyItemProvider"/> class. /// </summary> /// <param name="provider">The provider.</param> /// <param name="typeSource">The type source.</param> /// <exception cref="ArgumentNullException"> /// provider or typeSource is null /// </exception> public DefaultPropertyItemProvider(IServiceProvider provider, ITypeSource typeSource) { this.provider = provider ?? throw new ArgumentNullException(nameof(provider)); processorFactories = (typeSource ?? throw new ArgumentNullException(nameof(typeSource))) .GetTypesWithInterface(typeof(IPropertyProcessor)) .Where(x => !x.IsAbstract && !x.IsInterface) .Select(type => ActivatorUtilities.CreateFactory(type, Type.EmptyTypes)); }
public void AddMappingsFromSource(ITypeSource source) { source.GetTypes() .Where(IsMappingOf <IMappingProvider>) .Each(Add); Log.LoadedFluentMappingsFromSource(source); }
internal static IFilterableTypeSource FromTypeSource(ITypeSource typeSource) { if (typeSource == null) { throw new ArgumentNullException("typeSource"); } return(new FilterableTypeSource(typeSource)); }
/// <summary> /// Constructs the AllClassesAutoMapper with a specified Source. /// </summary> /// <param name="source"></param> public AllClassesAutoMapper(ITypeSource source) { if (source == null) { throw new ArgumentNullException("source"); } Source = source; }
public PermissionService(ITwoLevelCache cache, ISqlConnections sqlConnections, ITypeSource typeSource, IUserAccessor userAccessor) { Cache = cache ?? throw new ArgumentNullException(nameof(cache)); SqlConnections = sqlConnections ?? throw new ArgumentNullException(nameof(sqlConnections)); TypeSource = typeSource ?? throw new ArgumentNullException(nameof(typeSource)); UserAccessor = userAccessor ?? throw new ArgumentNullException(nameof(userAccessor)); }
public ListResponse <string> ListPermissionKeys( [FromServices] ITypeSource typeSource) { return(new ListResponse <string> { Entities = MyRepository.ListPermissionKeys(Cache.Memory, typeSource).ToList() }); }
public FilteredTypeSource(Func <Type, bool> filter, ITypeSource inner) { Guard.IsNotNull(filter, "filter"); Guard.IsNotNull(inner, "inner"); _filter = filter; _inner = inner; }
public ITypeScanner Scan(ITypeSource typeSource) { Guard.IsNotNull(typeSource, "typeSource"); var scanner = new TypeScanner(typeSource); _typeScanners.Add(scanner); return scanner; }
public void AddMappingsFromSource(ITypeSource source) { source.GetTypes() .Where(x => IsMappingOf <IMappingProvider>(x) || IsMappingOf <IIndeterminateSubclassMappingProvider>(x) || IsMappingOf <IExternalComponentMappingProvider>(x) || IsMappingOf <IFilterDefinition>(x)) .Each(Add); }
public void LoadedConventionsFromSource(ITypeSource source) { isDirty = true; scannedSources.Add(new ScannedSource { Identifier = source.GetIdentifier(), Phase = ScanPhase.Conventions }); }
public IFilterableTypeSource FromTypeSource(ITypeSource typeSource) { if (typeSource == null) { throw new ArgumentNullException("typeSource"); } _innerTypeSource = typeSource; return(this); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultRowTypeRegistry"/> class. /// </summary> /// <param name="typeSource">The type source.</param> /// <exception cref="ArgumentNullException">typeSource</exception> public DefaultRowTypeRegistry(ITypeSource typeSource) { rowTypes = (typeSource ?? throw new ArgumentNullException(nameof(typeSource))) .GetTypesWithInterface(typeof(IRow)) .Where(x => !x.IsAbstract && !x.IsInterface); byConnectionKey = rowTypes.Where(x => x.GetCustomAttribute <ConnectionKeyAttribute>() != null) .ToLookup(x => x.GetCustomAttribute <ConnectionKeyAttribute>().Value); }
public void LoadedFluentMappingsFromSource(ITypeSource source) { isDirty = true; scannedSources.Add(new ScannedSource { Identifier = source.GetIdentifier(), Phase = ScanPhase.FluentMappings }); }
internal FilterableTypeSource(ITypeSource innerTypeSource, Func <Type, bool> predicate = null) : this(predicate) { if (innerTypeSource == null) { throw new ArgumentNullException("innerTypeSource"); } _innerTypeSource = innerTypeSource; }
public static List <NavigationItem> GetNavigationItems(IPermissionService permissions, ITypeSource typeSource, IServiceProvider serviceProvider, Func <string, string> resolveUrl = null, Func <NavigationItemAttribute, bool> filter = null) { var menuItems = GetNavigationItemAttributes(typeSource, serviceProvider, filter); return(ConvertToNavigationItems(permissions, menuItems, resolveUrl)); }
public ITypeScanner Scan(ITypeSource typeSource) { Guard.IsNotNull(typeSource, "typeSource"); var scanner = new TypeScanner(typeSource); _typeScanners.Add(scanner); return(scanner); }
public IEnumerable<Export> GetExportsIn(ITypeSource source) { var result = new List<Export>(); foreach (var type in _convention.TypesToExport(source.Types)) { result.AddRange(GetExportsIn(type)); } return result; }
public UserDataScript(ITwoLevelCache cache, IPermissionService permissions, ITypeSource typeSource, IUserAccessor userAccessor, IUserRetrieveService userRetrieveService) { Cache = cache ?? throw new ArgumentNullException(nameof(cache)); Permissions = permissions ?? throw new ArgumentNullException(nameof(permissions)); TypeSource = typeSource ?? throw new ArgumentNullException(nameof(typeSource)); UserAccessor = userAccessor ?? throw new ArgumentNullException(nameof(userAccessor)); UserRetriever = userRetrieveService ?? throw new ArgumentNullException(nameof(userRetrieveService)); }
internal FilterableTypeSource(ITypeSource innerTypeSource) { if (innerTypeSource == null) { throw new ArgumentNullException("innerTypeSource"); } _innerTypeSource = innerTypeSource; _predicate = anyType; }
public TestContainerProvider(string connectionString, ITypeSource typeSource) { var builder = new ContainerBuilder() .RegisterPersistence(connectionString, typeSource) .RegisterApplicationServices(Assembly.GetExecutingAssembly()); RegisterMockedUserContext(builder); this.Container = builder.Build(); }
public static IDictionary<string, HashSet<string>> GetImplicitPermissions(IMemoryCache memoryCache, ITypeSource typeSource) { if (memoryCache is null) throw new ArgumentNullException(nameof(memoryCache)); if (typeSource is null) throw new ArgumentNullException(nameof(typeSource)); return memoryCache.Get<IDictionary<string, HashSet<string>>>("ImplicitPermissions", TimeSpan.Zero, () => { var result = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase); Action<Type> addFrom = null; addFrom = (type) => { foreach (var member in type.GetFields(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic)) { if (member.FieldType != typeof(String)) continue; var key = member.GetValue(null) as string; if (key == null) continue; foreach (var attr in member.GetCustomAttributes<ImplicitPermissionAttribute>()) { HashSet<string> list; if (!result.TryGetValue(key, out list)) { list = new HashSet<string>(StringComparer.OrdinalIgnoreCase); result[key] = list; } list.Add(attr.Value); } } foreach (var nested in type.GetNestedTypes(BindingFlags.Public | BindingFlags.DeclaredOnly)) addFrom(nested); }; foreach (var type in typeSource.GetTypesWithAttribute( typeof(NestedPermissionKeysAttribute))) { addFrom(type); } return result; }); }
public static AutoPersistenceModel Source(ITypeSource source, Func <Type, bool> where) { var persistenceModel = new AutoPersistenceModel(); persistenceModel.AddTypeSource(source); if (where != null) { persistenceModel.Where(where); } return(persistenceModel); }
public TestContainerProvider(ITypeSource typeSource) { string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; var builder = new ContainerBuilder() .RegisterPersistence(connectionString, typeSource) .RegisterApplicationServices(Assembly.GetExecutingAssembly()); var mockedUserContext = CreateMockedUserContext(); builder.RegisterInstance(mockedUserContext).AsImplementedInterfaces(); this.Container = builder.Build(); }
public void AddSource(ITypeSource source) { foreach (var type in source.GetTypes()) { if (type.IsAbstract || type.IsGenericType || !typeof(IConvention).IsAssignableFrom(type)) { continue; } Add(type, MissingConstructor.Ignore); } log.LoadedConventionsFromSource(source); }
///<summary> /// constructor that takes a <see cref="ITypeSource"/> that wil be used to build the /// ClassDefinitions. ///</summary> ///<param name="source"></param> ///<exception cref="ArgumentNullException"></exception> public ReflectionClassDefLoader(ITypeSource source) { if (source == null) throw new ArgumentNullException("source"); Source = source; }
internal FilterableTypeSource(ITypeSource innerTypeSource, Func<Type, bool> predicate = null) : this(predicate) { if (innerTypeSource == null) throw new ArgumentNullException("innerTypeSource"); _innerTypeSource = innerTypeSource; }
public static ContainerBuilder RegisterPersistence(this ContainerBuilder builder, string connectionString, ITypeSource persistenceModelsTypeSource) { var autoPersistenceModel = AutoMap.Source(persistenceModelsTypeSource, new AutomappingConfiguration()); InternalRegisterPersistence(builder, connectionString, autoPersistenceModel); return builder; }
public TypeScanner(ITypeSource typeSource) { _typeSource = typeSource; }
public void LoadedFluentMappingsFromSource(ITypeSource source) {}
public void LoadedConventionsFromSource(ITypeSource source) {}
/// <summary> /// Constructs the AllClassesAutoMapper with a specified Source. /// </summary> /// <param name="source"></param> public AllClassesAutoMapper(ITypeSource source) { if (source == null) throw new ArgumentNullException("source"); Source = source; }
public IFilterableTypeSource FromTypeSource(ITypeSource typeSource) { if (typeSource == null) throw new ArgumentNullException("typeSource"); _innerTypeSource = typeSource; return this; }
public void DeclaredProvider( ITypeSource sut ) { Assert.NotNull( sut ); Assert.Same( DeclaredAssemblyProvider.Default, sut ); }
internal static IFilterableTypeSource FromTypeSource(ITypeSource typeSource) { if (typeSource == null) throw new ArgumentNullException("typeSource"); return new FilterableTypeSource(typeSource); }