public void WritePropertyToDictionary(IDictionary <string, object> dictionary, T obj)
        {
            object value = _property.Get(obj);

            if (value == null)
            {
                return;
            }

            var values = value as IDictionary <TKey, TValue>;

            if (values == null)
            {
                return;
            }

            var elements = new List <object>();

            foreach (var element in values)
            {
                elements.Add(new object[] { element.Key, element.Value });
            }

            dictionary.Add(_property.Property.Name, elements.ToArray());
        }
        public void WritePropertyToDictionary(IDictionary <string, object> dictionary, T obj)
        {
            object value = _property.Get(obj);

            if (value == null)
            {
                return;
            }

            var values = value as IList <TElement>;

            if (values == null)
            {
                return;
            }

            var elements = new object[values.Count];

            for (int i = 0; i < values.Count; i++)
            {
                elements[i] = _elementConverter.GetDictionary(values[i]);
            }

            dictionary.Add(_property.Property.Name, elements);
        }
예제 #3
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);
        }
예제 #4
0
        public Task <Value <TValue> > GetProperty(TranslateContext <TInput, TSchema> context)
        {
            if (context.HasInput)
            {
                return(Task.FromResult(_property.Get(context.Input)));
            }

            return(Task.FromResult(Value.Missing <TValue>()));
        }
        void ISetCorrelationId <T> .SetCorrelationId(SendContext <T> context)
        {
            var correlationId = _property.Get(context.Message);

            if (correlationId.HasValue && correlationId.Value != Guid.Empty)
            {
                context.CorrelationId = correlationId;
            }
        }
예제 #6
0
        public void SetCorrelationId(SendContext <T> context)
        {
            var message = (CorrelatedBy <Guid>)context.Message;

            var correlationId = _property.Get(message);

            if (correlationId != Guid.Empty)
            {
                context.CorrelationId = correlationId;
            }
        }
예제 #7
0
        public void WritePropertyToDictionary(IDictionary <string, object> dictionary, T obj)
        {
            var value = _property.Get(obj);

            if (value == null)
            {
                return;
            }

            dictionary.Add(_property.Property.Name, value);
        }
        public bool TryGetScopeId(TMessage input, out TId id)
        {
            if (input != null)
            {
                id = _property.Get(input);
                return(true);
            }

            id = default(TId);
            return(false);
        }
예제 #9
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);
        }
        public void WritePropertyToDictionary(IDictionary <string, object> dictionary, T obj)
        {
            var value = _property.Get(obj);

            if (value == null)
            {
                return;
            }

            var nullableValue = (TValue?)value;

            dictionary.Add(_property.Property.Name, nullableValue.Value);
        }
예제 #11
0
        public MessageData <TValue> GetProperty(TransformContext <TInput> context)
        {
            if (context.HasInput)
            {
                MessageData <TValue> value = _property.Get(context.Input);
                if (value?.Address != null)
                {
                    return(MessageDataFactory.Load <TValue>(_repository, value.Address, context.CancellationToken));
                }
            }

            return(new EmptyMessageData <TValue>());
        }
예제 #12
0
        public void WritePropertyToDictionary(IDictionary <string, object> dictionary, T obj)
        {
            var value = _property.Get(obj);

            if (!(value is IDictionary <TKey, TValue> values))
            {
                return;
            }

            object[] elementArray = values.Select(element => new object[] { element.Key, _elementConverter.GetDictionary(element.Value) })
                                    .ToArray <object>();

            dictionary.Add(_property.Property.Name, elementArray);
        }
예제 #13
0
        public void WritePropertyToDictionary(IDictionary <string, object> dictionary, T obj)
        {
            object value = _property.Get(obj);

            var values = value as IDictionary <TKey, TValue>;

            if (values == null)
            {
                return;
            }

            object[] elementArray = values.Select(element => new object[] { element.Key, element.Value })
                                    .ToArray <object>();

            dictionary.Add(_property.Property.Name, elementArray);
        }
예제 #14
0
        public PropertyNode(int id, PropertyInfo propertyInfo, PropertySelector <TProperty, TValue> propertySelector)
            : base(id)
        {
            _propertyInfo     = propertyInfo;
            _propertySelector = propertySelector;

            var property = new ReadOnlyProperty <T, TProperty>(propertyInfo);

            _propertyAction = (x, next) =>
            {
                if (x != null)
                {
                    TProperty propertyValue = property.Get(x);
                    next(propertyValue);
                }
            };
        }
예제 #15
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>());
            }
        }
        public void WritePropertyToDictionary(IDictionary <string, object> dictionary, T obj)
        {
            var value = _property.Get(obj);

            if (!(value is TElement[] values))
            {
                return;
            }

            var elements = new IDictionary <string, object> [values.Length];

            for (var i = 0; i < values.Length; i++)
            {
                elements[i] = _elementConverter.GetDictionary(values[i]);
            }

            dictionary.Add(_property.Property.Name, elements);
        }
예제 #17
0
        public void WritePropertyToDictionary(IDictionary <string, object> dictionary, T obj)
        {
            IDictionary <string, object> value = _converter.GetDictionary(_property.Get(obj));

            dictionary.Add(_property.Property.Name, value);
        }
예제 #18
0
 public void WritePropertyToDictionary(IDictionary <string, object> dictionary, T obj)
 {
     dictionary.Add(_property.Property.Name, _property.Get(obj));
 }