public async Task <IValueProvider> BindAsync(TableEntityContext value, ValueBindingContext context) { var table = value.Table; TableEntity entity; try { var result = await table.GetEntityAsync <TableEntity>( value.PartitionKey, value.RowKey).ConfigureAwait(false); entity = result.Value; } catch (RequestFailedException e) when (e.Status == 404 && (e.ErrorCode == TableErrorCode.TableNotFound || e.ErrorCode == TableErrorCode.ResourceNotFound)) { return(new NullEntityValueProvider <TElement>(value)); } TElement userEntity; if (typeof(TElement) == typeof(TableEntity)) { userEntity = (TElement)(object)entity; } else { userEntity = PocoTypeBinder.Shared.Deserialize <TElement>(entity); } return(new PocoEntityValueBinder <TElement>(value, entity.ETag.ToString(), userEntity)); }
// TODO: Change detection //private readonly IDictionary<string, EntityProperty> _originalProperties; public TableEntityValueBinder(TableEntityContext entityContext, ITableEntity entity, Type valueType) { _entityContext = entityContext; _value = entity; _valueType = valueType; // TODO: Change detection //_originalProperties = DeepClone(entity.WriteEntity(null)); }
public PocoEntityValueBinder( TableEntityContext entityContext, ValueBindingContext context, TableEntity originalEntity, FuncAsyncConverter entityToPocoConverter, FuncAsyncConverter pocoToEntityConverter) { _entityContext = entityContext; _valueBindingContext = context; _originalEntity = originalEntity; _entityToPocoConverter = entityToPocoConverter; _pocoToEntityConverter = pocoToEntityConverter; }
public Task <IValueProvider> BindAsync(object value, ValueBindingContext context) { TableEntityContext entityContext = null; if (!_converter.TryConvert(value, out entityContext)) { throw new InvalidOperationException("Unable to convert value to TableEntityContext."); } TableClientHelpers.ValidateAzureTableKeyValue(entityContext.PartitionKey); TableClientHelpers.ValidateAzureTableKeyValue(entityContext.RowKey); return(BindEntityAsync(entityContext, context)); }
public bool TryConvert(object input, out TableEntityContext output) { TInput typedInput = input as TInput; if (typedInput == null) { output = null; return(false); } output = _innerConverter.Convert(typedInput); return(true); }
public async Task <IValueProvider> BindAsync(TableEntityContext value, ValueBindingContext context) { var table = value.Table; try { var result = await table.GetEntityAsync <TElement>(value.PartitionKey, value.RowKey, cancellationToken : context.CancellationToken).ConfigureAwait(false); return(new TableEntityValueBinder(value, result.Value, typeof(TElement))); } catch (RequestFailedException e) when (e.Status == 404 && (e.ErrorCode == TableErrorCode.TableNotFound || e.ErrorCode == TableErrorCode.ResourceNotFound)) { return(new NullEntityValueProvider <TElement>(value)); } }
public Task <IValueProvider> BindAsync(BindingContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } TableEntityPath boundPath = _path.Bind(context.BindingData); var table = _client.GetTableClient(boundPath.TableName); TableEntityContext entityContext = new TableEntityContext { Table = table, PartitionKey = boundPath.PartitionKey, RowKey = boundPath.RowKey }; return(BindEntityAsync(entityContext, context.ValueContext)); }
public async Task <IValueProvider> BindAsync(TableEntityContext value, ValueBindingContext context) { var table = value.Table; TableEntity entity; try { entity = await table.GetEntityAsync <TableEntity>( value.PartitionKey, value.RowKey).ConfigureAwait(false); } catch (RequestFailedException e) when (e.Status == 404 && (e.ErrorCode == TableErrorCode.TableNotFound || e.ErrorCode == TableErrorCode.ResourceNotFound)) { return(new NullEntityValueProvider <TElement>(value)); } return(new PocoEntityValueBinder <TElement>(value, context, entity, _entityToPocoConverter, _pocoToEntityConverter)); }
public NullEntityValueProvider(TableEntityContext entityContext) { _entityContext = entityContext; }
private Task <IValueProvider> BindEntityAsync(TableEntityContext entityContext, ValueBindingContext context) { return(_argumentBinding.BindAsync(entityContext, context)); }