General question about driver development

I'm trying to plan what I need to do to create a driver for my REST client. I've created a .Net REST client (class library) that encapsulates the Desire To Learn "Valence" API.

To use this we create an instance of ValenceSession (which takes a host and four string credentials, AppID/AppKey/UserID/UserKey).

That instance expose numerous properties and each property is an instance of a distinct class that contains numerous methods, eg we can have: session.Courses.CreateCourse(...) or session.Forums.GetForumsForCourse(...) and so on.

In addition the session exposes a few properties that are IEnumerable like AvailableMethods - which is a set of all API method supported.

Many of the methods (like GetForumsForCourse) also return IEnumerable but of course they require arguments.

Currently I can use LINQPad in "C# Statements" mode to create an instance and then invoke methods, the entire library has close to 200 classes which correspond to the many JSON types supported by the service.

e.g. I may have this in the LINQPad query window:

var session = ValenceSession.Create("XXX", "YYY", "WWW", "ZZZ", ""); session.AvailableMethods.Dump(); session.OrgUnits.GetDescendantOrgUnitsSeq("latest", 6932).ToLookup(r => r.Identifier).Select(x => x.First()).Where(d => d.Type.Id == 3).Take(10).Dump(); session.Groups.GetGroupCategories("latest",7358).Dump(); session.Sections.AreSectionsInitialized(ProductVersion.Default,7358).Dump(); session.Log.GetAllMessagesSeq(ProductVersion.Latest,"2017-01-01T01:00:00.000Z","2017-11-10T01:00:00.000Z").Dump();

and this works well, it enables us to "query" the service in a very rich way, extremely powerful.

But I want to eliminate the first line, where we create the object instance and pass in raw credentials and so on.

I assume a dynamic driver is desired here (many of the returned sequence can be nested sequences of various compound classes) but is this even possible?

With SQL for example the connection exposes all tables as IEnumerable properties but with this Valence API we have very few such properties and mostly lots of methods. Also with SQL the user writes queries against a connection's properties (tables) not against the connection itself.

Can you suggest how best to go about this?


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!