示例#1
0
        public async Task <ApplyResourceChange.Types.Response> ApplyResourceChange(ApplyResourceChange.Types.Request request)
        {
            var prior   = DeserializeDynamicValue(request.PriorState);
            var planned = DeserializeDynamicValue(request.PlannedState);

            if (planned == null)
            {
                // Delete
                await _resourceProvider.DeleteAsync(prior);

                return(new ApplyResourceChange.Types.Response());
            }
            else if (prior == null)
            {
                // Create
                var created = await _resourceProvider.CreateAsync(planned);

                var createdSerialized = SerializeDynamicValue(created);
                return(new ApplyResourceChange.Types.Response
                {
                    NewState = createdSerialized,
                });
            }
            else
            {
                // Update
                var updated = await _resourceProvider.UpdateAsync(prior, planned);

                var updatedSerialized = SerializeDynamicValue(updated);
                return(new ApplyResourceChange.Types.Response
                {
                    NewState = updatedSerialized,
                });
            }
        }
示例#2
0
 public async Task DeleteAsync(string resourceKey)
 {
     await provider.DeleteAsync(resourceKey);
 }
示例#3
0
 protected override Task <IResourceInfo> DeleteAsyncInternal(UriString uri, IImmutableSession metadata)
 {
     return(_resourceProvider.DeleteAsync(Combine(uri), metadata));
 }
示例#4
0
 public static async Task <IResourceInfo> DeleteFileAsync(this IResourceProvider resourceProvider, string path, IImmutableSession metadata = default)
 {
     return(await resourceProvider.DeleteAsync(CreateUri(path), metadata.ThisOrEmpty().Set(Use <IResourceNamespace> .Namespace, x => x.Format, MimeType.Text)));
 }