protected IServiceProvider GetContainer(IReflectorConfiguration rc) { ImmutableSpecFactory.ClearCache(); var hostBuilder = CreateHostBuilder(new string[] { }, rc).Build(); return(hostBuilder.Services); }
public DomainObjectContainerInjector(IReflectorConfiguration config, ILoggerFactory loggerFactory, ILogger <DomainObjectContainerInjector> logger) { this.loggerFactory = loggerFactory ?? throw new InitialisationException($"{nameof(loggerFactory)} is null"); serviceTypes = config.Services.ToList(); }
// do nothing, the generic reflector does not have a parant public virtual void Configuration(IReflectorConfiguration config) { if (_delegate != null) { _delegate.Configuration(config); } }
public ServicesManager(IDomainObjectInjector injector, INakedObjectManager manager, IReflectorConfiguration config) { Assert.AssertNotNull(injector); Assert.AssertNotNull(manager); Assert.AssertNotNull(config); this.injector = injector; this.manager = manager; services = config.Services.Select(Activator.CreateInstance).ToList(); }
protected virtual void RegisterTypes(IServiceCollection services, IReflectorConfiguration rc) { RegisterFacetFactories(services); services.AddSingleton <ISpecificationCache, ImmutableInMemorySpecCache>(); services.AddSingleton <IClassStrategy, DefaultClassStrategy>(); services.AddSingleton <IReflector, Reflector>(); services.AddSingleton <IMetamodel, Metamodel>(); services.AddSingleton <IMetamodelBuilder, Metamodel>(); services.AddSingleton <IMenuFactory, NullMenuFactory>(); services.AddSingleton(rc); TestHook(services); }
public ServicesManager(IDomainObjectInjector injector, INakedObjectManager manager, IReflectorConfiguration config, ILogger <ServicesManager> logger, IFunctionalReflectorConfiguration fConfig = null) { this.injector = injector ?? throw new InitialisationException($"{nameof(injector)} is null"); this.manager = manager ?? throw new InitialisationException($"{nameof(manager)} is null"); this.logger = logger ?? throw new InitialisationException($"{nameof(logger)} is null"); var fServices = fConfig == null?Array.Empty <Type>() : fConfig.Services; services = config.Services.Union(fServices).Select(Activator.CreateInstance).ToList(); }
public Reflector(IClassStrategy classStrategy, IMetamodelBuilder metamodel, IReflectorConfiguration config, IMenuFactory menuFactory, IEnumerable <IFacetDecorator> facetDecorators, IEnumerable <IFacetFactory> facetFactories, ILoggerFactory loggerFactory, ILogger <Reflector> logger) { ClassStrategy = classStrategy ?? throw new InitialisationException($"{nameof(classStrategy)} is null"); this.metamodel = metamodel ?? throw new InitialisationException($"{nameof(metamodel)} is null"); this.config = config ?? throw new InitialisationException($"{nameof(config)} is null"); this.menuFactory = menuFactory ?? throw new InitialisationException($"{nameof(menuFactory)} is null"); this.loggerFactory = loggerFactory ?? throw new InitialisationException($"{nameof(loggerFactory)} is null"); this.logger = logger ?? throw new InitialisationException($"{nameof(logger)} is null"); facetDecoratorSet = new FacetDecoratorSet(facetDecorators.ToArray()); FacetFactorySet = new FacetFactorySet(facetFactories.ToArray()); }
public Reflector(IClassStrategy classStrategy, IMetamodelBuilder metamodel, IReflectorConfiguration config, IMenuFactory menuFactory, IFacetDecorator[] facetDecorators, IFacetFactory[] facetFactories) { Assert.AssertNotNull(classStrategy); Assert.AssertNotNull(metamodel); Assert.AssertNotNull(config); Assert.AssertNotNull(menuFactory); this.classStrategy = classStrategy; this.metamodel = metamodel; this.config = config; this.menuFactory = menuFactory; facetDecoratorSet = new FacetDecoratorSet(facetDecorators); FacetFactorySet = new FacetFactorySet(facetFactories); }
public ParallelReflector(IClassStrategy classStrategy, IMetamodelBuilder metamodel, IReflectorConfiguration config, IFunctionalReflectorConfiguration functionalConfig, IMenuFactory menuFactory, IEnumerable <IFacetDecorator> facetDecorators, IEnumerable <IFacetFactory> facetFactories, ILoggerFactory loggerFactory, ILogger <ParallelReflector> logger) { ClassStrategy = classStrategy ?? throw new InitialisationException($"{nameof(classStrategy)} is null"); initialMetamodel = metamodel ?? throw new InitialisationException($"{nameof(metamodel)} is null"); this.config = config ?? throw new InitialisationException($"{nameof(config)} is null"); this.functionalConfig = functionalConfig; this.menuFactory = menuFactory ?? throw new InitialisationException($"{nameof(menuFactory)} is null"); this.loggerFactory = loggerFactory ?? throw new InitialisationException($"{nameof(loggerFactory)} is null"); this.logger = logger ?? throw new InitialisationException($"{nameof(logger)} is null"); facetDecoratorSet = new FacetDecoratorSet(facetDecorators.ToArray()); FacetFactorySet = new FacetFactorySet(facetFactories.Where(f => f.ReflectionTypes.HasFlag(ReflectionType.ObjectOriented)).ToArray()); FunctionalFacetFactorySet = new FacetFactorySet(facetFactories.Where(f => f.ReflectionTypes.HasFlag(ReflectionType.Functional)).ToArray()); }
public static ReflectConstructorSpec CreateConstructor(IConstructorAwareReflectClass claxx, Type clazz, IReflectorConfiguration config, IReflectConstructor[] constructors ) { if (claxx == null) { return(ReflectConstructorSpec.InvalidConstructor); } if (claxx.IsAbstract() || claxx.IsInterface()) { return(ReflectConstructorSpec.InvalidConstructor); } if (!Platform4.CallConstructor()) { var skipConstructor = !config.CallConstructor(claxx); if (!claxx.IsCollection()) { var serializableConstructor = SkipConstructor(claxx, skipConstructor , config.TestConstructors()); if (serializableConstructor != null) { return(new ReflectConstructorSpec(serializableConstructor, null)); } } } if (!config.TestConstructors()) { return(new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null)); } if (ReflectPlatform.CreateInstance(clazz) != null) { return(new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null)); } var sortedConstructors = SortConstructorsByParamsCount(constructors); return(FindConstructor(claxx, sortedConstructors)); }
public static ReflectConstructorSpec CreateConstructor(IConstructorAwareReflectClass claxx, Type clazz, IReflectorConfiguration config, IReflectConstructor[] constructors ) { if (claxx == null) { return ReflectConstructorSpec.InvalidConstructor; } if (claxx.IsAbstract() || claxx.IsInterface()) { return ReflectConstructorSpec.InvalidConstructor; } if (!Platform4.CallConstructor()) { var skipConstructor = !config.CallConstructor(claxx); if (!claxx.IsCollection()) { var serializableConstructor = SkipConstructor(claxx, skipConstructor , config.TestConstructors()); if (serializableConstructor != null) { return new ReflectConstructorSpec(serializableConstructor, null); } } } if (!config.TestConstructors()) { return new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null); } if (ReflectPlatform.CreateInstance(clazz) != null) { return new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null); } var sortedConstructors = SortConstructorsByParamsCount(constructors); return FindConstructor(claxx, sortedConstructors); }
public DefaultClassStrategy(IReflectorConfiguration config, IFunctionalReflectorConfiguration fConfig = null) { this.config = config; this.fConfig = fConfig; }
public DefaultClassStrategy(IReflectorConfiguration config) { this.config = config; }
public NetReflector(IReflectorConfiguration config) { _config = config; }
public virtual void Configuration(IReflectorConfiguration config) { _config = config; }
public void Configuration(IReflectorConfiguration reflectorConfiguration) { readReflector.Configuration(reflectorConfiguration); }
public DomainObjectContainerInjector(IReflectorConfiguration config) { Assert.AssertNotNull(config); serviceTypes = config.MenuServices.Union(config.ContributedActions).Union(config.SystemServices).ToList(); }
private IHostBuilder CreateHostBuilder(string[] args, IReflectorConfiguration rc) => Host.CreateDefaultBuilder(args) .ConfigureServices((hostContext, services) => { RegisterTypes(services, rc); });
public DomainObjectContainerInjector(IReflectorConfiguration config) { Assert.AssertNotNull(config); serviceTypes = config.Services.ToList(); }
private IMetamodelBuilder InstallSpecificationsParallel(Type[] types, IMetamodelBuilder metamodel, IReflectorConfiguration config) { var mm = GetPlaceholders(types); mm = IntrospectPlaceholders(mm); mm.ForEach(i => metamodel.Add(i.Value.Type, i.Value)); return(metamodel); }
// only intended for use during initial reflection //[NonSerialized] private IImmutableDictionary<Type, bool> namespaceScratchPad = ImmutableDictionary<Type, bool>.Empty; public DefaultClassStrategy(IReflectorConfiguration config) { this.config = config; }
public ServicesManager(IContainerInjector injector, INakedObjectManager manager, IReflectorConfiguration config) { Assert.AssertNotNull(injector); Assert.AssertNotNull(manager); Assert.AssertNotNull(config); this.injector = injector; this.manager = manager; IEnumerable <ServiceWrapper> ms = config.MenuServices.Select(s => new ServiceWrapper(ServiceType.Menu, Activator.CreateInstance(s))); IEnumerable <ServiceWrapper> cs = config.ContributedActions.Select(s => new ServiceWrapper(ServiceType.Contributor, Activator.CreateInstance(s))); IEnumerable <ServiceWrapper> ss = config.SystemServices.Select(s => new ServiceWrapper(ServiceType.System, Activator.CreateInstance(s))); services = ms.Union(cs).Union(ss).Cast <IServiceWrapper>().ToList(); }