Example #1
0
        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>());
            }
        }
Example #2
0
        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);
        }
Example #3
0
        public void Map(TEntity entity, TextSlice slice)
        {
            var valueSlice = _valueSliceFactory(slice, _position);

            var value = _valueFactory(valueSlice);

            _writeProperty.Set(entity, value);
        }
Example #4
0
        public TEntity Create()
        {
            var entity = _new();

            _entityTypeProperty.Set(entity, _entityInfo);

            return(entity);
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
 public void SetProperty(TLayout layout, Layout <T> value)
 {
     _property.Set(layout, value);
 }
Example #9
0
        public void Convert(TEntity entity, TextSlice slice)
        {
            var value = _valueFactory(slice);

            _writeProperty.Set(entity, value);
        }
Example #10
0
 public void Initialize(TEntity entity)
 {
     _writeProperty.Set(entity, new ConstantValue <TValue>(_value));
 }
Example #11
0
 public void SetProperty(TLayout layout, Entity <TEntity> value)
 {
     _property.Set(layout, _propertyConverter(value));
 }
Example #12
0
        public void Map(TEntity entity, TextSlice slice)
        {
            var value = new SliceValue <TValue>(slice, _position, _valueFactory);

            _writeProperty.Set(entity, value);
        }
Example #13
0
        public async Task Apply(TEntity entity, TranslateContext <TInput, TSchema> context)
        {
            var value = await _propertyProvider.GetProperty(context).ConfigureAwait(false);

            _property.Set(entity, value);
        }