public async Task Apply(TResult entity, TranslateContext <TInput, TSchema> context) { var inputValue = _inputProperty.Get(context.Input) ?? Value.Missing <TEntity>(); TranslateContext <TEntity, TSchema> inputContext = context.CreateContext(inputValue.Value); var result = await _entityTranslator.Translate(inputContext).ConfigureAwait(false); if (result.HasResult && result.TryGetEntity(0, out TEntity resultEntity)) { _property.Set(entity, new ConstantValue <TEntity>(resultEntity)); } else { _property.Set(entity, Value.Missing <TEntity>()); } }
public Task Apply(TResult entity, TranslateContext <TInput, TSchema> context) { var inputValue = _inputProperty.Get(context.Input) ?? ValueList.Missing <TValue>(); _property.Set(entity, inputValue); return(TaskUtil.Completed); }
public void Map(TEntity entity, TextSlice slice) { var valueSlice = _valueSliceFactory(slice, _position); var value = _valueFactory(valueSlice); _writeProperty.Set(entity, value); }
public TEntity Create() { var entity = _new(); _entityTypeProperty.Set(entity, _entityInfo); return(entity); }
public Task Apply(TEntity entity, TranslateContext <TInput, TSchema> context) { var existing = _readProperty.Get(entity); if (existing == null) { _property.Set(entity, ValueList.Missing <TPropertyEntity>()); } return(TaskUtil.Completed); }
public Task Apply(TEntity entity, TranslateContext <TInput, TSchema> context) { var inputValue = context.HasInput ? _inputProperty.Get(context.Input) : Value.Missing <TPropertyEntity>(); var subContext = context.CreateValueContext(inputValue); var resultValue = _valueProvider(subContext) ?? Value.Missing <TPropertyEntity>(); _property.Set(entity, resultValue); return(TaskUtil.Completed); }
public TEntity Create() { var entity = new TImplementation(); _entityInfoProperty.Set(entity, _entityInfo); for (int i = 0; i < _initializers.Length; i++) { _initializers[i].Initialize(entity); } return(entity); }
public void SetProperty(TLayout layout, Layout <T> value) { _property.Set(layout, value); }
public void Convert(TEntity entity, TextSlice slice) { var value = _valueFactory(slice); _writeProperty.Set(entity, value); }
public void Initialize(TEntity entity) { _writeProperty.Set(entity, new ConstantValue <TValue>(_value)); }
public void SetProperty(TLayout layout, Entity <TEntity> value) { _property.Set(layout, _propertyConverter(value)); }
public void Map(TEntity entity, TextSlice slice) { var value = new SliceValue <TValue>(slice, _position, _valueFactory); _writeProperty.Set(entity, value); }
public async Task Apply(TEntity entity, TranslateContext <TInput, TSchema> context) { var value = await _propertyProvider.GetProperty(context).ConfigureAwait(false); _property.Set(entity, value); }