Conversation
* Gimme for python and ruby * This is needed in .net to dynamically reference configuration values based on class name. The referencing code is in a base class, and the named configuration key is that of the derived class
jtroe
left a comment
There was a problem hiding this comment.
the respond_totest asserts that the method call is implemented on the class.
Is the GetParameter<T> functionality something we want implemented in the Config class?
| set { RawConfig[index] = value; } | ||
| } | ||
|
|
||
| public object this[string index] |
There was a problem hiding this comment.
Is object the right return type here? You'd have to do some kind of type manipulation with the result, which would make it less fluent...
There was a problem hiding this comment.
The reason this returns an object is to mimic this[int index].
|
I cannot get the |
| my_string = "thekey" | ||
| self.assertEqual(config.the_environment[my_string], "TheValue") | ||
|
|
||
| unittest.main() |
There was a problem hiding this comment.
Looks like I should remove unittest.main() as I was running python without the -m option that the rakefile calls it with.
| @property | ||
| def _shared_file_path(self): | ||
| return 'config.json' | ||
| return os.path.normpath('../config.json') |
There was a problem hiding this comment.
Should probably roll this back, since the rakefile calls the test from the root directory instead of the test directory.
|
|
||
| def shared_file_path | ||
| 'config.json' | ||
| File.join('..','..','config.json') |
There was a problem hiding this comment.
Should probably roll this back, since the rakefile calls the test from the root directory instead of the test directory.
|
Further testing is showing that the |
Hopefully just branching instead of forking and branching is not too egregious a faux pas to cause any sort of heart burn.
These changes are intended to give me the capability to dynamically reference a
dynamickey value in C#. As far as I can tell, key paths can only be 'hardcoded'. In other words, you must type out the hierarchy separating each level with a.(e.g.prod.task.task2[see config.json below for reference]). Other than looping through everything, I wasn't able to see a way dynamically reference a specific key.Ultimately I want to be able to reference keys of the same name as whichever derived class happens to be implementing the base class at run time. Here's a bit of code to make things a little more clear.
Example config.json:
On a side note, I found that there is one more unit test for Ruby than there are for python or .NET. Being a Ruby dolt and not having any time to do any digging, I did not attempt to understand exactly what it did or create complementary tests in python or .NET. The test is
test_respond_to.