コード例 #1
0
 public static object GetJsonProvidedIndexedProp(
     object underlying,
     FieldInfo field,
     int index)
 {
     var result = GetJsonProvidedSimpleProp(underlying, field);
     return CollectionUtil.ArrayValueAtIndex((Array) result, index);
 }
コード例 #2
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);
        }
コード例 #3
0
        /// <summary>
        ///     NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="object">object</param>
        /// <param name="propertyName">property name</param>
        /// <param name="index">index</param>
        /// <returns>value</returns>
        /// <throws>PropertyAccessException property access exceptions</throws>
        public static object GetJsonIndexedProp(
            object @object,
            string propertyName,
            int index)
        {
            var und = (JsonEventObjectBase) @object;
            if (und.TryGetNativeValue(propertyName, out var value)) {
                if (value == null) {
                    return null;
                }
                if (value is Array array) {
                    return CollectionUtil.ArrayValueAtIndex(array, index);
                }

                throw new InvalidOperationException(MESSAGE_VALUE_NOT_AN_ARRAY);
            }

            throw new KeyNotFoundException(propertyName);
        }
コード例 #4
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);
        }
コード例 #5
0
 private object GetBeanPropInternal(
     object @object,
     int index)
 {
     try {
         var value = (Array) _prop.GetValue(@object);
         return CollectionUtil.ArrayValueAtIndex(value, index);
     }
     catch (InvalidCastException e) {
         throw PropertyUtility.GetMismatchException(_prop, @object, e);
     }
     catch (TargetException e) {
         throw PropertyUtility.GetTargetException(_prop, e);
     }
     catch (TargetInvocationException e) {
         throw PropertyUtility.GetTargetException(_prop, e);
     }
     catch (MemberAccessException e) {
         throw PropertyUtility.GetMemberAccessException(_prop, e);
     }
     catch (ArgumentException e) {
         throw PropertyUtility.GetArgumentException(_prop, e);
     }
 }
コード例 #6
0
 public object GetJsonProp(object @object)
 {
     var value = JsonFieldGetterHelperProvided.GetJsonProvidedSimpleProp(@object, _field);
     return CollectionUtil.ArrayValueAtIndex((Array) value, _index);
 }