Beispiel #1
0
        private void Init()
        {
            _propertyNames = new string[_avroSchema.GetFields().Count];
            _propertyDescriptors = new EventPropertyDescriptor[_propertyNames.Length];
            int fieldNum = 0;

            foreach (Field field in _avroSchema.GetFields())
            {
                _propertyNames[fieldNum] = field.Name;

                Type propertyType = AvroTypeUtil.PropertyType(field.Schema);
                Type componentType = null;
                bool indexed = false;
                bool mapped = false;
                FragmentEventType fragmentEventType = null;

                if (field.Schema.Tag == global::Avro.Schema.Type.Array)
                {
                    componentType = AvroTypeUtil.PropertyType(field.Schema.GetElementType());
                    indexed = true;
                    if (field.Schema.GetElementType().Tag == global::Avro.Schema.Type.Record)
                    {
                        fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(field.Schema, _eventAdapterService);
                    }
                }
                else if (field.Schema.Tag == global::Avro.Schema.Type.Map)
                {
                    mapped = true;
                    componentType = AvroTypeUtil.PropertyType(field.Schema.GetValueType());
                }
                else if (field.Schema.Tag == global::Avro.Schema.Type.String)
                {
                    indexed = true;
                    componentType = typeof(char);
                    fragmentEventType = null;
                }
                else
                {
                    fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(field.Schema, _eventAdapterService);
                }

                var getter = new AvroEventBeanGetterSimple(
                    field, fragmentEventType == null ? null : fragmentEventType.FragmentType, _eventAdapterService);

                var descriptor = new EventPropertyDescriptor(
                    field.Name, propertyType, componentType, false, false, indexed, mapped, fragmentEventType != null);
                var item = new PropertySetDescriptorItem(descriptor, propertyType, getter, fragmentEventType);
                _propertyItems.Put(field.Name, item);
                _propertyDescriptors[fieldNum] = descriptor;

                fieldNum++;
            }
        }