Exemplo n.º 1
0
        public void SendEvent(object theEvent)
        {
            var underlying = GetUnderlying(theEvent);
            var eventBean = _eventBeanTypedEventFactory.AdapterForTypedJson(underlying, _eventType);

            if (_threadingService.IsInboundThreading) {
                _threadingService.SubmitInbound(eventBean, _runtimeEventSender);
            }
            else {
                _runtimeEventSender.ProcessWrappedEvent(eventBean);
            }
        }
Exemplo n.º 2
0
        public static object HandleJsonProvidedCreateFragmentArray(
            object value,
            EventType fragmentType,
            EventBeanTypedEventFactory factory)
        {
            if (value == null) {
                return null;
            }

            var array = value as Array;
            var len = array.Length;
            var events = new EventBean[len];
            if (fragmentType is JsonEventType) {
                for (var i = 0; i < len; i++) {
                    object item = array.GetValue(i);
                    events[i] = factory.AdapterForTypedJson(item, fragmentType);
                }
            }
            else {
                for (var i = 0; i < len; i++) {
                    object item = array.GetValue(i);
                    events[i] = factory.AdapterForTypedObject(item, fragmentType);
                }
            }

            return events;
        }
Exemplo n.º 3
0
        /// <summary>
        ///     NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="prop">value</param>
        /// <param name="fragmentType">event type</param>
        /// <param name="factory">factory</param>
        /// <param name="index">index</param>
        /// <returns>event bean or null</returns>
        public static EventBean HandleJsonProvidedCreateFragmentIndexed(
            object prop,
            int index,
            EventType fragmentType,
            EventBeanTypedEventFactory factory)
        {
            prop = CollectionUtil.ArrayValueAtIndex((Array) prop, index);
            if (prop == null) {
                return null;
            }

            return factory.AdapterForTypedJson(prop, fragmentType);
        }
Exemplo n.º 4
0
        public override object GetJsonFragment(object @object)
        {
            if (OptionalInnerType == null) {
                return null;
            }

            var value = JsonFieldGetterHelperSchema.GetJsonIndexedProp(@object, _field.PropertyName, Index);
            if (value == null) {
                return null;
            }

            return EventBeanTypedEventFactory.AdapterForTypedJson(value, OptionalInnerType);
        }
Exemplo n.º 5
0
        /// <summary>
        ///     NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="und">underlying</param>
        /// <param name="propertyName">property name</param>
        /// <param name="fragmentType">event type</param>
        /// <param name="factory">factory</param>
        /// <returns>event bean or null</returns>
        public static EventBean HandleJsonCreateFragmentSimple(
            JsonEventObjectBase und,
            string propertyName,
            EventType fragmentType,
            EventBeanTypedEventFactory factory)
        {
            if (und.TryGetNativeValue(propertyName, out var prop)) {
                if (prop == null) {
                    return null;
                }

                return factory.AdapterForTypedJson(prop, fragmentType);
            }

            throw new KeyNotFoundException(propertyName);
        }
Exemplo n.º 6
0
        public static object HandleJsonProvidedCreateFragmentSimple(
            object underlying,
            FieldInfo field,
            EventType fragmentType,
            EventBeanTypedEventFactory factory)
        {
            var prop = GetJsonProvidedSimpleProp(underlying, field);
            if (prop == null) {
                return null;
            }

            if (fragmentType is JsonEventType) {
                return factory.AdapterForTypedJson(prop, fragmentType);
            }

            return factory.AdapterForTypedObject(prop, fragmentType);
        }
Exemplo n.º 7
0
        /// <summary>
        ///     NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="und">underlying</param>
        /// <param name="propertyName">property name</param>
        /// <param name="fragmentType">event type</param>
        /// <param name="factory">factory</param>
        /// <param name="index">index</param>
        /// <returns>event bean or null</returns>
        public static EventBean HandleJsonCreateFragmentIndexed(
            JsonEventObjectBase und,
            string propertyName,
            int index,
            EventType fragmentType,
            EventBeanTypedEventFactory factory)
        {
            if (und.TryGetNativeValue(propertyName, out var prop)) {
                if (prop is Array array) {
                    prop = CollectionUtil.ArrayValueAtIndex(array, index);
                    if (prop == null) {
                        return null;
                    }

                    return factory.AdapterForTypedJson(prop, fragmentType);
                }

                throw new InvalidOperationException(MESSAGE_VALUE_NOT_AN_ARRAY);
            }

            throw new KeyNotFoundException(propertyName);
        }
Exemplo n.º 8
0
        /// <summary>
        ///     NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="und">underlying</param>
        /// <param name="propertyName">property name</param>
        /// <param name="fragmentType">event type</param>
        /// <param name="factory">factory</param>
        /// <returns>event bean or null</returns>
        public static EventBean[] HandleJsonCreateFragmentArray(
            JsonEventObjectBase und,
            string propertyName,
            EventType fragmentType,
            EventBeanTypedEventFactory factory)
        {
            if (und.TryGetNativeValue(propertyName, out var value)) {
                if (value == null) {
                    return null;
                }

                var asArray = (Array) value;
                var len = asArray.Length;
                var events = new EventBean[len];
                for (var i = 0; i < len; i++) {
                    object item = asArray.GetValue(i);
                    events[i] = factory.AdapterForTypedJson(item, fragmentType);
                }

                return events;
            }
            
            throw new KeyNotFoundException(propertyName);
        }
Exemplo n.º 9
0
        public EventBean Make(object[] propertyValues)
        {
            var outObject = MakeUnderlying(propertyValues);

            return(_service.AdapterForTypedJson(outObject, _jsonEventType));
        }
Exemplo n.º 10
0
 public EventBean Copy(EventBean theEvent)
 {
     var source = theEvent.Underlying;
     var target = _eventType.Delegate.TryCopy(source);
     return _eventBeanTypedEventFactory.AdapterForTypedJson(target, _eventType);
 }
Exemplo n.º 11
0
 public EventBean Make(object[] properties)
 {
     var values = MakeUnderlying(properties);
     return _eventAdapterService.AdapterForTypedJson(values, _jsonEventType);
 }
Exemplo n.º 12
0
 public EventBean Wrap(object underlying)
 {
     var und = _type.Parse((string) underlying);
     return _factory.AdapterForTypedJson(und, _type);
 }