コード例 #1
0
        /// <summary>
        /// Sets the IoC.
        /// </summary>
        private void SetIoc()
        {
            var app = new XFormsAppiOS();

            app.Init(this);

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

            var builder = new ContainerBuilder();

            builder.RegisterType <AccountService>().As <IAccountService>();
            builder.RegisterType <NotifiMngService>().As <INotifiMngService>();
            builder.RegisterType <ImproveService>().As <IImproveService>();
            builder.RegisterType <TourService>().As <ITourService>();
            builder.RegisterType <CaseService>().As <ICaseService>();
            builder.RegisterType <CalendarService>().As <ICalendarService>();
            builder.RegisterType <CommonFun_IOS>().As <ICommonFun>();
            builder.RegisterType <FilePickerImplementation>().As <IFilePicker>();
            builder.RegisterType <ReviewPlansService>().As <IReviewPlansService>();
            builder.RegisterType <RemoteService>().As <IRemoteService>();
            builder.RegisterType <LocalScoreService>().As <ILocalScoreService>();
            builder.RegisterType <ReportService>().As <IReportService>();
            #region sqlite
            builder.RegisterType <SqliteRepository <TaskOfPlanDto> >().As <IRepository <TaskOfPlanDto> >();
            builder.RegisterType <SqliteRepository <Distributor> >().As <IRepository <Distributor> >();
            builder.RegisterType <SqliteRepository <LoaclItemOfTaskDto> >().As <IRepository <LoaclItemOfTaskDto> >();
            builder.RegisterType <SqliteRepository <CheckStandard> >().As <IRepository <CheckStandard> >();
            builder.RegisterType <SqliteRepository <StandardPic> >().As <IRepository <StandardPic> >();
            builder.RegisterType <SqliteRepository <PictureStandard> >().As <IRepository <PictureStandard> >();
            builder.RegisterType <SqliteRepository <Score> >().As <IRepository <Score> >();
            builder.RegisterType <SqliteRepository <TaskOfPlan> >().As <IRepository <TaskOfPlan> >();
            builder.RegisterType <SqliteRepository <CheckResult> >().As <IRepository <CheckResult> >();
            builder.RegisterType <SqliteRepository <Domain.StandardPic> >().As <IRepository <Domain.StandardPic> >();
            builder.RegisterType <SqliteRepository <CustomizedTaskDto> >().As <IRepository <CustomizedTaskDto> >();
            builder.RegisterType <SqliteRepository <PlanDto> >().As <IRepository <PlanDto> >();
            builder.RegisterType <SqliteRepository <CustImproveItemDB> >().As <IRepository <CustImproveItemDB> >();
            builder.RegisterType <SqliteRepository <TaskCard> >().As <IRepository <TaskCard> >();
            builder.RegisterType <SqliteRepository <TaskItem> >().As <IRepository <TaskItem> >();
            builder.RegisterType <SqliteRepository <NameValueObject> >().As <IRepository <NameValueObject> >();
            #endregion
            builder.RegisterInstance(new CommonHelper(new Config.Config()));
            builder.RegisterInstance(new Config.Config());
            builder.RegisterType <SQLite_iOS>().As <ISQLite>();
            builder.Register(ctx =>
            {
                return(new AccountInfo());
            });
            //builder.Register<IDevice>(t => AppleDevice.CurrentDevice);

            var container         = builder.Build();
            var resolverContainer = new AutofacContainer(container);

            Resolver.SetResolver(resolverContainer.GetResolver());
        }
コード例 #2
0
        private void SetIoc()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <AccountService>().As <IAccountService>();
            builder.RegisterType <NotifiMngService>().As <INotifiMngService>();
            builder.RegisterType <ImproveService>().As <IImproveService>();
            builder.RegisterType <TourService>().As <ITourService>();
            builder.RegisterType <CaseService>().As <ICaseService>();
            builder.RegisterType <ReviewPlansService>().As <IReviewPlansService>();
            builder.RegisterType <CalendarService>().As <ICalendarService>();
            builder.RegisterType <RemoteService>().As <IRemoteService>();
            builder.RegisterType <LocalScoreService>().As <ILocalScoreService>();
            builder.RegisterType <ReportService>().As <IReportService>();
            #region sqlite
            builder.RegisterType <SqliteRepository <TaskOfPlanDto> >().As <IRepository <TaskOfPlanDto> >();
            builder.RegisterType <SqliteRepository <Distributor> >().As <IRepository <Distributor> >();
            builder.RegisterType <SqliteRepository <LoaclItemOfTaskDto> >().As <IRepository <LoaclItemOfTaskDto> >();
            builder.RegisterType <SqliteRepository <CheckStandard> >().As <IRepository <CheckStandard> >();
            builder.RegisterType <SqliteRepository <StandardPic> >().As <IRepository <StandardPic> >();
            builder.RegisterType <SqliteRepository <PictureStandard> >().As <IRepository <PictureStandard> >();
            builder.RegisterType <SqliteRepository <Score> >().As <IRepository <Score> >();
            builder.RegisterType <SqliteRepository <TaskOfPlan> >().As <IRepository <TaskOfPlan> >();
            builder.RegisterType <SqliteRepository <CheckResult> >().As <IRepository <CheckResult> >();
            builder.RegisterType <SqliteRepository <Domain.StandardPic> >().As <IRepository <Domain.StandardPic> >();
            builder.RegisterType <SqliteRepository <CustomizedTaskDto> >().As <IRepository <CustomizedTaskDto> >();
            builder.RegisterType <SqliteRepository <PlanDto> >().As <IRepository <PlanDto> >();
            builder.RegisterType <SqliteRepository <CustImproveItemDB> >().As <IRepository <CustImproveItemDB> >();
            builder.RegisterType <SqliteRepository <TaskCard> >().As <IRepository <TaskCard> >();
            builder.RegisterType <SqliteRepository <TaskItem> >().As <IRepository <TaskItem> >();
            builder.RegisterType <SqliteRepository <NameValueObject> >().As <IRepository <NameValueObject> >();

            #endregion
            builder.RegisterType <CommonFun_Droid>().As <ICommonFun>();
            builder.RegisterType <FilePickerImplementation>().As <IFilePicker>();
            builder.RegisterInstance(new CommonHelper(new Config.Config()));
            builder.RegisterInstance(new Config.Config());
            builder.RegisterType <SQLite_Android>().As <ISQLite>();
            builder.Register(ctx =>
            {
                return(new AccountInfo());
            });

            var container         = builder.Build();
            var resolverContainer = new AutofacContainer(container);
            Resolver.SetResolver(resolverContainer.GetResolver());
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: koland/bshkara
        private static void RegisterServices()
        {
            var builder   = new ContainerBuilder();
            var container = new AutofacContainer(builder.Build());

            //Allow native to register
            OnContainerSet?.Invoke(container);

            //register PCL Services
            container.Register <IWebService, WebService>();
            container.Register <IDependencyContainer>(container);

            //Set global resolver
            if (!Resolver.IsSet)
            {
                Resolver.SetResolver(container.GetResolver());
            }
        }
コード例 #4
0
        /// <summary>
        /// Sets Inversion of Control.
        /// </summary>
        private void SetIoC()
        {
            var nativeApplication = new XFormsApp <Application>();

            nativeApplication.Init(this);

            var containerBuilder = new ContainerBuilder();

            containerBuilder.Register(c => WindowsPhoneDevice.CurrentDevice).As <IDevice>();
            containerBuilder.Register(c => nativeApplication).As <IXFormsApp>();
            Core.App.RegisterCoreComponents(containerBuilder);

            var autofacContainer = new AutofacContainer(containerBuilder.Build());

            autofacContainer.Register <IDependencyContainer>(autofacContainer);

            Resolver.SetResolver(autofacContainer.GetResolver());
        }
コード例 #5
0
ファイル: App.xaml.cs プロジェクト: emiliobs/awesomekit
        private void InitializeResolver()
        {
            var builder = new ContainerBuilder();

            var autofacContainer = builder.AutoRegisterMvvmComponents(typeof(App).GetTypeInfo().Assembly)
                                   .Finish();

            // That container will use XLabs for resolver
            var container = new AutofacContainer(autofacContainer);

            //Here we can register PCL services
            container.Register <IDependencyContainer>(container);

            // And now, we will set resolver
            if (!Resolver.IsSet)
            {
                Resolver.SetResolver(container.GetResolver());
            }
        }
コード例 #6
0
        //private void SetMvvMIoc() {
        //	var resolverContainer = new SimpleContainer();
        //	resolverContainer.RegisterSingleton<IUserDialogs>(() => UserDialogs.Instance);
        //}

        private void SetIoc(App instance)
        {
            try
            {
                var builder = new ContainerBuilder();
                builder.RegisterType <AccountService>().As <IAccountService>();
                //builder.RegisterType<CommonFun_Droid>().As<ICommonFun>();
                builder.RegisterInstance(new Config.Config());
                builder.Register(ctx =>
                {
                    return(new AccountInfo());
                });

                var container         = builder.Build();
                var resolverContainer = new AutofacContainer(container);
                Resolver.SetResolver(resolverContainer.GetResolver());
            }
            catch (Exception)
            {
            }
        }
コード例 #7
0
        /// <summary>
        ///   Sets the IoC.
        /// </summary>
        private void SetIoc()
        {
            var nativeApplication = new XFormsApp <XFormsApplicationDroid>();

            nativeApplication.Init(this);

            var containerBuilder = new ContainerBuilder();

            containerBuilder.Register(c => AndroidDevice.CurrentDevice).As <IDevice>();
            containerBuilder.Register(c => nativeApplication).As <IXFormsApp>();
            containerBuilder.Register(c => new FileService()).As <IFileService>();
            containerBuilder.Register(c => new Id3TagService()).As <IId3TagService>();
            containerBuilder.Register(c => new MediaPlayerService()).As <IMediaPlayerService>();

            App.RegisterCoreComponents(containerBuilder);

            var autofacContainer = new AutofacContainer(containerBuilder.Build());

            autofacContainer.Register <IDependencyContainer>(autofacContainer);

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