public virtual Task <ITriggerData> BindAsync(TTriggerValue value, ValueBindingContext context)
        {
            Dictionary <string, object> bindingData = _hooks.GetContractInstance(value);

            TMessage eventData = _hooks.BindMessage(value, context);

            object userValue = this.Convert(eventData, bindingData);

            string invokeString = ConvertToString(eventData);

            IValueProvider valueProvider = new ConstantValueProvider(userValue, this._elementType, invokeString);
            var            triggerData   = new TriggerData(valueProvider, bindingData);

            return(Task.FromResult <ITriggerData>(triggerData));
        }
Example #2
0
        public override Task <ITriggerData> BindAsync(TTriggerValue value, ValueBindingContext context)
        {
            Dictionary <string, object> bindingData = _hooks.GetContractInstance(value);

            TMessage[] arrayRaw = _hooks.BindMessageArray(value, context);

            int  len         = arrayRaw.Length;
            Type elementType = _innerBinding._elementType;

            var arrayUser = Array.CreateInstance(elementType, len);

            for (int i = 0; i < len; i++)
            {
                TMessage item = arrayRaw[i];
                object   obj  = _innerBinding.Convert(item, null);
                arrayUser.SetValue(obj, i);
            }
            Type arrayType = elementType.MakeArrayType();

            IValueProvider valueProvider = new ConstantValueProvider(arrayUser, arrayType, "???");
            var            triggerData   = new TriggerData(valueProvider, bindingData);

            return(Task.FromResult <ITriggerData>(triggerData));
        }