/ChilliSource.Mobile.Ioc

DI container plugins for ChilliSource Mobile

Primary LanguageC#MIT LicenseMIT

License: MIT Built With C#

ChilliSource.Mobile.Ioc

This project is part of the ChilliSource framework developed by BlueChilli.

Summary

ChilliSource.Mobile.Ioc provides a DryIoc based dependency resolver for the Splat Service Locator.

Usage

Registering dependencies with the IoC Container

var container = new Container();
container.Register<ITestInterface, ImpTestClassObject>();
container.Register<ParentObject, ParentObject>();
container.Register<ChildObject, ChildObject>();

For more information please read the DryIoc Documentation

Registering the resolver with the Splat Service Locator

container.UseDryIocDependencyResolver();

Registering dependencies via the Splat Service Locator

Locator.CurrentMutable.Register(() => new ChildObject(), typeof(ChildObject));

For more information please read the Splat Documentation

ReactiveUI Integration

Register all views in the assembly

The following code will register all views in the assembly that implement ReactiveUI's IViewFor<T> interface:

var assembly = typeof(HomePageViewModel).Assembly;
container.RegisterViews(assembly);
container.UseDryIocDependencyResolver();

Register all view models in the assembly

Based on the MVVM convention of naming view models with the "ViewModel" suffix, the following code will search for all types suffixed with "ViewModel" in the assembly and register them in the container in order to automatically link them to their corresponding views.

var assembly = typeof(HomePageViewModel).Assembly;
container.RegisterViewModels(assembly);
container.UseDryIocDependencyResolver();

Resolve dependencies via the Splat Service Locator

var child = Locator.Current.GetService<ChildObject>();

Installation

The libraries are available via NuGet:

Releases

See the releases.

Contribution

Please see the Contribution Guide.

License

ChilliSource.Mobile is licensed under the MIT license.

Feedback and Contact

For questions or feedback, please contact chillisource@bluechilli.com.