Exemple #1
0
        /// <summary>
        /// Sets the IoC.
        /// </summary>
        private void SetIoc()
        {
            var resolverContainer = new global::XLabs.Ioc.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 <XLabs.Serialization.IJsonSerializer, XLabs.Serialization.JsonNET.JsonSerializer>()
            //.Register<IJsonSerializer, Services.Serialization.SystemJsonSerializer>()
            .Register <ITextToSpeechService, TextToSpeechService>()
            .Register <IEmailService, EmailService>()
            .Register <IMediaPicker, MediaPicker>()
            .Register <IXFormsApp>(app)
            .Register <ISecureStorage, SecureStorage>()
            .Register <global::XLabs.Ioc.IDependencyContainer>(t => resolverContainer);
            //.Register<global::XLabs.Caching.ICacheProvider>(
            //    t => new SQLiteSimpleCache(new SQLitePlatformIOS(),
            //        new SQLiteConnectionString(pathToDatabase, true), t.Resolve<global::XLabs.Serialization.IJsonSerializer>()));

            XLabs.Ioc.Resolver.SetResolver(resolverContainer.GetResolver());
        }
Exemple #2
0
        private void SetIoC()
        {
            var resolverContainer = new global::XLabs.Ioc.SimpleContainer();

            resolverContainer.Register <IEventAggregator>(t => new EventAggregator());

            XLabs.Ioc.Resolver.SetResolver(resolverContainer.GetResolver());
        }
Exemple #3
0
        private void SetIoc()
        {
            var resolverContainer = new global::XLabs.Ioc.SimpleContainer();

            resolverContainer
            .Register <IMediaPicker, MediaPicker>();

            XLabs.Ioc.Resolver.SetResolver(resolverContainer.GetResolver());
        }
Exemple #4
0
        private void SetIoc()
        {
            var resolverContainer = new global::XLabs.Ioc.SimpleContainer();

            var app = new XFormsAppiOS();

            app.Init(this);

            resolverContainer.Register <IDevice>(t => AppleDevice.CurrentDevice)
            .Register <IDisplay>(t => t.Resolve <IDevice>().Display);
            XLabs.Ioc.Resolver.SetResolver(resolverContainer.GetResolver());
        }
        /// <summary>
        /// Sets the IoC.
        /// </summary>
        private void SetIoc()
        {
            var resolverContainer = new global::XLabs.Ioc.SimpleContainer();

            var app = new XFormsAppiOS();

            app.Init(this);

            var documents = app.AppDataDirectory;

            resolverContainer.Register <IDevice>(t => AppleDevice.CurrentDevice)
            .Register <IJsonSerializer, XLabs.Serialization.JsonNET.JsonSerializer>();

            Resolver.SetResolver(resolverContainer.GetResolver());
        }
Exemple #6
0
        private void init()
        {
            #region 初始化 Common.StaticInfo

            var staticInfoInitArgs = new Common.StaticInfoInitArgs();

            staticInfoInitArgs.AppName = "XamarinTest";

            #region iOS项目路径赋值

            staticInfoInitArgs.AppFilesPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

            staticInfoInitArgs.AppCachePath = System.IO.Path.Combine(staticInfoInitArgs.AppFilesPath, "..", "Library", "Cache");

            #endregion

            #region  务器配置

            string pathServiceSettings = Common.ServiceSettingsUtils.GetConfigFilePath(argsDirPath: staticInfoInitArgs.AppFilesPath);

            if (System.IO.File.Exists(pathServiceSettings) == false)
            {
                Common.ServiceSettingsUtils.InitConfig(pathServiceSettings);
            }

            Common.ServiceSettingsUtils.ReadConfig(pathServiceSettings, staticInfoInitArgs);

            #endregion

            #region 本机配置

            string pathNativeSettings = Common.NativeSettingsUtils.GetConfigFilePath(argsDirPath: staticInfoInitArgs.AppFilesPath);

            if (System.IO.File.Exists(pathNativeSettings) == false)
            {
                Common.NativeSettingsUtils.InitConfig(pathNativeSettings);
            }

            Common.NativeSettingsUtils.ReadConfig(pathNativeSettings, staticInfoInitArgs);

            #endregion

            #region SQLite

            staticInfoInitArgs.InnerSQLiteConnStr = System.IO.Path.Combine
                                                    (
                System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),
                Util.Principle.DatabaseName_SQLite
                                                    );

            //staticInfoInitArgs.ExternalSQLiteConnStr = System.IO.Path.Combine
            //(
            //    staticInfoInitArgs.AndroidExternalFilesPath,
            //    Util.Principle.DatabaseName_SQLite
            //);

            #endregion

            Common.StaticInfo.Init(staticInfoInitArgs);

            #endregion

            //// iOS 数据库存储位置 (拷贝自 TODO 项目), 值得参考
            //string docFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            //string libFolder = System.IO.Path.Combine(docFolder, "..", "Library", "Databases");
            //if (!Directory.Exists(libFolder))
            //{
            //    Directory.CreateDirectory(libFolder);
            //}

            // 实现IOutput接口 - 用 Logcat 来实现
            App.Output = new MyOutput(); // TODO 未知道 iOS 是否有类似安卓的 LogUtil

            // 屏幕方向
            App.Screen = new MyScreen();

            // 初始化条码扫描器
            ZXing.Net.Mobile.Forms.iOS.Platform.Init();

            // 初始化定位
            App.LBS = MyLocation.GetInstance();

            // 初始化Audio
            App.AudioPlayer = MyAudioPlayer.GetInstance();

            // 初始化TTS
            App.TTS = MyTTS.GetInstance();

            //// 初始化IR ( iOS设备暂时未发现有红外装置 )
            //App.IR = MyIR.GetInstance(ApplicationContext);

            //// 初始化动态权限 ( iOS还没有需要 )

            //// 初始化Bluetooth ( iOS未能使用Xamarin.iOS的代码监测到蓝牙设备 )



            #region 初始化第三方 DLL 库

            // 初始化 Acr.UserDialogs
            // Nothing is necessary any longer as of v4.x.  There is an Init function for iOS but it is OPTIONAL and only required if you want/need to control
            // the top level viewcontroller for things like iOS extensions.Progress prompts will not use this factory function though!


            //// [弃用] 初始化 DevExpress.Mobile.Forms
            //DevExpress.Mobile.Forms.Init();
            //// 由于DevExpress.Mobile.DataGrid.Theme.ThemeManager.ThemeName 默认主题为 Themes.Dark,
            //// 这里初始化主题颜色为 Theme.Light
            //DevExpress.Mobile.DataGrid.Theme.ThemeManager.ThemeName = DevExpress.Mobile.DataGrid.Theme.Themes.Light;
            //DevExpress.Mobile.DataGrid.Theme.ThemeManager.RefreshTheme();


            // FFImageLoading ( Gif 动图 ) ( SVG 矢量图显示 )
            var svgAssembly = typeof(FFImageLoading.Svg.Forms.SvgCachedImage).GetTypeInfo().Assembly;
            FFImageLoading.Forms.Platform.CachedImageRenderer.Init();


            // Plugin.MediaManager.Forms ( 视频播放 )
            // MediaManager.Forms.Platforms.iOS.VideoViewRenderer.Init();
            // Plugin.MediaManager.Forms.iOS.VideoViewRenderer.Init();


            // 初始化 XLab
            var resolverContainer = new global::XLabs.Ioc.SimpleContainer();
            resolverContainer.Register <XLabs.Platform.Services.Media.IMediaPicker, XLabs.Platform.Services.Media.MediaPicker>();
            XLabs.Ioc.Resolver.SetResolver(resolverContainer.GetResolver());


            // TODO Aspose.Cells
            #endregion
        }
Exemple #7
0
        private void init()
        {
            #region 初始化 Common.StaticInfo

            var staticInfoInitArgs = new Common.StaticInfoInitArgs();

            staticInfoInitArgs.AppName = "XamarinTest";

            #region 安卓项目路径赋值

            // 安卓系统外部存储绝对路径
            staticInfoInitArgs.AndroidExternalPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;

            // App外部缓存绝对路径 -- /{安卓系统外部存储路径}/Android/data/{appPackageName}/cache
            foreach (var item in this.GetExternalCacheDirs())
            {
                staticInfoInitArgs.AndroidExternalCachePath = item.AbsolutePath;
                break;
            }

            // App外部文件绝对路径 -- /{安卓系统外部存储路径}/Android/data/{appPackageName}/files
            foreach (var item in this.GetExternalFilesDirs(string.Empty))
            {
                staticInfoInitArgs.AndroidExternalFilesPath = item.AbsolutePath;
                break;
            }

            #endregion

            #region  务器配置

            string pathServiceSettings = Common.ServiceSettingsUtils.GetConfigFilePath(argsDirPath: staticInfoInitArgs.AndroidExternalFilesPath);

            if (System.IO.File.Exists(pathServiceSettings) == false)
            {
                Common.ServiceSettingsUtils.InitConfig(pathServiceSettings);
            }

            Common.ServiceSettingsUtils.ReadConfig(pathServiceSettings, staticInfoInitArgs);

            #endregion

            #region 本机配置

            string pathNativeSettings = Common.NativeSettingsUtils.GetConfigFilePath(argsDirPath: staticInfoInitArgs.AndroidExternalFilesPath);

            if (System.IO.File.Exists(pathNativeSettings) == false)
            {
                Common.NativeSettingsUtils.InitConfig(pathNativeSettings);
            }

            Common.NativeSettingsUtils.ReadConfig(pathNativeSettings, staticInfoInitArgs);

            #endregion

            #region SQLite

            staticInfoInitArgs.InnerSQLiteConnStr = System.IO.Path.Combine
                                                    (
                System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),
                Util.Principle.DatabaseName_SQLite
                                                    );

            staticInfoInitArgs.ExternalSQLiteConnStr = System.IO.Path.Combine
                                                       (
                staticInfoInitArgs.AndroidExternalFilesPath,
                Util.Principle.DatabaseName_SQLite
                                                       );

            #endregion

            Common.StaticInfo.Init(staticInfoInitArgs);

            #endregion

            // 实现IOutput接口 - 用 Logcat 来实现
            App.Output = new MyOutput();

            // 屏幕方向
            App.Screen = Util.XamariN.AndroiD.MyScreen.GetInstance(this);

            // 初始化条码扫描器
            ZXing.Net.Mobile.Forms.Android.Platform.Init();

            // 初始化百度定位
            App.LBS = new BaiduLBS(ApplicationContext);

            // 初始化Audio
            App.AudioPlayer = Util.XamariN.AndroiD.MyAudioPlayer.GetInstance();

            // 初始化TTS
            App.TTS = Util.XamariN.AndroiD.MyTTS.GetInstance();

            // 初始化IR
            App.IR = MyIR.GetInstance(ApplicationContext);

            // 弃用
            // 初始化动态权限
            // 1)实现封装好的接口
            // App.AndroidPermissionUtils = Util.XamariN.AndroiD.MyAndroidPermission.GetInstance(this);
            // 2)下面这个实现用于本项目快速测试, 不需要更新 Util.XamariN.AndroiD 的 DLL 到 nuget
            // MyAndroidPermission_InTestSolution myPermission = MyAndroidPermission_InTestSolution.GetInstance(this);
            // App.AndroidPermissionUtils_InTestSolution = myPermission;

            // 初始化Bluetooth
            App.Bluetooth = Util.XamariN.AndroiD.MyBluetooth.GetInstance(this);

            App.MyShareUtils = new Util.XamariN.AndroiD.MyShareUtils();
            // 文件管理器 ShareUtils 赋值具体
            Util.XamariN.FileExplorer.MyFileExplorer.ShareUtils = new Util.XamariN.AndroiD.MyShareUtils();

            App.MyWechatOpenSDK = new MyWeChatOpenSDK(app_id: "wxd66c092941a6aabf");

            #region 安卓特有

            // 访问 Assets 资源
            App.AndroidAssetsUtils = Util.XamariN.AndroiD.MyAndroidAssetsUtils.GetInstance(this);

            // 初始化 Intent 工具类
            App.AndroidIntentUtils = Util.XamariN.AndroiD.MyAndroidIntentUtils.GetInstance(this);
            string auth = $"{this.Application.PackageName}.fileprovider";
            App.AndroidIntentUtils.SetFileProvider_Authority(auth);

            // 初始化 Android 权限工具类
            App.AndroidPermissionUtils = Util.XamariN.AndroiD.MyAndroidPermission.GetInstance(this);

            // 初始化截屏
            App.AndroidScreenshot = Util.XamariN.AndroiD.MyAndroidScreenshot.GetInstance(this);

            // 初始化录屏
            App.AndroidScreenRecord = Util.XamariN.AndroiD.MyAndroidScreenRecord.GetInstance(this);

            #endregion



            #region 初始化第三方 DLL 库

            // 初始化 Acr.UserDialogs
            Acr.UserDialogs.UserDialogs.Init(this);

            //// [弃用] DevExpress.Mobile.Forms
            //// 初始化 DevExpress.Mobile.Forms
            //DevExpress.Mobile.Forms.Init();
            //// 由于DevExpress.Mobile.DataGrid.Theme.ThemeManager.ThemeName 默认主题为 Themes.Dark,
            //// 这里初始化主题颜色为 Theme.Light
            //DevExpress.Mobile.DataGrid.Theme.ThemeManager.ThemeName = DevExpress.Mobile.DataGrid.Theme.Themes.Light;
            //DevExpress.Mobile.DataGrid.Theme.ThemeManager.RefreshTheme();


            // 初始化 FFImageLoading
            // 2.4.4.589(稳定版)执行 init 方式会报错
            // System.TypeLoadException: Could not load list of method overrides due to Method not found: void
            // Nuget 引用 2.4.5.880-pre
            // 1) Xamarin.FFImageLoading
            // 2) Xamarin.FFImageLoading.Forms
            // 然后以下的执行初始化语句
            var svgAssembly = typeof(FFImageLoading.Svg.Forms.SvgCachedImage).GetTypeInfo().Assembly;                                  // <-- 追加
            FFImageLoading.Forms.Platform.CachedImageRenderer.Init(enableFastRenderer: true);


            // Plugin.MediaManager.Forms ( 视频播放类库 )
            //MediaManager.CrossMediaManager.Current.Init();


            // 初始化 XLab
            var resolverContainer = new global::XLabs.Ioc.SimpleContainer();
            resolverContainer.Register <XLabs.Platform.Services.Media.IMediaPicker, XLabs.Platform.Services.Media.MediaPicker>();
            XLabs.Ioc.Resolver.SetResolver(resolverContainer.GetResolver());

            // Aspose.Cells
            App.ExcelUtils_Aspose = new Util.Excel.ExcelUtils_Aspose_XamarinAndroid();

            #endregion
        }