Esempio n. 1
0
 public static async Task <StorageFile> CreateFileAsync(
     string path,
     StorageStrategy location       = StorageStrategy.Local,
     CreationCollisionOption option = CreationCollisionOption.OpenIfExists)
 {
     return(await CreateFileAsync(path, GetFolderFromStrategy(location), option));
 }
Esempio n. 2
0
 private static IFolder GetFolderFromStrategy(StorageStrategy location)
 {
     switch (location)
     {
         case StorageStrategy.Roaming:
             return FileSystem.Current.RoamingStorage;
         default:
             return FileSystem.Current.LocalStorage;
     }
 }
Esempio n. 3
0
 static Either()
 {
     if (Either.IsMutuallyNotConvertable(typeof(T1), typeof(T2)))
     {
         Strategy = StorageStrategy.ReferenceConversion;
     }
     else
     {
         Strategy = StorageStrategy.Box;
     }
 }
Esempio n. 4
0
        private static IFolder GetFolderFromStrategy(StorageStrategy location)
        {
            switch (location)
            {
            case StorageStrategy.Roaming:
                return(FileSystem.Current.RoamingStorage);

            default:
                return(FileSystem.Current.LocalStorage);
            }
        }
Esempio n. 5
0
        public static async Task <bool> DeleteFileAsync(string path, StorageStrategy location = StorageStrategy.Local)
        {
            var file = await GetIfFileExistsAsync(path, GetFolderFromStrategy(location)).ConfigureAwait(false);

            if (file != null)
            {
                await file.DeleteAsync();
            }

            return(!(await FileExistsAsync(path, location).ConfigureAwait(false)));
        }
Esempio n. 6
0
        public Repo CreateRepository(StorageStrategy strategy)
        {
            var factory = factories.FirstOrDefault(f => f.CanHandle(strategy));

            if (factory != null)
            {
                return(factory.GetRepository());
            }
            else
            {
                throw new Exception("Strategy not implemented: " + strategy.ToString());
            }
        }
Esempio n. 7
0
        private int ComputetHashCode()
        {
            var hashCode = 112535552;

            hashCode = hashCode * -1521134295 + PropKind.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <Type> .Default.GetHashCode(Type);

            hashCode = hashCode * -1521134295 + StorageStrategy.GetHashCode();
            hashCode = hashCode * -1521134295 + ComparerIsDefault.GetHashCode();
            hashCode = hashCode * -1521134295 + ComparerIsRefEquality.GetHashCode();
            hashCode = hashCode * -1521134295 + DefaultValFuncIsDefault.GetHashCode();
            return(hashCode);
        }
Esempio n. 8
0
 public static IStorage Create(StorageStrategy storageStrategy)
 {
     IEngine engine = null;
     switch (storageStrategy)
     {
         case StorageStrategy.Speed:
             engine = Engine.Create();
             break;
         case StorageStrategy.SpeedEsent:
             break;
         default:
             break;
     }
     return new Storage(engine, DefaultSerializer.Create());
 }
        public static StorageFolder GetFolderFromStrategy(StorageStrategy location)
        {
            switch (location)
            {
                case StorageStrategy.Roaming:
                    return ApplicationData.Current.RoamingFolder;
                case StorageStrategy.Temporary:
                    return ApplicationData.Current.TemporaryFolder;
                case StorageStrategy.Installation:
                    return Package.Current.InstalledLocation;

                default:
                    return ApplicationData.Current.LocalFolder;
            }
        }
Esempio n. 10
0
        private static StorageFolder GetFolderFromStrategy(StorageStrategy location)
        {
            switch (location)
            {
            case StorageStrategy.Roaming:
                return(ApplicationData.Current.RoamingFolder);

            case StorageStrategy.Temporary:
                return(ApplicationData.Current.TemporaryFolder);

            case StorageStrategy.Installation:
                return(Package.Current.InstalledLocation);

            default:
                return(ApplicationData.Current.LocalFolder);
            }
        }
Esempio n. 11
0
 public static async Task<BinaryWriter> GetWriterForFileAsync(string path,
     StorageStrategy location = StorageStrategy.Local)
 {
     return await GetWriterForFileAsync(path, GetFolderFromStrategy(location)).ConfigureAwait(false);
 }
Esempio n. 12
0
 public static async Task <IFile> GetIfFileExistsAsync(string path,
                                                       StorageStrategy strategy = StorageStrategy.Local)
 {
     return(await GetIfFileExistsAsync(path, GetFolderFromStrategy(strategy)).DontMarshall());
 }
Esempio n. 13
0
 public static async Task<IFile> GetIfFileExistsAsync(string path, StorageStrategy strategy = StorageStrategy.Local)
 {
     return await GetIfFileExistsAsync(path, GetFolderFromStrategy(strategy)).ConfigureAwait(false);
 }
Esempio n. 14
0
 public static async Task <BinaryWriter> GetWriterForFileAsync(string path,
                                                               StorageStrategy location = StorageStrategy.Local)
 {
     return(await GetWriterForFileAsync(path, GetFolderFromStrategy(location)).DontMarshall());
 }
Esempio n. 15
0
 public static async Task <IFolder> EnsureFolderExistsAsync(string path,
                                                            StorageStrategy location = StorageStrategy.Local)
 {
     return(await EnsureFolderExistsAsync(path, GetFolderFromStrategy(location)).DontMarshall());
 }
Esempio n. 16
0
 public static async Task<IFile> CreateFileAsync(string path,
     StorageStrategy location = StorageStrategy.Local,
     CreationCollisionOption option = CreationCollisionOption.OpenIfExists)
 {
     return await CreateFileAsync(path, GetFolderFromStrategy(location), option);
 }
Esempio n. 17
0
 public bool CanHandle(StorageStrategy strategy)
 {
     return(strategy == StorageStrategy.Synchronised);
 }
Esempio n. 18
0
 public bool CanHandle(StorageStrategy strategy)
 {
     return(strategy == StorageStrategy.Local);
 }
Esempio n. 19
0
 public static Task DeleteFolderContentAsync(StorageStrategy location)
 {
     var folder = GetFolderFromStrategy(location);
     return DeleteFolderContentAsync(folder);
 }
Esempio n. 20
0
 public static async Task<IFile> GetIfFileExistsAsync(string path,
     StorageStrategy strategy = StorageStrategy.Local)
 {
     return await GetIfFileExistsAsync(path, GetFolderFromStrategy(strategy)).DontMarshall();
 }
Esempio n. 21
0
 public static async Task<IFolder> EnsureFolderExistsAsync(string path,
     StorageStrategy location = StorageStrategy.Local)
 {
     return await EnsureFolderExistsAsync(path, GetFolderFromStrategy(location)).DontMarshall();
 }
Esempio n. 22
0
 public static async Task<IFile> GetFileAsync(string path,
     StorageStrategy location = StorageStrategy.Local)
 {
     return await CreateFileAsync(path, GetFolderFromStrategy(location));
 }
Esempio n. 23
0
 public static async Task <StorageFolder> EnsureFolderExistsAsync(
     string path,
     StorageStrategy location = StorageStrategy.Local)
 {
     return(await EnsureFolderExistsAsync(path, GetFolderFromStrategy(location)).ConfigureAwait(false));
 }
Esempio n. 24
0
 public bool CanHandle(StorageStrategy strategy)
 {
     return(strategy == StorageStrategy.Online);
 }
Esempio n. 25
0
 public static async Task <BinaryWriter> GetWriterForFileAsync(
     string path,
     StorageStrategy location = StorageStrategy.Local)
 {
     return(await GetWriterForFileAsync(path, GetFolderFromStrategy(location)).ConfigureAwait(false));
 }
Esempio n. 26
0
 public static async Task<bool> FileExistsAsync(string path, StorageStrategy location = StorageStrategy.Local)
 {
     return await FileExistsAsync(path, GetFolderFromStrategy(location)).ConfigureAwait(false);
 }
Esempio n. 27
0
 public static async Task <StorageFile> GetFileAsync(
     string path,
     StorageStrategy location = StorageStrategy.Local)
 {
     return(await CreateFileAsync(path, GetFolderFromStrategy(location)));
 }
Esempio n. 28
0
 public static async Task<BinaryWriter> GetWriterForFileAsync(string path,
     StorageStrategy location = StorageStrategy.Local)
 {
     return await GetWriterForFileAsync(path, GetFolderFromStrategy(location)).DontMarshall();
 }
Esempio n. 29
0
 public static async Task <StorageFile> GetIfFileExistsAsync(
     string path,
     StorageStrategy strategy = StorageStrategy.Local)
 {
     return(await GetIfFileExistsAsync(path, GetFolderFromStrategy(strategy)).ConfigureAwait(false));
 }
Esempio n. 30
0
        public static Task DeleteFolderContentAsync(StorageStrategy location)
        {
            var folder = GetFolderFromStrategy(location);

            return(DeleteFolderContentAsync(folder));
        }