Accessing REST api from Windows CE

1.8k views Asked by At

I have one Windows Handheld device application which has the requirement of accessing a REST API. The REST API gives me JSON output which I am going to handle via Newton.JSON. Now to achieve modular structure I want to have the communication to the REST API be handled via a different module altogether something like a Class Library. But unfortunately it seems that it is not possible to do so via a class library(or maybe possible). So my question is what is the best alternative to do so?

Please note that I don't want to include those connectivity operations in my front end application project. And I am using .Net framework 3.5 & Windows Mobile SDK 6.0

Thanks in advance

2

There are 2 answers

0
Joy On BEST ANSWER

Now I got my answer. Sorry I did a mistake while selecting the project type. I selected "Windows Form Class Library" project instead of "Smart Device Class Library" project. Now that I have selected the right one it is working fine for me.

BTW thanks for those responses.

Cheers

0
josef On

Pseudo class library code:

public function void startQuery() //starts a thread that does the JSON query
//inside thread on query result use OnDone() delegate

private delegate void OnDone(string dateTimeString);

//In main GUI code add a reference to the class lib and init a new object then add an event handler to the OnDone delegate of the class lib
JSONClassLib myJson=new JSONClassLib();
...
   myJson.OnDone+=new EventHandler(myEventHandler);
void myEventHandler(sender this, objext o){
   //will be called when query is done
}
//you need to use Control.Invoke if you want to update the GUI from myEventHandler  
//to start a query use something like this from your class lib
   myJson.doQuery(string);

If you add your existing code we may help with creating a class lib and async code