All Projects → igorkulman → Kulman.WPA81.BaseRestService

igorkulman / Kulman.WPA81.BaseRestService

Licence: MIT license
Base class for a Windows Phone 8.1 XAML, Windows 8.1 and Windows 10 Universal REST service implementation

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to Kulman.WPA81.BaseRestService

Elmish.Uno
Static UWP views for elmish programs running with the Uno Platform
Stars: ✭ 23 (+21.05%)
Mutual labels:  uwp
LaunchMapsPlugin
Launch External Maps Plugin for Xamarin and Windows
Stars: ✭ 49 (+157.89%)
Mutual labels:  uwp
Chatovatko
A chatting C# application with end-to-end encryption.
Stars: ✭ 19 (+0%)
Mutual labels:  uwp
TsinghuaNet
清华大学校园网客户端与联网库,适用于 UWP、iOS、Android,其余平台见 tunet-rust
Stars: ✭ 67 (+252.63%)
Mutual labels:  uwp
woadialer
A dialer based on UWP and .NET for the WoA on Lumia Project.
Stars: ✭ 66 (+247.37%)
Mutual labels:  uwp
MindSetUWP
NeuroSky MindWave & MindWave Mobile EEG Headset library for Windows 10 Universal applications
Stars: ✭ 14 (-26.32%)
Mutual labels:  uwp
UltraFaceDotNet
C# version of Ultra-Light-Fast-Generic-Face-Detector-1MB for Windows, MacOS, Linux, iOS and Android
Stars: ✭ 56 (+194.74%)
Mutual labels:  uwp
Portable-WebDAV-Library
Moved to codeberg.org - https://codeberg.org/DecaTec/Portable-WebDAV-Library - The Portable WebDAV Library is a strongly typed, async WebDAV client library which is fully compliant to RFC 4918, RFC 4331 and "Additional WebDAV Collection Properties". It is implemented as .NETStandard 1.1 library in oder to be used on any platform supporting .NETS…
Stars: ✭ 45 (+136.84%)
Mutual labels:  uwp
fhash
fHash - an open source files hash calculator for Windows and macOS
Stars: ✭ 222 (+1068.42%)
Mutual labels:  uwp
Nethereum.UI.Wallet.Sample
Cross platform wallet example using Nethereum, Xamarin.Forms and MvvmCross
Stars: ✭ 77 (+305.26%)
Mutual labels:  uwp
WinDev-Utility
A utility for windows developers
Stars: ✭ 17 (-10.53%)
Mutual labels:  uwp
Denna
Denna to-do list application
Stars: ✭ 21 (+10.53%)
Mutual labels:  uwp
ContextMenuForWindows11
Add Custom Context Menu For Windows11
Stars: ✭ 693 (+3547.37%)
Mutual labels:  uwp
MADE.NET
MADE.NET is a home to all of those bits of code that you know you'll reuse in another project. Making app development easier with .NET.
Stars: ✭ 75 (+294.74%)
Mutual labels:  uwp
Xalami
A delicious way to kickstart your Xamarin Forms project
Stars: ✭ 18 (-5.26%)
Mutual labels:  uwp
MQTTnet
MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). The implementation is based on the documentation from http://mqtt.org/.
Stars: ✭ 3,309 (+17315.79%)
Mutual labels:  uwp
LocalNotifications
Create and manage in-app notifications in Universal Windows applications.
Stars: ✭ 37 (+94.74%)
Mutual labels:  uwp
IoTHAT
Turta IoT HAT Source, Reference and Manual.
Stars: ✭ 23 (+21.05%)
Mutual labels:  uwp
UWP-MVVM-Toolkit-Sample
Demonstrates using the Windows Community MVVM Toolkit in a UWP app.
Stars: ✭ 31 (+63.16%)
Mutual labels:  uwp
uno.toolkit.ui
A set of custom controls for the WinUI and the Uno Platform not offered out of the box by WinUI, such as Card, TabBar, NavigationBar, etc.
Stars: ✭ 45 (+136.84%)
Mutual labels:  uwp

Base REST service for Universal Apps

NuGet version Build status MIT licensed UWP ready WinRT ready WPA81 ready

Base class for a Windows Phone 8.1 (Silverlight), Windows Phone 8.1 XAML and Windows 8.1 REST service implementation. Also works fin in Windows 10 projects (UWP).

Installation

PM> Install-Package Kulman.WPA81.BaseRestService

Usage

Create your service class and inherit from BaseRestService. The minimum you need to do to make it work is to override the GetBaseUrl() method to set the base url for all the requests.

public class MyDataService: BaseRestService
{
    protected override string GetBaseUrl()
    {
        return "my base url";
    }
}

You can (but do not have to) also override the GetRequestHeaders() method to set the default request headers.

protected override Dictionary<string, string> GetRequestHeaders(string requestUrl)
{
    return new Dictionary<string, string>
    {
        { "Accept-Encoding", "gzip, deflate" },
        { "Accept", "application/json" },
    };
}

You can also override the CreateJsonSerializerSettings method with you need custom JSON deserialization settings.

Now you can use the following methods in your class:

Task<T> Get<T>(string url);
Task<T> Put<T>(string url, object request);
Task<T> Post<T>(string url, object request);
Task<T> Patch<T>(string url, object request);
Task Delete(string url);
Task<Dictionary<string, string>> Head(string url);

If you need to get the raw request, there are overloads returning HttpResponseMessage:

Task<HttpResponseMessage> Get(string url);
Task<HttpResponseMessage> Put(string url, object request);
Task<HttpResponseMessage> Post(string url, object request);
Task<HttpResponseMessage> Patch(string url, object request);

All the available methods have overloads accepting and CancellationToken.

Methods in your service may then look like this

public Task<List<Account>> GetAccounts()
{
    return Get<List<Account>>("/accounts");
}
 
public Task<Account> UpdateAccount(Account account)
{
    return Patch<Account>("/accounts",account);
}

For more information, see my blog post REST service base class for Windows Phone 8.1 XAML apps.

For changes, see the changelog.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].