当前位置: 首页>>代码示例>>C#>>正文


C# IStorage.GetType方法代码示例

本文整理汇总了C#中IStorage.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IStorage.GetType方法的具体用法?C# IStorage.GetType怎么用?C# IStorage.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IStorage的用法示例。


在下文中一共展示了IStorage.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RequestHistoryResource

        public RequestHistoryResource(IStorage storage)
        {
            if (!storage.Supports<IQueryRequests>())
                throw new ArgumentException($"IStorage implementation of type '{storage.GetType().FullName}' does not support IQueryRequests.", nameof(storage));

            _requests = storage.As<IQueryRequests>();
        }
开发者ID:mike-kaufman,项目名称:Glimpse.Prototype,代码行数:7,代码来源:RequestHistoryResource.cs

示例2: Initialize

        /// <summary>
        /// Initializes the controller:  Loads settings, starts web server, sets up the camera and storage providers,
        /// tries to log into OneDrive (if OneDrive is selected), and starts the file upload and deletion timers
        /// </summary>
        /// <returns></returns>
        public async Task Initialize()
        {
            try
            {
                // Load settings from file
                XmlSettings = await AppSettings.RestoreAsync("Settings.xml");

                // Start web server on port 8000
                if (!Server.IsRunning)
                    Server.Start(8000);

                // Create local storage folder if it doesn't exist
                StorageFolder folder = KnownFolders.PicturesLibrary;
                try
                {
                    await folder.GetFolderAsync(AppSettings.FolderName);
                }catch(System.IO.FileNotFoundException)
                {
                    await folder.CreateFolderAsync(AppSettings.FolderName);
                }

                Camera = CameraFactory.Get(XmlSettings.CameraType);
                Storage = StorageFactory.Get(XmlSettings.StorageProvider);

                await Camera.Initialize();

                // Try to log into OneDrive using existing Access Token in settings file
                if (Storage.GetType() == typeof(OneDrive))
                {
                    var oneDrive = App.Controller.Storage as OneDrive;

                    if (oneDrive != null)
                    {
                        if (!oneDrive.IsLoggedIn())
                        {
                            try
                            {
                                await oneDrive.AuthorizeWithRefreshToken(XmlSettings.OneDriveRefreshToken);
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine(ex.Message);

                                // Log telemetry event about this exception
                                var events = new Dictionary<string, string> { { "Controller", ex.Message } };
                                App.Controller.TelemetryClient.TrackEvent("FailedToLoginOneDrive", events);
                            }
                        }
                    }
                }

                this.alljoynManager = new AllJoynManager();
                await this.alljoynManager.Initialize(this.Camera, this.Storage);

                //Timer controlling camera pictures with motion
                uploadPicturesTimer = new DispatcherTimer();
                uploadPicturesTimer.Interval = TimeSpan.FromSeconds(uploadInterval);
                uploadPicturesTimer.Tick += uploadPicturesTimer_Tick;
                uploadPicturesTimer.Start();

                //Timer controlling deletion of old pictures
                deletePicturesTimer = new DispatcherTimer();
                deletePicturesTimer.Interval = TimeSpan.FromHours(deleteInterval);
                deletePicturesTimer.Tick += deletePicturesTimer_Tick;
                deletePicturesTimer.Start();

                IsInitialized = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Controller.Initialize() Error: " + ex.Message);

                // Log telemetry event about this exception
                var events = new Dictionary<string, string> { { "Controller", ex.Message } };
                App.Controller.TelemetryClient.TrackEvent("FailedToInitialize", events);
            }
        }
开发者ID:bethoma,项目名称:securitysystem,代码行数:82,代码来源:Controller.cs


注:本文中的IStorage.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。