public void EnsureInitialized(Context applicationContext) { if (MvxSimpleIoCContainer.Instance != null) { return; } var ioc = MvxSimpleIoCContainer.Initialize(); ioc.RegisterSingleton <IMvxPluginManager>(new MvxFilePluginManager(".Droid", ".dll")); ioc.RegisterSingleton <IMvxAndroidGlobals>(new AndroidGlobals(applicationContext, GetType().Namespace)); var topActivity = new AndroidTopActivity(); ioc.RegisterSingleton <ITopActivity>(topActivity); ioc.RegisterSingleton <IMvxMainThreadDispatcher>(topActivity); var builder = new MvxAndroidBindingBuilder(); builder.DoRegistration(); var viewCache = ioc.Resolve <IMvxTypeCache <View> >(); viewCache.AddAssembly(typeof(View).Assembly); var namespaces = ioc.Resolve <IMvxNamespaceListViewTypeResolver>(); namespaces.Add("Android.Views"); namespaces.Add("Android.Widget"); namespaces.Add("Android.Webkit"); }
public static void Check() { if (_checked) { return; } _checked = true; // if Application.Current == null Forms is in design mode if (Application.Current != null) { return; } if (MvxSingleton <IMvxIoCProvider> .Instance == null) { var iocProvider = MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton(iocProvider); } if (!Mvx.CanResolve <IMvxBindingParser>()) { //We might want to look into returning the platform specific Forms binder var builder = new MvxBindingBuilder(); builder.DoRegistration(); } }
public static void Check() { if (_checked) { return; } _checked = true; #if WINDOWS_WPF if (!(bool)DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue) { return; } #endif #if WINDOWS_COMMON if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } #endif if (MvxSingleton <IMvxIoCProvider> .Instance == null) { var iocProvider = MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton(iocProvider); } if (!Mvx.CanResolve <IMvxBindingParser>()) { var builder = new MvxWindowsBindingBuilder(MvxWindowsBindingBuilder.BindingType.MvvmCross); builder.DoRegistration(); } }
public static void RegisterTypes() { MvxSimpleIoCContainer.Initialize(); Mvx.RegisterType <ILoginService, LoginService> (); Mvx.RegisterType <IStopWatchWrapper, StopWatchWrapper> (); Mvx.RegisterType <IApiService, ApiService> (); }
public void TryResolve_WithAttrInjection_AttrMarkedProperiesGetInjected() { MvxSingleton.ClearAllSingletons(); var options = new MvxIocOptions { PropertyInjectorOptions = new MvxPropertyInjectorOptions() { InjectIntoProperties = MvxPropertyInjection.MvxInjectInterfaceProperties } }; var instance = MvxSimpleIoCContainer.Initialize(options); Mvx.RegisterType <IA, A>(); Mvx.RegisterType <IB, B>(); Mvx.RegisterType <IC, C>(); IA a; var result = Mvx.TryResolve(out a); Assert.IsTrue(result); Assert.IsNotNull(a); Assert.IsInstanceOf <A>(a); var castA = (A)a; Assert.IsNotNull(castA.B); Assert.IsInstanceOf <B>(castA.B); Assert.IsNull(castA.C); Assert.IsNull(castA.BNever); Assert.IsNull(castA.CNever); }
public static void Check() { if (_checked) { return; } _checked = true; if (!DesignMode.DesignModeEnabled) { return; } if (MvxSingleton <IMvxIoCProvider> .Instance == null) { var iocProvider = MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton(iocProvider); } if (!Mvx.CanResolve <IMvxBindingParser>()) { var builder = new MvxWindowsBindingBuilder(MvxWindowsBindingBuilder.BindingType.MvvmCross); builder.DoRegistration(); } }
public void EnsureInitialized(Context context) { if (MvxSimpleIoCContainer.Instance != null) { return; } ApplicationContext = context; MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton <IMvxAndroidGlobals>(this); var plugin = new MvxFilePluginManager(".Droid", ".dll"); Mvx.RegisterSingleton <IMvxPluginManager>(plugin); var builder = new MvxAndroidBindingBuilder(); builder.DoRegistration(); var viewCache = Mvx.Resolve <IMvxTypeCache <View> >(); viewCache.AddAssembly(typeof(Android.Widget.LinearLayout).Assembly); var valueConverterRegistry = Mvx.Resolve <IMvxValueConverterRegistry>(); valueConverterRegistry.AddOrOverwrite("TheLengthConverter", new LengthValueConverter()); var locationBootstrap = new LocationPluginBootstrap(); locationBootstrap.Run(); }
public void EnsureInit(IMvxAndroidGlobals androidGlobals) { if (MvxSimpleIoCContainer.Instance != null) { return; } MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton <IMvxTrace>(new MvxDebugTrace()); MvxTrace.Initialize(); Mvx.RegisterSingleton <IMvxAndroidGlobals>(androidGlobals); new MvxAndroidBindingBuilder().DoRegistration(); var viewCache = Mvx.Resolve <IMvxTypeCache <View> >(); viewCache.AddAssembly(typeof(View).Assembly); var namespaces = Mvx.Resolve <IMvxNamespaceListViewTypeResolver>(); namespaces.Add("Android.Views"); namespaces.Add("Android.Widget"); namespaces.Add("Android.Webkit"); }
public static void Initialize() { MvxSimpleIoCContainer.Initialize(); Mvx.LazyConstructAndRegisterSingleton <INavigationMenuService <Activity>, NavigationMenuService>(); Mvx.RegisterSingleton(typeof(IStringLookup), new StringLookup(this.ApplicationContext)); }
public void EnsureInitialized(Context applicationContext) { if (MvxSimpleIoCContainer.Instance != null) { return; } var ioc = MvxSimpleIoCContainer.Initialize(); ioc.RegisterSingleton <IMvxTrace>(new MvxDebugOnlyTrace()); MvxTrace.Initialize(); ioc.RegisterSingleton <IMvxAndroidGlobals>(new AndroidGlobals(applicationContext)); var builder = new MvxAndroidBindingBuilder(); builder.DoRegistration(); var viewCache = ioc.Resolve <IMvxTypeCache <View> >(); viewCache.AddAssembly(typeof(View).Assembly); var namespaces = ioc.Resolve <IMvxNamespaceListViewTypeResolver>(); namespaces.Add("Android.Views"); namespaces.Add("Android.Widget"); namespaces.Add("Android.Webkit"); }
public override void OnCreate() { MvxSimpleIoCContainer.Initialize(); Mvx.RegisterType <IPlatform, DroidPlatform> (); Mvx.RegisterType <ISettings, DroidSettings> (); base.OnCreate(); }
public static void Initialize() { BlobCache.ApplicationName = "MahTestApp"; BlobCache.EnsureInitialized(); MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton <IBlobCache>(() => BlobCache.LocalMachine); Mvx.RegisterType <IPlatform, ApplePlatform> (); Mvx.RegisterType <ISettings, AppleSettings> (); }
public void Non_generic_RegisterType_with_constructor_throws_if_constructor_returns_incompatible_value() { MvxSingleton.ClearAllSingletons(); var instance = MvxSimpleIoCContainer.Initialize(); instance.RegisterType(typeof(IC), () => 36); var c1 = Mvx.Resolve <IC>(); }
public static void ClassInitialize(TestContext t) { ServiceLocator.AzureMobileService = new AzureMobileService(); ServiceLocator.ResourceFileService = new TestResourceFileService(); ServiceLocator.MessageService = new TestMessageService(); var iocProvider = MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton <IMvxFileStore>(new MvxWpfFileStore()); }
public static void Initialize() { if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } var iocProvider = MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton(iocProvider); }
public void Non_generic_RegisterType_with_constructor_throws_if_constructor_returns_incompatible_reference() { MvxSingleton.ClearAllSingletons(); var instance = MvxSimpleIoCContainer.Initialize(); instance.RegisterType(typeof(IC), () => "Fail"); Assert.Throws <MvxIoCResolveException>(() => { var c1 = Mvx.Resolve <IC>(); }); }
public static void ResetContext() { MvxSingleton.ClearAllSingletons(); var ioc = MvxSimpleIoCContainer.Initialize(null); ioc.RegisterSingleton(ioc); ioc.RegisterSingleton <IMvxTrace>(new UnitTestTrace()); MvxSingletonCache.Initialize(); ioc.RegisterSingleton <IMvxSettings>(new MvxSettings()); MvxTrace.Initialize(); }
public override void OnCreate() { BlobCache.ApplicationName = "MahTestApp"; BlobCache.EnsureInitialized(); MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton <IBlobCache>(() => BlobCache.LocalMachine); Mvx.RegisterType <IPlatform, DroidPlatform> (); Mvx.RegisterType <ISettings, DroidSettings> (); base.OnCreate(); }
public static void Register() { MvxSimpleIoCContainer.Initialize(); Mvx.ConstructAndRegisterSingleton <IUserDialogService, UserDialogService>(); Mvx.ConstructAndRegisterSingleton <IGitHubDataProvider, GitHubDataProvider>(); Mvx.ConstructAndRegisterSingleton <INavigationService, NavigationService>(); Mvx.RegisterType <IRepositoriesViewModel, RepositoriesViewModel>(); Mvx.RegisterType <IRepositoryDetailsViewModel, RepositoryDetailsViewModel>(); }
protected virtual void ClearAll() { // fake set up of the IoC MvxSingleton.ClearAllSingletons(); this._ioc = MvxSimpleIoCContainer.Initialize(this.CreateIocOptions()); this._ioc.RegisterSingleton(this._ioc); this._ioc.RegisterSingleton <IMvxTrace>(new TestTrace()); InitializeSingletonCache(); this.InitializeMvxSettings(); MvxTrace.Initialize(); this.AdditionalSetup(); }
protected void ClearAll() { // fake set up of the IoC MvxSingleton.ClearAllSingletons(); _ioc = MvxSimpleIoCContainer.Initialize(); _ioc.RegisterSingleton(_ioc); _ioc.RegisterSingleton <IMvxTrace>(new TestTrace()); RegisterAdditionalSingletons(); InitialiseSingletonCache(); InitialiseMvxSettings(); MvxTrace.Initialize(); }
protected MvxDesignTimeHelper() { if (!IsInDesignTool) { return; } if (MvxSingleton <IMvxIoCProvider> .Instance == null) { var iocProvider = MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton(iocProvider); } }
private static void Configurate() { ////здесь будет конфигурироваться DI контейнер MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton <IOrderService>(new OrderService()); Mvx.RegisterSingleton <IUserService>(new UserService()); Mvx.RegisterSingleton <IOrderHubService>(new OrderHubService()); Mvx.ConstructAndRegisterSingleton <IUserController, UserController>(); Mvx.ConstructAndRegisterSingleton <IOrderController, OrderController>(); }
public void EnsureInitialized(Context applicationContext) { if (MvxSimpleIoCContainer.Instance != null) { return; } var ioc = MvxSimpleIoCContainer.Initialize(); ioc.RegisterSingleton <IMvxPluginManager>(new MvxFilePluginManager(".Droid", ".dll")); ioc.RegisterSingleton <IMvxAndroidGlobals>(new AndroidGlobals(applicationContext, GetType().Namespace)); }
public static void Initialize(Context applicationContext) { MvxSimpleIoCContainer.Initialize(); Mvx.LazyConstructAndRegisterSingleton <INavigationMenuService <Fragment>, NavigationMenuService>(); Mvx.RegisterSingleton(typeof(IStringLookupService), new StringLookupService(applicationContext)); Mvx.RegisterSingleton(typeof(IVersionInfo), new VersionInfoService(applicationContext)); Mvx.LazyConstructAndRegisterSingleton <ILoggingService, FileLoggingService>(); Mvx.LazyConstructAndRegisterSingleton <IFileHelper, FileHelper>(); Mvx.LazyConstructAndRegisterSingleton <IJobsService, JobsService>(); Mvx.LazyConstructAndRegisterSingleton <IITunesDataService, ITunesDataService>(); Mvx.LazyConstructAndRegisterSingleton <ICreateHttpClientHelper, AndroidConnectionHandlerCreator>(); }
public void EnsureInit() { if (MvxSimpleIoCContainer.Instance != null) { return; } var ioc = MvxSimpleIoCContainer.Initialize(); var builder = new MvxTouchBindingBuilder(); builder.DoRegistration(); }
public static void Resolves_unsuccessfully_when_registered_open_generic_with_one_generic_parameter_that_was_not_registered() { var instance = MvxSimpleIoCContainer.Initialize(); ((MvxSimpleIoCContainer)instance).CleanAllResolvers(); IOG <C2> toResolve = null; var isResolved = Mvx.TryResolve <IOG <C2> >(out toResolve); Assert.IsFalse(isResolved); Assert.IsNull(toResolve); }
public static void ClassInitialize(TestContext t) { ServiceLocator.AzureMobileService = new AzureMobileService(); ServiceLocator.ResourceFileService = new TestResourceFileService(); ServiceLocator.MessageService = new TestMessageService(); var iocProvider = MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton <IMvxFileStore>(new MvxWpfFileStore()); itemsShowcaseViewModel = new ItemsShowcaseViewModel(); MonitorLoadingItems(); Debug.WriteLine("Initial DataSources Loaded " + DateTime.Now.ToString()); }
static BaseMvvmCrossTest() { if (MvxSimpleIoCContainer.Instance == null) { MvxSingletonCache.Initialize(); MvxSimpleIoCContainer.Initialize(); MvxSimpleIoCContainer.Instance.RegisterSingleton(MvxSimpleIoCContainer.Instance); MvxSimpleIoCContainer.Instance.RegisterSingleton <IMvxTrace>(new TestTrace()); MvxSimpleIoCContainer.Instance.RegisterSingleton <IMvxSettings>(new MvxSettings()); MvxTrace.Initialize(); } }
public void EnsureInit() { if (MvxSimpleIoCContainer.Instance != null) { return; } MvxSimpleIoCContainer.Initialize(); Mvx.RegisterSingleton <IMvxTrace>(new MvxDebugTrace()); MvxTrace.Initialize(); new MvxTouchBindingBuilder().DoRegistration(); }