コード例 #1
0
ファイル: AvroFragmentTypeUtil.cs プロジェクト: valmac/nesper
        internal static FragmentEventType GetFragmentType(
            Schema schema,
            string propertyName,
            IDictionary <string, PropertySetDescriptorItem> propertyItems,
            EventAdapterService eventAdapterService)
        {
            string unescapePropName        = ASTUtil.UnescapeDot(propertyName);
            PropertySetDescriptorItem item = propertyItems.Get(unescapePropName);

            if (item != null)
            {
                return(item.FragmentEventType);
            }

            Property            property = PropertyParser.ParseAndWalkLaxToSimple(propertyName);
            AvroFieldDescriptor desc     = AvroFieldUtil.FieldForProperty(schema, property);

            if (desc == null)
            {
                return(null);
            }
            if (desc.IsDynamic)
            {
                return(null);
            }
            Schema fieldSchemaByAccess = desc.Field.Schema;

            if (desc.IsAccessedByIndex)
            {
                fieldSchemaByAccess = fieldSchemaByAccess.GetElementType();
            }
            return(GetFragmentEventTypeForField(fieldSchemaByAccess, eventAdapterService));
        }
コード例 #2
0
ファイル: AvroPropertyUtil.cs プロジェクト: lanicon/nesper
        public static Type PropertyType(
            Schema fieldSchema,
            Property property)
        {
            var desc = AvroFieldUtil.FieldForProperty(fieldSchema, property);
            if (desc == null) {
                return null;
            }

            if (desc.IsDynamic) {
                return typeof(object);
            }

            Schema typeSchema = desc.Field.Schema;
            if (desc.IsAccessedByIndex) {
                if (desc.Field.Schema is ArraySchema arraySchema) {
                    typeSchema = arraySchema.ItemSchema;
                } else if (desc.Field.Schema is PrimitiveSchema primitiveSchema) {
                    // Only happens for strings
                    return typeof(char);
                }
            }
            else if (desc.IsAccessedByKey) {
                typeSchema = desc.Field.Schema.AsMapSchema().ValueSchema;
            }

            return AvroTypeUtil.PropertyType(typeSchema);
        }
コード例 #3
0
ファイル: AvroPropertyUtil.cs プロジェクト: valmac/nesper
        public static Type PropertyType(Schema fieldSchema, Property property)
        {
            var desc = AvroFieldUtil.FieldForProperty(fieldSchema, property);

            if (desc == null)
            {
                return(null);
            }
            if (desc.IsDynamic)
            {
                return(typeof(Object));
            }
            Schema typeSchema = desc.Field.Schema;

            if (desc.IsAccessedByIndex)
            {
                if (desc.Field.Schema.Tag == Schema.Type.Array)
                {
                    typeSchema = desc.Field.Schema.GetElementType();
                }
                else if (desc.Field.Schema.Tag == Schema.Type.String)
                {
                    return(typeof(char));
                }
            }
            else if (desc.IsAccessedByKey)
            {
                typeSchema = desc.Field.Schema.GetValueType();
            }
            return(AvroTypeUtil.PropertyType(typeSchema));
        }
コード例 #4
0
        internal static FragmentEventType GetFragmentType(
            Schema schema,
            string propertyName,
            string moduleName,
            IDictionary<string, PropertySetDescriptorItem> propertyItems,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventTypeAvroHandler eventTypeAvroHandler,
            AvroEventTypeFragmentTypeCache fragmentTypeCache)
        {
            var unescapePropName = StringValue.UnescapeDot(propertyName);
            var item = propertyItems.Get(unescapePropName);
            if (item != null) {
                return item.FragmentEventType;
            }

            var property = PropertyParser.ParseAndWalkLaxToSimple(propertyName);
            var desc = AvroFieldUtil.FieldForProperty(schema, property);
            if (desc == null) {
                return null;
            }

            if (desc.IsDynamic) {
                return null;
            }

            var fieldSchemaByAccess = desc.Field.Schema;
            if (desc.IsAccessedByIndex) {
                fieldSchemaByAccess = fieldSchemaByAccess.AsArraySchema().ItemSchema;
            }

            return GetFragmentEventTypeForField(
                fieldSchemaByAccess,
                moduleName,
                eventBeanTypedEventFactory,
                eventTypeAvroHandler,
                fragmentTypeCache);
        }