public static async Task <object> DeserializeFromFileAsync(this IAsyncStreamSerializer serializer, Type type, string path, CancellationToken cancellationToken = default) { using (var stream = File.OpenRead(path)) { return(await serializer.DeserializeFromStreamAsync(type, stream, cancellationToken).ConfigureAwait(false)); } }
public static async Task SerializeToFileAsync(this IAsyncStreamSerializer serializer, string path, object graph, bool overwrite = false, CancellationToken cancellationToken = default) { using (var stream = File.Open(path, overwrite ? FileMode.Create : FileMode.CreateNew)) { await serializer.SerializeToStreamAsync(stream, graph, cancellationToken).ConfigureAwait(false); } }
public AzureBlobStorageCacheClient(string connectionString, IAsyncStreamSerializer serializer, string containerName, string defaultPartitionDirectory, ILogger logger, bool throwOnError) : base(throwOnError, logger) { ArgCheck.NotNullOrEmpty(nameof(connectionString), connectionString); ArgCheck.NotNull(nameof(serializer), serializer); ArgCheck.NotNullOrEmpty(nameof(containerName), containerName); _containerName = containerName; _defaultPartitionDirectory = defaultPartitionDirectory; _serializer = serializer; _storageAccount = CloudStorageAccount.Parse(connectionString); _client = _storageAccount.CreateCloudBlobClient(); _container = _client.GetContainerReference(_containerName); }
public static async Task <T> DeserializeFromFileAsync <T>(this IAsyncStreamSerializer serializer, string path, CancellationToken cancellationToken = default) { return((T)await serializer.DeserializeFromFileAsync(typeof(T), path, cancellationToken).ConfigureAwait(false)); }