public override void OnCreate() { // This will be called whenever anything happens for the first time - including a receiver or service being started. _current = new WeakReference <NativeDroidApplication>(this); ViewPump.Init(ViewPump.InvokeBuilder() .AddInterceptor(new BindingInterceptor()) .Build()); // Register the view model to view mappings foreach (var mapping in GetViewModelToViewMappings()) { ViewModelToViewConverter.AddMapping(mapping.Key, mapping.Value); } // Register splash mappings foreach (var mapping in GetViewModelToSplashMappings()) { ViewModelToViewConverter.AddSplashMapping(mapping.Key, mapping.Value); } // Register the obtain dispatcher function PortableDispatcher.ObtainDispatcherFunction = () => { return(new AndroidDispatcher()); }; // Register message dialog PortableMessageDialog.Extension = (messageDialog) => { AndroidMessageDialog.Show(messageDialog); return(Task.FromResult(true)); }; PortableLocalizedResources.CultureExtension = GetCultureInfo; // Initialize the app PortableApp.InitializeAsync((PortableApp)Activator.CreateInstance(GetPortableAppType())); base.OnCreate(); }
/// <summary> /// Loads the current module. /// </summary> protected override bool LoadInternal() { Application application = Application.Current; if (application == null || application.Resources == null) { return(false); } var dictionary = application.Resources; var converter = new ViewModelToViewConverter(); SetItem(dictionary, "ViewModelToViewConverterInternal", converter); SetItem(dictionary, "ViewModelToViewConverter", converter); var container = IocContainer ?? ServiceProvider.IocContainer; IViewMappingProvider provider; if (container == null || !container.TryGet(out provider)) { foreach (Assembly assembly in Context.Assemblies) { foreach (Type type in assembly.SafeGetTypes(Mode != LoadMode.Design)) { AddTemplate(dictionary, type); } } } else { foreach (var viewMappingItem in provider.ViewMappings) { AddTemplate(dictionary, viewMappingItem.ViewModelType); } } return(true); }
public NativeUwpApplication() { // Register the view model to view mappings foreach (var mapping in GetViewModelToViewMappings()) { ViewModelToViewConverter.AddMapping(mapping.Key, mapping.Value); } // Register the obtain dispatcher function PortableDispatcher.ObtainDispatcherFunction = () => { return(new UwpDispatcher()); }; // Register message dialog PortableMessageDialog.Extension = UwpMessageDialog.ShowAsync; PortableLocalizedResources.CultureExtension = GetCultureInfo; // Initialize the app PortableApp.InitializeAsync((PortableApp)Activator.CreateInstance(GetPortableAppType())); }
protected override bool LoadInternal() { Application application = Application.Current; if (application == null || application.Resources == null) return false; var dictionary = application.Resources; var converter = new ViewModelToViewConverter(); SetItem(dictionary, "ViewModelToViewConverterInternal", converter); SetItem(dictionary, "ViewModelToViewConverter", converter); var container = IocContainer ?? ServiceProvider.IocContainer; IViewMappingProvider provider; if (container == null || !container.TryGet(out provider)) { foreach (Assembly assembly in Context.Assemblies) foreach (Type type in assembly.SafeGetTypes(!Mode.IsDesignMode())) AddTemplate(dictionary, type); } else { foreach (var viewMappingItem in provider.ViewMappings) AddTemplate(dictionary, viewMappingItem.ViewModelType); } return true; }
static ViewModelToViewConverter() { Instance = new ViewModelToViewConverter(); }
public void AddMapping(Type viewModelType, Type viewControllerType) { ViewModelToViewConverter.AddMapping(viewModelType, viewControllerType); }