本文整理汇总了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>();
}
示例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);
}
}