Esempio n. 1
0
        public Object GetAvroFieldValue(GenericRecord record)
        {
            var value = record.Get(_propertyName);

            if (value == null)
            {
                return(null);
            }

            if (value is Array)
            {
                return(AvroEventBeanGetterIndexed.GetIndexedValue((Array)value, _index));
            }

            if (value is IEnumerable <object> )
            {
                return(AvroEventBeanGetterIndexed.GetIndexedValue((IEnumerable <object>)value, _index));
            }

            if (value is IEnumerable)
            {
                return(AvroEventBeanGetterIndexed.GetIndexedValue(((IEnumerable)value).Cast <object>(), _index));
            }

            return(null);
        }
 public Object GetFragment(EventBean eventBean)
 {
     var record = (GenericRecord) eventBean.Underlying;
     var values = (ICollection<object>) record.Get(_posTop);
     var value = AvroEventBeanGetterIndexed.GetIndexedValue(values, _index);
     if (value == null || !(value is GenericRecord))
     {
         return null;
     }
     return _nested.GetAvroFragment((GenericRecord) value);
 }
 public Object Get(EventBean eventBean)
 {
     var record = (GenericRecord) eventBean.Underlying;
     var inner = (GenericRecord) record.Get(_top);
     if (inner == null)
     {
         return null;
     }
     var collection = (ICollection<object>) inner.Get(_pos);
     return AvroEventBeanGetterIndexed.GetIndexedValue(collection, _index);
 }
 private Object Navigate(EventBean eventBean)
 {
     var record = (GenericRecord) eventBean.Underlying;
     var values = (ICollection<object>) record.Get(_posTop);
     Object value = AvroEventBeanGetterIndexed.GetIndexedValue(values, _index);
     if (value == null || !(value is GenericRecord))
     {
         return null;
     }
     for (int i = 0; i < _nested.Length - 1; i++)
     {
         value = _nested[i].GetAvroFieldValue((GenericRecord) value);
         if (value == null || !(value is GenericRecord))
         {
             return null;
         }
     }
     return value;
 }
        public static Object GetAvroFieldValue(GenericRecord record, String propertyName, int index)
        {
            var value = record.Get(propertyName);

            if (value is Array valueArray)
            {
                return(AvroEventBeanGetterIndexed.GetIndexedValue(valueArray, index));
            }

            if (value is IEnumerable <object> valueGenericEnum)
            {
                return(AvroEventBeanGetterIndexed.GetIndexedValue(valueGenericEnum, index));
            }

            if (value is IEnumerable valueEnum)
            {
                return(AvroEventBeanGetterIndexed.GetIndexedValue(valueEnum.Cast <object>(), index));
            }

            return(null);
        }
 public Object Get(EventBean eventBean, int index)
 {
     var record = (GenericRecord) eventBean.Underlying;
     var values = (ICollection<object>) record.Get(_pos);
     return AvroEventBeanGetterIndexed.GetIndexedValue(values, index);
 }