Lukianol.Arguments. Dynamic Support

I continue to work with the Lukianol.Arguments API. If you might notice it is very ugly when you want to get typed arguments from a result:


A lot of letters as for me. What could we do here?

We can gain from C# 4.0 dynamic objects! I have simply inherited ArgumentParserResult from the DynamicObject and overridden the TryGetMember method where  a value is returned by a property name from an underlying arguments’ dictionary. Check this test with the described functional presentation:

        public void DynamicArgumentsParserResultShouldWork()
            var args = new List<string>

            var map = new ArgumentsMap()

            var parser = new ArgumentParser(map);

            var result = parser.ParseAsDynamicResult(args);

            TimeSpan timeout = result.Timeout;

            Assert.AreEqual(TimeSpan.FromSeconds(5), timeout);

You can find the Lukianol.Arguments at CodePlex

This entry was posted in .NET, C#, Codeplex. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s