Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolated config scripts #70

Closed
adamralph opened this issue Sep 18, 2013 · 3 comments
Closed

Isolated config scripts #70

adamralph opened this issue Sep 18, 2013 · 3 comments
Assignees
Labels
Milestone

Comments

@adamralph
Copy link
Contributor

Allows things like:

var config1 = new FileConfigurator("1.csx").Load();
var config2 = new FileConfigurator("2.csx").Load();

var foo1 = config1.Get<int>("foo");
var foo2 = config2.Get<int>("foo");

Currently there is no way to get a handle on the 'current' configurator in script. We only have a handle to the static Configurator which represents the latest configurator in the cascade chain, as controlled by Configurator.Load();.

The new syntax will allow the following in script:

Add("foo", 123);

I.e. no reference to the static Configurator when adding. This adds the value to the current configurator. If the configurator is loaded via a call to one of the static Configurator.Load() methods then its values still form part of the cascading values.

It will still be possible to read values in script using the Configurator.Get() methods. Of course, it will also still be possible to add values using Configurator.Add() in script, but this would be pathological.

@ghost ghost assigned adamralph Oct 5, 2013
@adamralph
Copy link
Contributor Author

Need to preserve static addition - this is useful for communicating values from app to script, e.g. version, which can be used to execute versioned config.

The best idea is probably to always implicitly ensure a basic configurator is present to receive statically added values. This means statically added values will always have no 'source', they just come from code somewhere. This is probably OK. When adding values through scripts the new local Add() method should be used which will convey source info and ensure that the items belong to the current configurator when using isolated scripts.

@adamralph
Copy link
Contributor Author

We can also consider providing a deprecated, backward behaviour preserving, IConfigRScriptHost.Configurator which wraps the local Add()/Set(). Although would the Get() have to wrap the static Get()?

Important to note that the only way to remove the deprecated member later would be to break the calls by changing Add()/Set() to something else. One option is to delay the change from Add() to Set() until then.

too messy and not worth it

@adamralph
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant