/// <summary> /// Using the information in this <see cref="ConfigReference"/>, the object this reference points to will be resolved and returned. This <see cref="ConfigReference"/> must point to an actual configuration. If it points to a file, an <see cref="InvalidOperationException"/> will be thrown.<para/> /// Consider using <see cref="Resolve{T}(ConfigReference)"/> if the type of the result is known.<para/> /// This will automatically populate the arguments in the referenced config if applicable, making usage of the returned object relatively straightforward. /// </summary> /// <param name="cfgRef">The ConfigReference to resolve the reference to.</param> /// <returns>The ManagedConfig the given ConfigReference is pointing to.</returns> /// <exception cref="InvalidOperationException">If IsFileReference() returns true on this ConfigReference.</exception> public static ManagedConfig Resolve(this ConfigReference cfgRef) { if (cfgRef.IsFileReference()) { throw new InvalidOperationException("Cannot resolve the path to a non-config reference (this ConfigReference points to a file!)"); } ManagedConfig mgCfg = ConfigReferenceBootstrapper.ConfigReferences.TryGetReferenceFromName(cfgRef.getName())?.Clone(); // Populate the values of the referenced object if possible. if (mgCfg is ParameterizedConfig paramCfg) { // This can store arguments. paramCfg.ApplyArguments(cfgRef.getArguments()); return(paramCfg); } // It's gotta stay as a ManagedConfig // Can't make use of this to apply arguments to. How do I handle this? // For now: Return the object without any changes. return(mgCfg); }
public CacheNavigationDatabase(IOptions <ManagedConfig> managedConfig) { _managedConfig = managedConfig.Value; }
public SqlNavigationDatabase(IOptions <ManagedConfig> managedConfig, ShortUrlDbContext shortUrlDbContext) { _shortUrlDbContext = shortUrlDbContext; _managedConfig = managedConfig.Value; }
public AdminController(IOptions <ManagedConfig> managedConfig, INavigationDatabase navigationDatabase) { _navigationDatabase = navigationDatabase; _managedConfig = managedConfig.Value; }
public HashKeyService(IOptions <ManagedConfig> managedConfig, IDataProvider dataProvider) { _randomGenerator = new Random(); _managedConfig = managedConfig.Value; _dataProvider = dataProvider; }