Esempio n. 1
0
        public EditSensorViewModel(IWindowManager windowManager, SimpleContainer container)
        {
            _windowManager = windowManager;
            _container = container;

            Templates = SensorTemplate.ImportAll();
        }
        public void The_child_container_returned_contains_parent_entries() {
            var container = new SimpleContainer();
            container.PerRequest<object>();
            var childContainer = container.CreateChildContainer();

            Assert.NotNull(childContainer.GetInstance(typeof (object), null));
        }
Esempio n. 3
0
 public void RegisterDependencies(SimpleContainer container)
 {
     container.Register<DefaultController>();
     container.Register<QuotesController>();
     container.Register<IClock, Clock>();
     container.Register<IQuotesRepository, QuotesRepository>();
 }
Esempio n. 4
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init ();
            Xamarin.FormsMaps.Init ();
            // Code for starting up the Xamarin Test Cloud Agent
            #if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
            #endif

            MR.Gestures.iOS.Settings.LicenseKey = "6XZT-V54J-73E4-4VK8-RFAJ-ZBS8-Q8UB-Y3W7-BSGP-FETM-EYQ9-QEPP-WRTA";
            CachedImageRenderer.Init ();

            //ImageService.Initialize(
            //Necessary IOC Code To Get Device Properties
            var container = new SimpleContainer ();
            container.Register<IDevice> (t => AppleDevice.CurrentDevice);
            container.Register<IDisplay> (t => t.Resolve<IDevice> ().Display);
            if( !Resolver.IsSet )
                Resolver.SetResolver (container.GetResolver ());

            // Initialize the parse bluemart client
            try
            {
                ParseClient.Initialize("EUDL8rKwCc1JcL8tw5KsW1QB9ePSGx2dSBTobbE5","PNOG7XhRV8tuB907fQ0S0b5ShaIzYN0wVPZ3AyoN");
            }
            catch(ParseException e) {
                //Log.Warn("BlueMart",e.Message.ToString());
            }

            LoadApplication (new App ());

            return base.FinishedLaunching (app, options);
        }
Esempio n. 5
0
        //  Inversion of control setup
        private void SetIoc()
        {
            var resolverContainer = new SimpleContainer();

            var app = new XFormsAppiOS();
            app.Init(this);
            resolverContainer.Register<IXFormsApp>(app);

            var documents = app.AppDataDirectory;

            // UNEEDED CONTROLS FOR TEST
            //resolverContainer.Register<IGeolocator, Geolocator>();
            //resolverContainer.Register<IEmailService, EmailService>();
            //resolverContainer.Register<IMediaPicker, MediaPicker>();
            //resolverContainer.Register<IDevice>( t => AppleDevice.CurrentDevice);
            Resolver.SetResolver(resolverContainer.GetResolver());

            DependencyService.Register<Geolocator> ();

            //resolverContainer.Register<IDevice>(t => AndroidDevice.CurrentDevice);
            //Resolver.SetResolver(resolverContainer.GetResolver());

            //  Startup location services

            Util util = new Util ();
            util.EnableLocationServices ();
        }
 public void HasHandler_returns_true_when_handler_exists() {
     var container = new SimpleContainer();
     container.RegisterPerRequest(typeof (object), "Object", typeof (object));
     
     Assert.True(container.HasHandler(typeof (object), null));
     Assert.True(container.HasHandler(null, "Object"));
 }
Esempio n. 7
0
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     // init stubs
     var fakeExplorer = new Mock<Explorer>();
     fakeExplorer.SetupAllProperties();
     var fakeMailItem = new Mock<MailItem>();
     fakeMailItem.SetupAllProperties();
     fakeMailItem.Object.Subject = "test subj";
     fakeMailItem.Object.Body = "test body";
     var atts = new Mock<Attachments>();
     atts.Setup(a => a.GetEnumerator()).Returns(ProductList);
     fakeMailItem.SetupGet(m => m.Attachments).Returns(atts.Object);
     var _container = new SimpleContainer()
         .RegisterSingle(fakeExplorer)
         .Register<IView>(container => new NewWorkItem())
         .Register<AppViewModel>(container => new AppViewModel())
         .Register<IPresenter>(container => new Presenter
         {
             View = container.Create<IView>(),
             ViewModel = container.Create<AppViewModel>()
         });
     
     var form = _container.Create<IPresenter>();
     form.Initialize(fakeMailItem.Object);
 }
Esempio n. 8
0
        private void SetIoc()
        {
            var resolverContainer = new SimpleContainer();

            var app = new XFormsAppiOS();
            app.Init(this);
            resolverContainer.Register<IXFormsApp>(app);

            var documents = app.AppDataDirectory;

            //resolverContainer.Register<IGeolocator, Geolocator>();
            //resolverContainer.Register<IEmailService, EmailService>();
            //resolverContainer.Register<IMediaPicker, MediaPicker>();
            //resolverContainer.Register<IDevice>( t => AppleDevice.CurrentDevice);
            Resolver.SetResolver(resolverContainer.GetResolver());

            DependencyService.Register<Geolocator> ();

            //resolverContainer.Register<IDevice>(t => AndroidDevice.CurrentDevice);
            //Resolver.SetResolver(resolverContainer.GetResolver());

            Console.WriteLine ("Here");
            Util util = new Util ();
            util.EnableLocationServices ();

            //manager.AuthorizationChanged += (sender, args) => {
               // Console.WriteLine ("Authorization changed to: {0}", args.Status);
            //};
            //if (UIDevice.CurrentDevice.CheckSystemVersion(8,0))
            //    manager.RequestWhenInUseAuthorization();
        }
Esempio n. 9
0
		/// <summary>
		/// Sets the IoC.
		/// </summary>
		private void SetIoc()
		{
			var resolverContainer = new SimpleContainer();

			var app = new XFormsAppiOS();
			app.Init(this);

			var documents = app.AppDataDirectory;
			var pathToDatabase = Path.Combine(documents, "xforms.db");

			resolverContainer.Register<IDevice>(t => AppleDevice.CurrentDevice)
				.Register<IDisplay>(t => t.Resolve<IDevice>().Display)
				.Register<IFontManager>(t => new FontManager(t.Resolve<IDisplay>()))
				//.Register<IJsonSerializer, XLabs.Serialization.ServiceStack.JsonSerializer>()
				//.Register<IJsonSerializer, Services.Serialization.SystemJsonSerializer>()
				//.Register<ITextToSpeechService, TextToSpeechService>()
				//.Register<IEmailService, EmailService>()
				.Register<IMediaPicker, MediaPicker>()
				.Register<IXFormsApp>(app)
				.Register<ISecureStorage, SecureStorage>()
				.Register<IDependencyContainer>(t => resolverContainer)
				/*.Register<ISimpleCache>(
					t => new SQLiteSimpleCache(new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS(),
						new SQLite.Net.SQLiteConnectionString(pathToDatabase, true), t.Resolve<IJsonSerializer>()))*/;

			Resolver.SetResolver(resolverContainer.GetResolver());
		}
Esempio n. 10
0
        public EditSiteDataViewModel(IWindowManager windowManager, SimpleContainer container)
        {
            _windowManager = windowManager;
            _container = container;

            AllContacts = Contact.ImportAll();
            AllCountries = CountriesHelper.CountriesNames();
            //Hack used to force the damn buttons to update
            DoneCancelVisible = Visibility.Visible;
            DoneCancelVisible = Visibility.Collapsed;
            DoneCancelEnabled = true;
            _cantSave = false;
            AllContacts.CollectionChanged += (o, e) =>
                                                 {
                                                     if (e.Action != NotifyCollectionChangedAction.Add || _contactTypeToUpdate <= -1)
                                                         return;

                                                     if (_contactTypeToUpdate == 0)
                                                     {
                                                         PrimaryContact = e.NewItems[0] as Contact;
                                                     }
                                                     else if (_contactTypeToUpdate == 1)
                                                     {
                                                         SecondaryContact = e.NewItems[0] as Contact;
                                                     }
                                                 };
        }
Esempio n. 11
0
        protected override void Configure() {
            container = new SimpleContainer();

            container.Singleton<IWindowManager, WindowManager>();
            container.Singleton<IEventAggregator, EventAggregator>();
            container.PerRequest<IShell, ShellViewModel>();
        }
Esempio n. 12
0
        private static IRequestClient AugmentClient(SimpleContainer container)
        {
            var progress = container.Get<IProgressService>();
            var handler = container.Get<IRequestClient>();

            return new ErrorHandlingRestClient(new ProgressAwareRestClient(handler, progress));
        }
Esempio n. 13
0
        protected override void Configure()
        {
            container = new SimpleContainer();
            container.Instance(container);

            container.Singleton<App>();
        }
        /// <summary>
        /// Sets the IoC.
        /// </summary>
        private void SetIoc()
        {
            var resolverContainer = new SimpleContainer();

            var app = new XFormsAppDroid();

            app.Init(this);

            var documents = app.AppDataDirectory;
            var pathToDatabase = Path.Combine(documents, "xforms.db");

            resolverContainer.Register<IDevice>(t => AndroidDevice.CurrentDevice)
                .Register<IDisplay>(t => t.Resolve<IDevice>().Display)
                .Register<IJsonSerializer, Services.Serialization.ServiceStackV3.JsonSerializer>()
                .Register<IDependencyContainer>(resolverContainer)
                .Register<IXFormsApp>(app)
                .Register<ISimpleCache>(
                    t => new SQLiteSimpleCache(new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid(),
                        new SQLite.Net.SQLiteConnectionString(pathToDatabase, true), t.Resolve<IJsonSerializer>()));


            Resolver.SetResolver(resolverContainer.GetResolver());

            _initialized = true;
        }
Esempio n. 15
0
 public MDIViewModel(SimpleContainer container) {
     this.Master = container.GetInstance<SettingViewModel>();
     this.Detail = container.GetInstance<TabViewModel>();
     //var vm = container.GetInstance<JobDetailViewModel>();
     //vm.ID = 1178538;
     //this.Detail = vm;
 }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            //initialising shared project variables
            App.screenWidth = (int)UIScreen.MainScreen.Bounds.Width;
            App.screenHeight = (int)UIScreen.MainScreen.Bounds.Height;
            App.cameraAccessGranted = true;

            //initialising the resolver for the devices camera
            //used in the CameraViewModel class for cross-platform
            //camera functionality
            #region Resolver Init
            SimpleContainer container = new SimpleContainer();
            container.Register<IDevice>(t => AppleDevice.CurrentDevice);
            container.Register<IDisplay>(t => t.Resolve<IDevice>().Display);
            container.Register<INetwork>(t => t.Resolve<IDevice>().Network);

            Resolver.SetResolver(container.GetResolver());
            #endregion

            global::Xamarin.Forms.Forms.Init();
            global::Xamarin.FormsMaps.Init();
            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }
Esempio n. 17
0
        public Application(SimpleContainer container)
        {
            this.container = container;

            ConventionManager.AddElementConvention<SearchBar>(SearchBar.TextProperty, "Text", "SearchButtonPressed");

            ViewModelLocator.AddNamespaceMapping("Hubb.Forms.Core.Views", "Hubb.Core.ViewModels");
            ViewLocator.AddNamespaceMapping("Hubb.Core.ViewModels", "Hubb.Forms.Core.Views");

            Initialize();

            container
                .Instance<IGitHubClient>(new GitHubClient(new ProductHeaderValue("hubb-forms", "1.0.0")));

            container
                .Singleton<IAuthenticationService, AuthenticationService>()
                .Singleton<IRepositoryService, RepositoryService>()
                .Singleton<IAppNavigationService, AppNavigationService>();

            container
                .PerRequest<LoginViewModel>()
                .PerRequest<RepositorySearchViewModel>();

            DisplayRootView<LoginView>();
        }
Esempio n. 18
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/Arial-Rounded-MT-Bold.ttf");

            global::Xamarin.Forms.Forms.Init (this, bundle);
                Xamarin.FormsMaps.Init(this, bundle);

            MR.Gestures.Android.Settings.LicenseKey = "6XZT-V54J-73E4-4VK8-RFAJ-ZBS8-Q8UB-Y3W7-BSGP-FETM-EYQ9-QEPP-WRTA";
            CachedImageRenderer.Init ();

            //Necessary IOC Code To Get Device Properties
            var container = new SimpleContainer ();
            container.Register<IDevice> (t => AndroidDevice.CurrentDevice);
            container.Register<IDisplay> (t => t.Resolve<IDevice> ().Display);
            if( !Resolver.IsSet )
                Resolver.SetResolver (container.GetResolver ());

            // Initialize the parse bluemart client
            try
            {
                ParseClient.Initialize("EUDL8rKwCc1JcL8tw5KsW1QB9ePSGx2dSBTobbE5","PNOG7XhRV8tuB907fQ0S0b5ShaIzYN0wVPZ3AyoN");
            }
            catch(ParseException e) {
                Log.Warn("BlueMart",e.Message.ToString());
            }

            LoadApplication (new App ());
        }
        protected override void Configure()
        {
            _container = new SimpleContainer();
            _container.Instance(_container);
            _container.Singleton<IWindowManager, WindowManager>();
            _container.Singleton<IEventAggregator, EventAggregator>();

            _container.Singleton<IUIManager, UIManager>();
            _container.Singleton<IEventDispatcher, EventDispatcher>();

            _container.Singleton<TextBlockViewManager>();
            _container.Singleton<ButtonViewManager>();
            _container.Singleton<ContainerViewManager>();
            _container.Singleton<StackPanelViewManager>();

            _container.Instance<IReactAssemblyProvider>(new ReactAssemblyProvider(SelectAssemblies));

            //            _container.PerRequest<IJavaScriptExecutor, JavaScriptCoreExecutor>();
            _container.PerRequest<IJavaScriptExecutor, WebSocketExecutor>();
            _container.Singleton<IReactBridge, ReactBridgeImpl>();
            _container.PerRequest<IModuleLoader, ModuleLoader>();
            _container.PerRequest<ReactRootViewModel>();
            _container.PerRequest<ReactTextBlockViewModel>();
            _container.PerRequest<ReactButtonViewModel>();
            _container.PerRequest<ReactContainerViewModel>();

            _container.PerRequest<IShell, ShellViewModel>();
            _container.PerRequest<CefSampleViewModel>();
            _container.PerRequest<WebSocketSampleViewModel>();
        }
Esempio n. 20
0
        public void CyclicDependencySimple()
        {
            var c = new SimpleContainer();

            c.RegisterType<ITypeToResolve, ConcreteWithSimpleCyclicDependency>();
            c.Resolve<ITypeToResolve>();
        }
        protected override void OnCreate(Bundle bundle)
        {
            //initialising shared project variables
            App.screenWidth = (int)(Resources.DisplayMetrics.WidthPixels / Resources.DisplayMetrics.Density);
            App.screenHeight = (int)(Resources.DisplayMetrics.HeightPixels / Resources.DisplayMetrics.Density);
            App.cameraAccessGranted = true;

            base.OnCreate(bundle);

            //initialising the resolver for the devices camera
            //used in the CameraViewModel class for cross-platform
            //camera functionality
            #region Resolver Init
            SimpleContainer container = new SimpleContainer();
            container.Register<IDevice>(t => AndroidDevice.CurrentDevice);
            container.Register<IDisplay>(t => t.Resolve<IDevice>().Display);
            container.Register<INetwork>(t => t.Resolve<IDevice>().Network);

            Resolver.SetResolver(container.GetResolver());
            #endregion

            global::Xamarin.Forms.Forms.Init(this, bundle);
            global::Xamarin.FormsMaps.Init (this, bundle);
            LoadApplication(new App());
        }
Esempio n. 22
0
        public void NoResolvableConstructor()
        {
            var c = new SimpleContainer();

            // wyjątek, string nie ma konstruktora bezparametrowego i nie da się rozwikłać żadnego z konstruktorów
            c.Resolve<ConcreteWithStringParam>();
        }
        public HomeViewModel(INavigationService ns, SimpleContainer container) {
            this.DisplayName = "Home";

            this.BtnClickCmd = new Command(() => {
                ns.NavigateToViewModelAsync<ProductViewModel>();
            });
        }
Esempio n. 24
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var resolverContainer = new SimpleContainer();

            resolverContainer.Register<IDevice>(t => AndroidDevice.CurrentDevice)
                .Register<IDisplay>(t => t.Resolve<IDevice>().Display)
                .Register<IFontManager>(t => new FontManager(t.Resolve<IDisplay>()))
                //.Register<IJsonSerializer, Services.Serialization.JsonNET.JsonSerializer>()
                //.Register<IJsonSerializer, JsonSerializer>()
                //.Register<IEmailService, EmailService>()
                .Register<IMediaPicker, MediaPicker>()
                .Register<ITextToSpeechService, TextToSpeechService>()
                .Register<IDependencyContainer>(resolverContainer)
                .Register<IAdvancedTimer>(t => new AdvancedTimer.Forms.Plugin.Droid.AdvancedTimerImplementation());
                //.Register<IXFormsApp>(app)
                //.Register<ISecureStorage>(t => new KeyVaultStorage(t.Resolve<IDevice>().Id.ToCharArray()))
                //.Register<ISimpleCache>(
                //    t => new SQLiteSimpleCache(new SQLitePlatformAndroid(),
                //        new SQLiteConnectionString(pathToDatabase, true), t.Resolve<IJsonSerializer>()));

            Resolver.SetResolver(resolverContainer.GetResolver());

            global::Xamarin.Forms.Forms.Init(this, bundle);
            AdvancedTimer.Forms.Plugin.Droid.AdvancedTimerImplementation.Init();
            LoadApplication(new App());
        }
Esempio n. 25
0
		/// <summary>
		/// Sets the IoC.
		/// </summary>
		private void SetIoc()
		{
			var resolverContainer = new SimpleContainer();

			var app = new XFormsAppDroid();

			app.Init(this);

			var documents = app.AppDataDirectory;
			var pathToDatabase = Path.Combine(documents, "xforms.db");

			resolverContainer.Register<IDevice> (t => AndroidDevice.CurrentDevice)
				.Register<IDisplay> (t => t.Resolve<IDevice> ().Display)
				.Register<IFontManager> (t => new FontManager (t.Resolve<IDisplay> ()))
			//.Register<IJsonSerializer, Services.Serialization.JsonNET.JsonSerializer>()
			//.Register<IJsonSerializer, JsonSerializer>()
			//.Register<IEmailService, EmailService>()
				.Register<IMediaPicker, MediaPicker> ()
			//.Register<ITextToSpeechService, TextToSpeechService>()
				.Register<IDependencyContainer> (resolverContainer)
				.Register<IXFormsApp> (app)
				.Register<ISecureStorage> (t => new KeyVaultStorage (t.Resolve<IDevice> ().Id.ToCharArray ()));
				/*.Register<ISimpleCache>(
					t => new SQLiteSimpleCache(new SQLitePlatformAndroid(),
						new SQLiteConnectionString(pathToDatabase, true), t.Resolve<IJsonSerializer>()));*/


			Resolver.SetResolver(resolverContainer.GetResolver());
		}
Esempio n. 26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            global::Xamarin.Forms.Forms.Init (this, bundle);

            ToastNotificatorImplementation.Init();

            EventProvider.ContentResolver = ContentResolver;
            DependencyService.Register<EventProvider> ();
            DependencyService.Register<EventNotification> ();
            DependencyService.Register<Geolocator> ();

            if (!Resolver.IsSet) {
                var documents = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                var pathToDatabase = Path.Combine(documents, "xforms.db");

                var resolverContainer = new SimpleContainer();
                var serializer = new SystemJsonSerializer();

                resolverContainer
                    .Register<IJsonSerializer> (t => serializer)
                    .Register<IRestClient>(new JsonRestClient(serializer))
                    .Register<ISimpleCache> (
                    t => new SQLiteSimpleCache (new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid (),
                        new SQLite.Net.SQLiteConnectionString (pathToDatabase, true), t.Resolve<IJsonSerializer> ()));

                Resolver.SetResolver(resolverContainer.GetResolver());
            }

            LoadApplication (new App ());
        }
Esempio n. 27
0
        private void RegistModel(SimpleContainer container) {

            var types = this.GetType().GetTypeInfo().Assembly.DefinedTypes
                .Select(t => new { T = t, Mode = t.GetCustomAttribute<RegistAttribute>()?.Mode })
                .Where(o => o.Mode != null && o.Mode != InstanceMode.None);

            foreach (var t in types) {
                var type = t.T.AsType();
                if (t.Mode == InstanceMode.Singleton) {
                    container.RegisterSingleton(type, null, type);
                } else if (t.Mode == InstanceMode.PreRequest) {
                    container.RegisterPerRequest(type, null, type);
                }
            }

            //container
            //    .Singleton<TabViewModel>()
            //    .Singleton<SettingViewModel>()
            //    .Singleton<MDIViewModel>()
            //    .Singleton<IndexViewModel>()
            //    .Singleton<SearchViewModel>()
            //    .Singleton<CompanyPositionsViewModel>()
            //    .Singleton<MyViewModel>()
            //    .Singleton<LoginViewModel>()
            //    .Singleton<FavoritesViewModel>()

            //    .PerRequest<CitySelectorViewModel>()
            //    .PerRequest<JobDetailViewModel>()
            //    .PerRequest<SearchedItemViewModel>()
            //    ;
        }
        private void SetIoC()
        {
            // Create the container
            var container = new SimpleContainer();

            var app = new XFormsAppWP();
            app.Init(this);
            DependencyService.Register<SecureStorage>();
            DependencyService.Register<Geolocator>();
            //DependencyService.Register<IRestClient>();
            //DependencyService.Register<JsonRestClient>();
            //DependencyService.Register<RestCoreClient>();
            DependencyService.Register<IWinAppMethods>();
            container.Register<IDevice>(t => WindowsPhoneDevice.CurrentDevice)
                .Register<ISecureStorage>(t => new SecureStorage())
                .Register<IGeolocator>(t => new Geolocator())
                .Register<IDependencyContainer>(container)
                .Register<IXFormsApp>(app);

            // Get the version number
            //Definitions.VersionNumber = Package.Current.Id.Version.ToString();
            

            // Resolve the container
            Resolver.SetResolver(container.GetResolver());

            // After downgrade to 8.0, scale was no longer available in xlabs implementation.
            Definitions.Scale = Application.Current.Host.Content.ScaleFactor / 100d;
            Definitions.ScreenWidth = Application.Current.Host.Content.ActualWidth;
            Definitions.ScreenHeight = Application.Current.Host.Content.ActualHeight;
            var integ = 1;
        }
Esempio n. 29
0
        public Application(SimpleContainer container)
        {
            this.container = container;

            Initialize();

            ViewModelLocator.AddNamespaceMapping("NDC.Build.Forms.Core.Views", "NDC.Build.Core.ViewModels");
            ViewLocator.AddNamespaceMapping("NDC.Build.Core.ViewModels", "NDC.Build.Forms.Core.Views");

            MessageBinder.SpecialValues.Add("$tappedItem", GetTappedItem);

            container.Instance<FormsApplication>(this);

            container
               .Singleton<ITeamServicesClient, OfflineTeamServicesClient>()
               .Singleton<IAuthenticationService, OfflineAuthenticationService>()
               .Singleton<IApplicationNavigationService, ApplicationNavigationService>()
               .Singleton<IDialogService, ActionSheetDialogService>();

            container
                .PerRequest<LoginViewModel>()
                .PerRequest<ProjectsViewModel>()
                .PerRequest<BuildsViewModel>();

            DisplayRootView<LoginView>();
        }
Esempio n. 30
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            var resolverContainer = new SimpleContainer();

            resolverContainer.Register<IDevice>(t => AppleDevice.CurrentDevice)
                .Register<IDisplay>(t => t.Resolve<IDevice>().Display)
                .Register<IFontManager>(t => new FontManager(t.Resolve<IDisplay>()))
                //.Register<IJsonSerializer, XLabs.Serialization.ServiceStack.JsonSerializer>()
                //.Register<IJsonSerializer, Services.Serialization.SystemJsonSerializer>()
                .Register<ITextToSpeechService, TextToSpeechService>()
                .Register<IEmailService, EmailService>()
                .Register<IMediaPicker, MediaPicker>()
                //.Register<IXFormsApp>(app)
                .Register<ISecureStorage, SecureStorage>()
                .Register<IDependencyContainer>(t => resolverContainer);
            //.Register<ISimpleCache>(
            //    t => new SQLiteSimpleCache(new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS(),
            //        new SQLite.Net.SQLiteConnectionString(pathToDatabase, true), t.Resolve<IJsonSerializer>()));

            Resolver.SetResolver(resolverContainer.GetResolver());
            LoadApplication(new App());
            return base.FinishedLaunching(app, options);
        }
Esempio n. 31
0
 public ValidateViewModel(ShellViewModel conductor, SimpleContainer container)
 {
     this.conductor = conductor;
     this.container = container;
 }
Esempio n. 32
0
        public void Setup()
        {
            FakeRepository repository = new FakeRepository();

            SimpleContainer.MapInstance <IPersonRepository>(repository);
        }
Esempio n. 33
0
 /// <summary>
 /// Get instance in container
 /// </summary>
 /// <param name="T">Interface</param>
 /// <returns>Instance of T</returns>
 public static object GetInstance(Type T)
 {
     return(SimpleContainer.GetInstance(T));
 }
Esempio n. 34
0
 /// <summary>
 /// Get instance in container
 /// </summary>
 /// <typeparam name="T">Interface</typeparam>
 /// <returns>Instance of T</returns>
 public static T GetInstance <T>() where T : class
 {
     return(SimpleContainer.GetInstance <T>());
 }
Esempio n. 35
0
 /// <summary>
 /// Register a interface and implementation in container
 /// </summary>
 /// <param name="T1">Interface</param>
 /// <param name="T2">implementation</param>
 /// <param name="life">Lifecycle of the instance</param>
 /// <param name="args">Parameters of contructor</param>
 public static void Register(Type T1, Type T2, IoCInfraLifeCycle life = IoCInfraLifeCycle.Singleton, params object[] args)
 {
     SimpleContainer.Register(T1, () => Activator.CreateInstance(T2, args), ChooseLife(life));
 }
Esempio n. 36
0
 /// <summary>
 /// Register a interface and implementation in container
 /// </summary>
 /// <param name="T1">Interface</param>
 /// <param name="T2">Implementation</param>
 /// <param name="life">Lifecycle of the instance</param>
 public static void Register(Type T1, Type T2, IoCInfraLifeCycle life = IoCInfraLifeCycle.Singleton)
 {
     SimpleContainer.Register(T1, T2, ChooseLife(life));
 }
Esempio n. 37
0
 /// <summary>
 /// Register a interface and implementation in container
 /// </summary>
 /// <typeparam name="T1">Interface</typeparam>
 /// <typeparam name="T2">Implementation</typeparam>
 /// <param name="life">Lifecycle of the instance</param>
 public static void Register <T1, T2>(IoCInfraLifeCycle life = IoCInfraLifeCycle.Singleton)
     where T1 : class
     where T2 : class
 {
     SimpleContainer.Register(typeof(T1), typeof(T2), ChooseLife(life));
 }
 public ShellViewModel(SimpleContainer container)
 {
     this.container = container;
 }
Esempio n. 39
0
 public ShellProvider(SimpleContainer container)
 {
     _container = container;
 }
Esempio n. 40
0
 public static void RegisterShellProvider(this SimpleContainer simpleContainer)
 {
     simpleContainer.Handler <IShellProvider>(currentContainer => new ShellProvider(currentContainer));
 }
 protected override void Configure()
 {
     _container = new SimpleContainer();
     _container.Instance(_container);
 }
Esempio n. 42
0
        protected override void Configure()
        {
            var config = new TypeMappingConfiguration()
            {
                DefaultSubNamespaceForViews      = "intf.Views",
                DefaultSubNamespaceForViewModels = "intf.Views"
            };

            ViewLocator.ConfigureTypeMappings(config);
            ViewModelLocator.ConfigureTypeMappings(config);


            // -----


            _container = new SimpleContainer();
            _container.Instance(_container);

            // Common
            _container.Singleton <IWindowManager, WindowManager>();
            _container.Singleton <IEventAggregator, EventAggregator>();
            _container.Singleton <IViewModelResolver, ViewModelResolver>();
            _container.Singleton <IFlashMessagesManager, FlashMessagesManager>();
            _container.PerRequest <IValidationObject, ValidationObject>();
            _container.Singleton <IOverlay, Overlay>();

            // Services
            _container.Singleton <PerstStorageFactory>();
            _container.Singleton <StoragePool>();
            _container.Singleton <IIODialogService, FilePathDialogService>();
            _container.Singleton <IListingSectionFactory, ListingSectionFactory>();
            _container.Singleton <IListingsReportFactory, ListingsReportFactory>();
            _container.Singleton <IListingReportGenerator, ListingReportGenerator>();
            _container.Singleton <IBackupImport, BackupImport>();
            _container.Singleton <IEmployerViewModelsFactory, EmployerViewModelsFactory>();
            _container.Singleton <IEmployerFactory, EmployerFactory>();
            _container.Singleton <IListingFactory, ListingFactory>();

            // facades
            _container.Singleton <ListingFacade>();
            _container.Singleton <SettingFacade>();
            _container.Singleton <EmployerFacade>();

            // Windows
            _container.Singleton <MainWindowViewModel>();
            _container.PerRequest <StartupErrorWindowViewModel>();

            // ViewModels
            _container.Singleton <ListingsOverviewViewModel>();
            _container.Singleton <EmployersViewModel>();
            _container.Singleton <ListingViewModel>();
            _container.Singleton <ListingDeletionViewModel>();
            _container.Singleton <ListingDetailViewModel>();
            _container.Singleton <ListingEditingViewModel>();
            _container.Singleton <ListingItemViewModel>();
            _container.Singleton <ListingPdfGenerationViewModel>();
            _container.Singleton <PdfGenerationSettingsViewModel>();
            _container.Singleton <SettingsViewModel>();
            _container.Singleton <EmptyListingsGenerationViewModel>();
            _container.PerRequest <WorkedTimeSettingViewModel>();
            _container.Singleton <ListingsPdfGenerationViewModel>();
            _container.Singleton <CopyListingViewModel>();

            // Subscribers
            _container.Singleton <ListingSubscriber>().GetInstance <ListingSubscriber>();
            _container.Singleton <EmployerSubscriber>().GetInstance <EmployerSubscriber>();
            _container.Singleton <SettingsSubscriber>().GetInstance <SettingsSubscriber>();
        }
 public ShellViewModel(IEventAggregator events, SalesViewModel salesViewModel, SimpleContainer simpleContainer, ILoggedInUserModel loggedOnUser, IAPIHelper aPIHelper)
 {
     Events            = events;
     SalesViewModel    = salesViewModel;
     SimpleContainer   = simpleContainer;
     this.loggedOnUser = loggedOnUser;
     this.aPIHelper    = aPIHelper;
     events.Subscribe(this);
     ActivateItem(SimpleContainer.GetInstance <LoginViewModel>());
 }
Esempio n. 44
0
 public UpdateClassViewModel(IDepartmentRepository departmentRepository, IClassRepository classRepository, IEventAggregator eventAggregator, IWindowManager manager, SimpleContainer container)
 {
     _departmentRepository = departmentRepository;
     _classRepository      = classRepository;
     _eventAggregator      = eventAggregator;
     _manager   = manager;
     _container = container;
     _confirmationDialogHelper = new ConfirmationDialogHelper(_manager, _eventAggregator, _container);
     _eventAggregator.SubscribeOnPublishedThread(this);
 }
 public NavigationService(SimpleContainer container, IWindowManager windowManager)
 {
     _container     = container;
     _windowManager = windowManager;
 }
Esempio n. 46
0
 public The_SimpleContainer()
 {
     container = new SimpleContainer();
 }
Esempio n. 47
0
 public void shouldFindThatIsMoreThanOneLongestConstructorAndThrowException()
 {
     SimpleContainer simpleContainer = new SimpleContainer();
     twoLongConstr   fs = simpleContainer.Resolve <twoLongConstr>();
 }
Esempio n. 48
0
 public void shouldFindThatIsMoreThanOneDepedencyConstructorAndThrowException()
 {
     SimpleContainer simpleContainer = new SimpleContainer();
     var             fs = simpleContainer.Resolve <twoDepedencyConstr>();
 }
Esempio n. 49
0
 public void shouldThrowExceptionBecauseCantResolveOneOfParam()
 {
     SimpleContainer simpleContainer = new SimpleContainer();
     var             fs = simpleContainer.Resolve <X>();
 }
Esempio n. 50
0
 public void shouldFindCycleAndThrowException()
 {
     SimpleContainer simpleContainer = new SimpleContainer();
     ACycle          fs = simpleContainer.Resolve <ACycle>();
 }
Esempio n. 51
0
 public override void InitializeDbConnectionFactory()
 {
     SimpleContainer.RegisterInstance <IDbConnectionFactory>(new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider));
     OrmLiteConfig.DialectProvider.NamingStrategy = new OrmLiteNamingStrategyBase();
     OrmLiteConfig.BeforeExecFilter = cmd => Debug.WriteLine(cmd.GetDebugString());
 }
Esempio n. 52
0
 public ViewModelResolver(SimpleContainer container)
 {
     _container = container;
 }
Esempio n. 53
0
 protected override void Configure()
 {
     _container = new SimpleContainer();
     _container.Singleton <IWindowManager, WindowManager>();
     _container.PerRequest <ShellViewModel>();
 }
Esempio n. 54
0
 public override void InitializeMessaging()
 {
     SimpleContainer.RegisterSingleton <IMessageService>(() => new InMemoryTransientMessageService());
 }
Esempio n. 55
0
 public async Task Execute(SimpleContainer container, INavigationService ns)
 {
     await ns.NavigateToViewModelAsync <JoinWizardViewModel>();
 }
Esempio n. 56
0
 /// <summary>
 /// Initializes the ExApp and creates a Container
 /// </summary>
 protected ExApp()
 {
     Container = new SimpleContainer();
 }
Esempio n. 57
0
 protected override void Configure()
 {
     container = new SimpleContainer();
     container.Instance(container);
     container.Singleton <App>();
 }
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                FormsAppCompatActivity.ToolbarResource   = Resource.Layout.Toolbar;
                FormsAppCompatActivity.TabLayoutResource = Resource.Layout.Tabs;

                base.OnCreate(bundle);

                if (Settings.BuginAndroidAutoresize)
                {
                    this.Window.AddFlags(WindowManagerFlags.Fullscreen);
                    this.Window.AddFlags(WindowManagerFlags.KeepScreenOn);
                    Window.SetSoftInputMode(SoftInput.AdjustResize);
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                    {
                        // Bug in Android 5+, this is an adequate workaround
                        AndroidBug5497WorkaroundForXamarinAndroid.assistActivity(this, WindowManager);
                    }
                }

                if (Settings.TurnFullScreenOn)
                {
                    this.Window.AddFlags(WindowManagerFlags.Fullscreen);
                    this.Window.AddFlags(WindowManagerFlags.KeepScreenOn);
                }

                if (Settings.TurnSecurityProtocolType3072On)
                {
                    ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                    HttpClient client = new HttpClient(new Xamarin.Android.Net.AndroidClientHandler());
                }

                if (Settings.TurnTrustFailureOn_WebException)
                {
                    //If you are Getting this error >>> System.Net.WebException: Error: TrustFailure /// then Set it to true
                    System.Net.ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
                    System.Security.Cryptography.AesCryptoServiceProvider b = new System.Security.Cryptography.AesCryptoServiceProvider();
                }

                CachedImageRenderer.Init();
                var ignore = new CircleTransformation();

                var assembliesToInclude = new List <Assembly>()
                {
                    typeof(CachedImage).GetTypeInfo().Assembly,
                    typeof(CachedImageRenderer).GetTypeInfo().Assembly
                };
                AndroidClipboardManager = (ClipboardManager)GetSystemService(ClipboardService);

                var container = new SimpleContainer();
                container.Register <IDevice>(t => AndroidDevice.CurrentDevice);
                container.Register <IGeolocator, Geolocator>();
                Resolver.ResetResolver();
                Resolver.SetResolver(container.GetResolver());
                CrossMedia.Current.Initialize();
                ImageCircleRenderer.Init();



                UserDialogs.Init(this);
                global::Xamarin.Forms.Forms.Init(this, bundle);

                AndroidAppLinks.Init(this);

                var data = Intent?.Data?.EncodedAuthority.ToString();

                //Uri data = getIntent().getData();
                //String scheme = data.getScheme(); // "http"
                //String host = data.getHost(); // "twitter.com"
                //List < String > params = data.getPathSegments();
                //String first = params.get(0); // "status"
                //String second = params.get(1); // "1234"



                LoadApplication(new App());
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 59
0
 /// <summary>
 /// Register a interface and implementation in container
 /// </summary>
 /// <typeparam name="T1">Interface</typeparam>
 /// <typeparam name="T2">Implementation</typeparam>
 /// <param name="args">Parameters of contructor</param>
 /// <param name="life">Lifecycle of the instance</param>
 public static void Register <T1, T2>(IoCInfraLifeCycle life = IoCInfraLifeCycle.Singleton, params object[] args)
     where T1 : class
     where T2 : class
 {
     SimpleContainer.Register <T1>(() => (T1)Activator.CreateInstance(typeof(T2), args), ChooseLife(life));
 }
 public CommonControlsServices(SimpleContainer container)
 {
     //           container.PerRequest<JournalViewModel>();
     container.PerRequest <AccountBalancesViewModel>();
 }