/// <summary> /// Updates the specified file. /// </summary> /// <param name="file">The file.</param> /// <param name="stream">The binary stream.</param> /// <param name="cancellationToken">The <see cref="CancellationToken" /> used to propagate notifications that the operation should be canceled.</param> /// <returns></returns> public async Task UpdateAsync(File file, Stream stream, CancellationToken cancellationToken) { // use file guid instead name var queryOptions = new FileQueryOptions() { Type = file.Type }; queryOptions.DocumentIds.Add(file.DocumentId); var filesToRemove = await FileStore.FindAsync(queryOptions, cancellationToken); foreach (var fileToRemove in filesToRemove) { BinaryProvider.Delete(fileToRemove.Reference); } await FileStore.UpdateAsync(file, cancellationToken); var reference = BinaryProvider.InitUpload(file.Id.ToString(CultureInfo.CurrentCulture)); await FileStore.InitAsync(file.Id, BinaryProvider.AssemblyQualifiedName, reference, cancellationToken); await BinaryProvider.FinalizeUploadAsync(reference, stream, cancellationToken); await FileStore.FinalizeAsync(file.Id, cancellationToken); }
private void VisitBinaryProvider(BinaryProvider provider, out CompilableProvider left, out CompilableProvider right) { using (new CorrectorState(this)) left = VisitCompilable(provider.Left); using (new CorrectorState(this)) right = VisitCompilable(provider.Right); }
private static DirectionCollection <int> ComputeBinaryOrder(BinaryProvider provider, DirectionCollection <int> leftOrder, DirectionCollection <int> rightOrder) { if (leftOrder.Count > 0) { return(new DirectionCollection <int>( leftOrder.Concat( rightOrder.Select(p => new KeyValuePair <int, Direction>(p.Key + provider.Left.Header.Length, p.Value))))); } return(new DirectionCollection <int>()); }
/// <summary> /// Adds the specified file. /// </summary> /// <param name="file">The file.</param> /// <param name="stream">The binary stream.</param> /// <param name="cancellationToken">The <see cref="CancellationToken" /> used to propagate notifications that the operation should be canceled.</param> /// <returns></returns> public async Task <long> CreateAsync(File file, Stream stream, CancellationToken cancellationToken) { // use file guid instead name var id = await FileStore.CreateAsync(file, cancellationToken); var reference = BinaryProvider.InitUpload(id.ToString(CultureInfo.CurrentCulture)); await FileStore.InitAsync(id, BinaryProvider.AssemblyQualifiedName, reference, cancellationToken); await BinaryProvider.FinalizeUploadAsync(reference, stream, cancellationToken); await FileStore.FinalizeAsync(id, cancellationToken); return(id); }
internal void MakeResources() { ValidateEntityResourceProviders(); foreach (var provider in EntityResourceProviders.Values) { provider.TypeCache = TypeCache; provider.ResourceCollection = ResourceCollection; provider.ResourceValidator = ResourceValidator; } ValidateAndBuildTypeLists ( out var regularTypes, out var wrapperTypes, out var terminalTypes, out var binaryTypes, out _ ); foreach (var provider in EntityResourceProviders.Values) { var claim = regularTypes.Where(provider.Include).ToList(); regularTypes = regularTypes.Except(claim).ToList(); provider.MakeClaimRegular(claim); } foreach (var provider in EntityResourceProviders.Values) { var claim = wrapperTypes.Where(provider.Include).ToList(); wrapperTypes = wrapperTypes.Except(claim).ToList(); provider.MakeClaimWrapped(claim); } foreach (var provider in EntityResourceProviders.Values) { provider.ReceiveClaimed(ResourceCollection.OfType <IEntityResource>() .Where(r => r.Provider == provider.Id) .ToList()); if (provider is IProceduralEntityResourceProvider) { provider.MakeClaimProcedural(); } } TerminalProvider.RegisterTerminalTypes(terminalTypes); BinaryProvider.RegisterBinaryTypes(binaryTypes); ValidateInnerResources(); }
private Provider VisitSetOperationProvider(BinaryProvider provider) { var leftMapping = mappings[provider]; var rightMapping = mappings[provider]; var oldMappings = ReplaceMappings(provider.Left, leftMapping); var newLeftProvider = VisitCompilable(provider.Left); leftMapping = mappings[provider.Left]; ReplaceMappings(provider.Right, rightMapping); var newRightProvider = VisitCompilable(provider.Right); rightMapping = mappings[provider.Right]; RestoreMappings(oldMappings); var expectedColumns = mappings[provider]; mappings[provider] = Merge(leftMapping, rightMapping); if (newLeftProvider == provider.Left && newRightProvider == provider.Right) { return(provider); } newLeftProvider = BuildSetOperationSource(newLeftProvider, expectedColumns, leftMapping); newRightProvider = BuildSetOperationSource(newRightProvider, expectedColumns, rightMapping); switch (provider.Type) { case ProviderType.Concat: return(new ConcatProvider(newLeftProvider, newRightProvider)); case ProviderType.Intersect: return(new IntersectProvider(newLeftProvider, newRightProvider)); case ProviderType.Except: return(new ExceptProvider(newLeftProvider, newRightProvider)); case ProviderType.Union: return(new UnionProvider(newLeftProvider, newRightProvider)); default: throw new ArgumentOutOfRangeException(); } }
private void SplitMappings(BinaryProvider provider, out List <int> leftMapping, out List <int> rightMapping) { List <int> binaryMapping = mappings[provider]; leftMapping = new List <int>(); rightMapping = new List <int>(); int leftCount = provider.Left.Header.Length; int index = 0; while (index < binaryMapping.Count && binaryMapping[index] < leftCount) { leftMapping.Add(binaryMapping[index]); index++; } for (int i = index; i < binaryMapping.Count; i++) { rightMapping.Add(binaryMapping[i] - leftCount); } }
internal static void MakeResources(IEntityResourceProvider[] externalProviders) { ValidateEntityResourceProviders(externalProviders); ValidateAndBuildTypeLists ( out var regularTypes, out var wrapperTypes, out var terminalTypes, out var binaryTypes, out var eventTypes ); foreach (var provider in EntityResourceProviders.Values) { var claim = regularTypes.Where(provider.Include).ToList(); regularTypes = regularTypes.Except(claim).ToList(); provider.MakeClaimRegular(claim); } foreach (var provider in EntityResourceProviders.Values) { var claim = wrapperTypes.Where(provider.Include).ToList(); wrapperTypes = wrapperTypes.Except(claim).ToList(); provider.MakeClaimWrapped(claim); } foreach (var provider in EntityResourceProviders.Values) { provider.ReceiveClaimed(Resource.ClaimedBy(provider)); if (provider is IProceduralEntityResourceProvider) { provider.MakeClaimProcedural(); } } TerminalProvider.RegisterTerminalTypes(terminalTypes); BinaryProvider.RegisterBinaryTypes(binaryTypes); EventProvider.RegisterEventTypes(eventTypes); ValidateInnerResources(); }
public string GetUrlForUri(string uri) { return(BinaryProvider.GetUrlForUri(uri)); }