RestApi.cs CampusAppWP8::Utility::RestApi CampusAppWP8::Utility //----------------------------------------------------------------------- //<copyrightfile="RestApi.cs"company="BTU/IIT"> //Companycopyrighttag. //</copyright> //<author>stubbfel</author> //<sience>10.06.2013</sience> //----------------------------------------------------------------------usingSystem; namespaceCampusAppWP8.Utility { usingSystem; usingSystem.Net; publicabstractclassRestApi { #regionMembers privateWebClientclient; #endregion #regionConstructor publicRestApi() { this.client=newWebClient(); } publicRestApi(UriapiBaseAddress) { this.client=newWebClient(); this.client.BaseAddress=apiBaseAddress.AbsoluteUri; } #endregion #regionMethods #regionpublic publicvoidHttpGet(Uriurl,Action<object,DownloadStringCompletedEventArgs>action) { this.client.DownloadStringCompleted+=newDownloadStringCompletedEventHandler(action); this.client.DownloadStringAsync(url); } publicvoidHttpDelete(Uriurl,Action<object,DownloadStringCompletedEventArgs>action) { thrownewNotSupportedException(); } publicvoidHttpHead(Uriurl,Action<object,DownloadStringCompletedEventArgs>action) { thrownewNotSupportedException(); } publicvoidHttpOptions(Uriurl,Action<object,DownloadStringCompletedEventArgs>action) { thrownewNotSupportedException(); } publicvoidHttpConnect(Uriurl,Action<object,DownloadStringCompletedEventArgs>action) { thrownewNotSupportedException(); } publicvoidHttpTrace(Uriurl,Action<object,DownloadStringCompletedEventArgs>action) { thrownewNotSupportedException(); } publicvoidHttpPost(Uriurl,Action<object,UploadStringCompletedEventArgs>action,stringpostData) { this.UploadData(url,action,"POST",postData); } publicvoidHttpPut(Uriurl,Action<object,UploadStringCompletedEventArgs>action,stringputData) { this.UploadData(url,action,"PUT",putData); } publicvoidHttpPatch(Uriurl,Action<object,UploadStringCompletedEventArgs>action,stringpatchData) { this.UploadData(url,action,"PATCH",patchData); } #endregion #regionprivate privatevoidUploadData(Uriurl,Action<object,UploadStringCompletedEventArgs>action,stringmethod,stringdata) { this.client.UploadStringCompleted+=newUploadStringCompletedEventHandler(action); this.client.UploadStringAsync(url,method,data); } #endregion #endregion } }