forked from reactiveui/ReactiveUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppBootstrapper.cs
More file actions
69 lines (56 loc) · 2.18 KB
/
AppBootstrapper.cs
File metadata and controls
69 lines (56 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using ReactiveUI;
using ReactiveUI.Cocoa;
using ReactiveUI.Mobile;
using System.Runtime.Serialization;
using Splat;
using TinyIoC;
using MonoTouch.UIKit;
using System.Linq;
using System.Collections.Generic;
namespace iOSPlayground
{
public class AppBootstrapper : ReactiveObject, IApplicationRootState
{
[IgnoreDataMember]
public TinyIoCContainer Kernel { get; protected set; }
[DataMember]
public IRoutingState Router { get; protected set; }
public AppBootstrapper()
{
Router = new RoutingState();
Kernel = new TinyIoCContainer();
// XXX: This is gross
Kernel.Register<UIViewController>(new RouterUINavigationController(Router), "InitialPage");
Kernel.Register(typeof(IViewFor<iOSPlaygroundViewModel>), typeof(iOSPlaygroundViewController));
Kernel.Register<IScreen>(this);
var toRegister = new Dictionary<Tuple<Type, String>, List<Type>>();
// TODO: Fix Me
//RxApp.ConfigureServiceLocator(
// (t, s) => s != null ? Kernel.Resolve(t, s) : Kernel.Resolve(t),
// (t, s) => Kernel.ResolveAll(t, true),
// (c, t, s) => {
// if (toRegister != null) {
// var pair = Tuple.Create(t,s);
// if (!toRegister.ContainsKey(pair)) {
// toRegister[pair] = new List<Type>();
// }
// toRegister[pair].Add(c);
// return;
// }
// if (s != null) {
// Kernel.Register(t, c, s);
// } else {
// Kernel.Register(t, c);
// }
// });
foreach(var key in toRegister.Keys) {
var val = toRegister[key].Distinct();
Kernel.RegisterMultiple(key.Item1, val);
}
toRegister = null;
var items = Kernel.ResolveAll(typeof(ICreatesObservableForProperty), true).ToArray();
// Router.Navigate.Go<iOSPlaygroundViewModel>();
}
}
}