Git Product home page Git Product logo

azuremobileclient.helpers's Introduction

AzureMobileClient.Helpers

AzureMobileClient.Helpers is a lightweight toolkit for using the Microsoft Azure Mobile Client. It provides a set of abstractions and base classes that are based originally on the Samples from Adrian Hall, along with a few tweaks to follow best practices with an interface based design.

Note that this library has been aligned with the Microsoft.Azure.Mobile.Client and is offered using NetStandard1.4 and as such is not compatible with traditional PCL projects. For this reason, it is recommended that you check out the Prism Templates I have available for dotnet new which use a NetStandard1.4 common library for the shared code.

Package Version MyGet
AzureMobileClient.Helpers HelpersShield HelpersMyGetShield
AzureMobileClient.Helpers.Autofac HelpersAutofacShield HelpersAutofacMyGetShield
AzureMobileClient.Helpers.DryIoc HelpersDryIocShield HelpersDryIocMyGetShield
AzureMobileClient.Helpers.SimpleInjector HelpersSimpleInjectorShield HelpersSimpleInjectorMyGetShield
AzureMobileClient.Helpers.Unity HelpersUnityShield HelpersUnityMyGetShield
AzureMobileClient.Helpers.AzureActiveDirectory HelpersAADShield HelpersAADMyGetShield

Support

If this project helped you reduce time to develop and made your app better, please help support this project.

paypal

Resources

Setting up the library for Dependency Injection

The following examples are based on using DryIoc in a Prism Application:

protected override void RegisterTypes()
{
    // ICloudTable is only needed for Online Only data
    Container.Register(typeof(ICloudTable<>), typeof(AzureCloudTable<>), Reuse.Singleton);
    Container.Register(typeof(ICloudSyncTable<>), typeof(AzureCloudSyncTable<>), Reuse.Singleton);

    Container.UseInstance<IPublicClientApplication>(new PublicClientApplication(Secrets.AuthClientId, AppConstants.Authority)
    {
        RedirectUri = AppConstants.RedirectUri
    });

    Container.RegisterMany<AADOptions>(reuse: Reuse.Singleton,
                                       serviceTypeCondition: type =>
                                                type == typeof(IAADOptions) ||
                                                type == typeof(IAADLoginProviderOptions));

    Container.Register<IAzureCloudServiceOptions, AppServiceContextOptions>(Reuse.Singleton);
    Container.RegisterMany<AppDataContext>(reuse: Reuse.Singleton,
                                           serviceTypeCondition: type => 
                                                type == typeof(IAppDataContext) ||
                                                type == typeof(ICloudService));
    Container.RegisterDelegate<IMobileServiceClient>(factoryDelegate: r => r.Resolve<ICloudService>().Client,
                                                     reuse: Reuse.Singleton,
                                                     setup: Setup.With(allowDisposableTransient: true));
    Container.Register<ILoginProvider<AADAccount>,LoginProvider>(Reuse.Singleton);
}
public class AwesomeAppCloudServiceOptions : IAzureCloudServiceOptions
{
    public string AppServiceEndpoint => "https://yourappname.azurewebsites.net";
    public string AlternateLoginHost => string.Empty;
    public string LoginUriPrefix => string.Empty;
    public HttpMessageHandler[] Handlers => new HttpMessageHandler[0];
}

public class AwesomeAppCustomerAppContext : DryIocCloudAppContext
{
    public MyAppClient(IContainer container)
        // We can optionally pass in a database name
        : base(container, "myDatabaseName.db")
    {

    }

    /*
     * NOTE: This is architected to be similar to Entity Framework in that
     * the CloudAppContext will look for properties that are ICloudSyncTable<>
     * so that it can register the Model type with the SQLite Store.
     */
    public ICloudSyncTable<Customer> Customers => SyncTable<Customer>();
    public ICloudSyncTable<Invoice> Invoices => SyncTable<Invoice>();
    public ICloudSyncTable<InvoiceItem> InvoiceItems => SyncTable<InvoiceItem>();
    public ICloudTable<Feedback> Feedback => Table<Feedback>();

}

public class Customer : EntityData
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Email { get; set; }
}

public class Invoice : EntityData
{
    public string CustomerId { get; set; }
}

public class InvoiceItem : EntityData
{
    public string InvoiceId { get; set; }
    public string ItemId { get; set; }
    public int Quantity { get; set; }
}

public class Feedback : EntityData
{
    public string Message { get; set; }
    public string Status { get; set; }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.