예제 #1
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public async Task <DriveFile> UploadFileAsync(string pathName, DriveFile destFolder, string storageFileId, CancellationToken token)
 {
     using (var stream = File.OpenRead(pathName))
     {
         return(await UploadFileAsync(stream, Path.GetFileName(pathName), destFolder, storageFileId, token));
     }
 }
예제 #2
0
파일: MockDrive.cs 프로젝트: fiftin/oblqo
 public override async Task<DriveFile> UploadFileAsync(Stream fileStream, string fileName, DriveFile destFolder, string storageFileId, CancellationToken token)
 {
     var file = new MockDriveFile(this, fileName, false);
     file.content = new byte[fileStream.Length];
     fileStream.Read(file.content, 0, (int)fileStream.Length);
     MockDriveFile folder = (MockDriveFile)destFolder;
     folder.Add(file);
     return file;
 }
예제 #3
0
 private static string GetFileName(DriveFile file, bool isLantinOnlySupport)
 {
     if (file == null)
     {
         return(null);
     }
     if (isLantinOnlySupport)
     {
         return(file.Name.Unidecode());
     }
     return(file.Name);
 }
예제 #4
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public virtual async Task <Image> GetImageAsync(DriveFile file, CancellationToken token)
 {
     using (var stream = await ReadFileAsync(file, token))
     {
         try
         {
             return(await Task.Run(() => Image.FromStream(stream)));
         }
         catch (Exception)
         {
             throw new BadImageFormatException();
         }
     }
 }
예제 #5
0
        private void PutFileTo(DriveFile file, IDictionary <string, DriveFileCollection> fileCollections)
        {
            DriveFileCollection collection;

            if (file.StorageFileId == null)
            {
                if (!TryFindFileByName(file.Name, file.Drive.IsLantinOnlySupport, fileCollections.Values, out collection))
                {
                    collection = new DriveFileCollection();
                    fileCollections.Add(file.StorageFileId ?? Guid.NewGuid().ToString(), collection);
                }
            }
            else if (!fileCollections.TryGetValue(file.StorageFileId, out collection))
            {
                collection = new DriveFileCollection();
                fileCollections.Add(file.StorageFileId ?? Guid.NewGuid().ToString(), collection);
            }
            collection.Add(file);
        }
예제 #6
0
 internal bool DeleteFileRecursive(DriveFile driveFile)
 {
     var y = files.FirstOrDefault(x => x.Name == driveFile.Name);
     if (y != null)
     {
         return files.Remove(y);
     }
     else
     {
         foreach (var x in files.Where(x=>x.IsFolder && x.files.Count > 0))
         {
             if (x.DeleteFileRecursive(driveFile))
             {
                 return true;
             }
         }
         return false;
     }
 }
예제 #7
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task DeleteFolderAsync(DriveFile driveFolder, CancellationToken token);
예제 #8
0
파일: MockDrive.cs 프로젝트: fiftin/oblqo
 public override async Task DeleteFolderAsync(DriveFile driveFolder, CancellationToken token)
 {
     rootFolder.DeleteFileRecursive(driveFolder);
 }
예제 #9
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task<ICollection<DriveFile>> GetSubfoldersAsync(DriveFile folder, CancellationToken token);
예제 #10
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task<Image> GetThumbnailAsync(DriveFile file, CancellationToken token);
예제 #11
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task<DriveFile> UploadFileAsync(Stream fileStream, string fileName, DriveFile destFolder, string storageFileId, CancellationToken token);
예제 #12
0
파일: MockDrive.cs 프로젝트: fiftin/oblqo
 public override Task<System.Drawing.Image> GetThumbnailAsync(DriveFile file, CancellationToken token)
 {
     throw new NotImplementedException();
 }
예제 #13
0
파일: Account.cs 프로젝트: fiftin/oblqo
 private static string GetFileName(DriveFile file, bool isLantinOnlySupport)
 {
     if (file == null)
     {
         return null;
     }
     if (isLantinOnlySupport)
     {
         return file.Name.Unidecode();
     }
     return file.Name;
 }
예제 #14
0
파일: MockDrive.cs 프로젝트: fiftin/oblqo
 public override async Task DownloadFileAsync(DriveFile driveFile, Stream output, CancellationToken token)
 {
     await output.WriteAsync(((MockDriveFile)driveFile).content, 0, ((MockDriveFile)driveFile).content.Length);
 }
예제 #15
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task DownloadFileAsync(DriveFile driveFile, string destFolder, ActionIfFileExists actionIfFileExists, CancellationToken token);
예제 #16
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task EnumerateFilesRecursive(DriveFile driveFolder, Action <DriveFile> action, CancellationToken token);
예제 #17
0
파일: MockDrive.cs 프로젝트: fiftin/oblqo
 public override async Task DownloadFileAsync(DriveFile driveFile, string destFolder, ActionIfFileExists actionIfFileExists, CancellationToken token)
 {
     throw new NotImplementedException();
 }
예제 #18
0
파일: MockDrive.cs 프로젝트: fiftin/oblqo
 public override async Task EnumerateFilesRecursive(DriveFile driveFolder, Action<DriveFile> action, CancellationToken token)
 {
     throw new NotImplementedException();
 }
예제 #19
0
파일: MockDrive.cs 프로젝트: fiftin/oblqo
 public override async Task<Stream> ReadFileAsync(DriveFile file, CancellationToken token)
 {
     return new MemoryStream(((MockDriveFile)file).content);
 }
예제 #20
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task EnumerateFilesRecursive(DriveFile driveFolder, Action<DriveFile> action, CancellationToken token);
예제 #21
0
파일: Account.cs 프로젝트: fiftin/oblqo
 private void PutFileTo(DriveFile file, IDictionary<string, DriveFileCollection> fileCollections)
 {
     DriveFileCollection collection;
     if (file.StorageFileId == null)
     {
         if (!TryFindFileByName(file.Name, file.Drive.IsLantinOnlySupport, fileCollections.Values, out collection))
         {
             collection = new DriveFileCollection();
             fileCollections.Add(file.StorageFileId ?? Guid.NewGuid().ToString(), collection);
         }
     }
     else if (!fileCollections.TryGetValue(file.StorageFileId, out collection))
     {
         collection = new DriveFileCollection();
         fileCollections.Add(file.StorageFileId ?? Guid.NewGuid().ToString(), collection);
     }
     collection.Add(file);
 }
예제 #22
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task DownloadFileAsync(DriveFile driveFile, Stream output, CancellationToken token);
예제 #23
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task DownloadFileAsync(DriveFile driveFile, Stream output, CancellationToken token);
예제 #24
0
파일: MockDrive.cs 프로젝트: fiftin/oblqo
 public override async Task<ICollection<DriveFile>> GetSubfoldersAsync(DriveFile folder, CancellationToken token)
 {
     return ((MockDriveFile)folder).files.Where(x => x.IsFolder).Cast<DriveFile>().ToList();
 }
예제 #25
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public virtual async Task<Image> GetImageAsync(DriveFile file, CancellationToken token)
 {
     using (var stream = await ReadFileAsync(file, token))
     {
         try
         {
             return await Task.Run(() => Image.FromStream(stream));
         }
         catch(Exception)
         {
             throw new BadImageFormatException();
         }
     }
 }
예제 #26
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task <DriveFile> UploadFileAsync(Stream fileStream, string fileName, DriveFile destFolder, string storageFileId, CancellationToken token);
예제 #27
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task DownloadFileAsync(DriveFile driveFile, string destFolder, ActionIfFileExists actionIfFileExists, CancellationToken token);
예제 #28
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task <Stream> ReadFileAsync(DriveFile file, CancellationToken token);
예제 #29
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public async Task<DriveFile> UploadFileAsync(string pathName, DriveFile destFolder, string storageFileId, CancellationToken token)
 {
     using (var stream = File.OpenRead(pathName))
     {
         return await UploadFileAsync(stream, Path.GetFileName(pathName), destFolder, storageFileId, token);
     }
 }
예제 #30
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task <Image> GetThumbnailAsync(DriveFile file, CancellationToken token);
예제 #31
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task<Stream> ReadFileAsync(DriveFile file, CancellationToken token);
예제 #32
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task <DriveFile> CreateFolderAsync(string folderName, DriveFile destFolder, CancellationToken token);
예제 #33
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task<DriveFile> CreateFolderAsync(string folderName, DriveFile destFolder, CancellationToken token);
예제 #34
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task <ICollection <DriveFile> > GetSubfoldersAsync(DriveFile folder, CancellationToken token);
예제 #35
0
파일: Drive.cs 프로젝트: fiftin/oblqo
 public abstract Task DeleteFolderAsync(DriveFile driveFolder, CancellationToken token);
예제 #36
0
파일: MockDrive.cs 프로젝트: fiftin/oblqo
 public override async Task<DriveFile> CreateFolderAsync(string folderName, DriveFile destFolder, 
     CancellationToken token)
 {
     return ((MockDriveFile)destFolder).CreateFolder(folderName);
 }