コード例 #1
0
        public NestedPropertyGetter(
            IList<EventPropertyGetter> getterChain,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            Type finalPropertyType,
            Type finalGenericType,
            BeanEventTypeFactory beanEventTypeFactory)
            : base(
                eventBeanTypedEventFactory,
                beanEventTypeFactory,
                finalPropertyType,
                finalGenericType)
        {
            _getterChain = new BeanEventPropertyGetter[getterChain.Count];

            for (var i = 0; i < getterChain.Count; i++) {
                _getterChain[i] = (BeanEventPropertyGetter) getterChain[i];
            }
        }
コード例 #2
0
        public ArrayFieldPropertyGetter(
            FieldInfo field,
            int index,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            BeanEventTypeFactory beanEventTypeFactory)
            : base(
                eventBeanTypedEventFactory,
                beanEventTypeFactory,
                field.FieldType.GetElementType(),
                null)
        {
            _index = index;
            _field = field;

            if (index < 0) {
                throw new ArgumentException("Invalid negative index value");
            }
        }
コード例 #3
0
        public override GenericPropertyDesc GetPropertyTypeGeneric(
            BeanEventType eventType,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var descriptor = eventType.GetIndexedProperty(PropertyNameAtomic);
            if (descriptor == null) {
                return null;
            }

            if (descriptor.IsIndexedReadMethod) {
                return new GenericPropertyDesc(descriptor.ReturnType);
            }

            // Check if this is an method returning array which is a type of simple property
            if (!descriptor.PropertyType.IsSimple()) {
                return null;
            }

            var returnType = descriptor.ReturnType;
            if (returnType.IsArray) {
                return new GenericPropertyDesc(returnType.GetElementType());
            }

            if (returnType.IsGenericEnumerable() || TypeHelper.IsImplementsInterface(returnType, typeof(IEnumerable))) {
                if (descriptor.AccessorProp != null) {
                    var genericType = TypeHelper.GetGenericPropertyType(descriptor.AccessorProp, false);
                    return new GenericPropertyDesc(genericType);
                }

                if (descriptor.ReadMethod != null) {
                    var genericType = TypeHelper.GetGenericReturnType(descriptor.ReadMethod, false);
                    return new GenericPropertyDesc(genericType);
                }

                if (descriptor.AccessorField != null) {
                    var genericType = TypeHelper.GetGenericFieldType(descriptor.AccessorField, false);
                    return new GenericPropertyDesc(genericType);
                }

                return null;
            }

            return null;
        }
コード例 #4
0
ファイル: VariableUtil.cs プロジェクト: lanicon/nesper
 public static VariableMetaData CompileVariable(
     String variableName,
     String variableModuleName,
     NameAccessModifier variableVisibility,
     String optionalContextName,
     NameAccessModifier? optionalContextVisibility,
     String optionalModuleName,
     ClassIdentifierWArray variableType,
     bool isConstant,
     bool compileTimeConstant,
     Object initializationValue,
     ImportService importService,
     ExtensionClass extensionClass,
     EventBeanTypedEventFactory eventBeanTypedEventFactory,
     EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
     BeanEventTypeFactory beanEventTypeFactory)
 {
     try {
         return GetTypeInfo(
             variableName,
             variableModuleName,
             variableVisibility,
             optionalContextName,
             optionalContextVisibility,
             optionalModuleName,
             variableType,
             false,
             isConstant,
             compileTimeConstant,
             initializationValue,
             importService,
             extensionClass,
             eventBeanTypedEventFactory,
             eventTypeRepositoryPreconfigured,
             beanEventTypeFactory);
     }
     catch (VariableTypeException t) {
         throw new ExprValidationException(t.Message, t);
     }
     catch (Exception t) {
         throw new ExprValidationException("Failed to compile variable '" + variableName + "': " + t.Message, t);
     }
 }
コード例 #5
0
        /// <summary>
        ///     Constructor takes a type name, map of property names and types, for
        ///     use with nestable Map events.
        /// </summary>
        /// <param name="propertyTypes">is pairs of property name and type</param>
        /// <param name="optionalSuperTypes">the supertypes to this type if any, or null if there are no supertypes</param>
        /// <param name="optionalDeepSuperTypes">the deep supertypes to this type if any, or null if there are no deep supertypes</param>
        /// <param name="metadata">event type metadata</param>
        /// <param name="getterFactory">getter factory</param>
        /// <param name="beanEventTypeFactory">bean factory</param>
        /// <param name="endTimestampPropertyName">end timestamp</param>
        /// <param name="startTimestampPropertyName">start timestamp</param>
        /// <param name="publicFields"></param>
        protected BaseNestableEventType(
            EventTypeMetadata metadata,
            IDictionary<string, object> propertyTypes,
            EventType[] optionalSuperTypes,
            ISet<EventType> optionalDeepSuperTypes,
            string startTimestampPropertyName,
            string endTimestampPropertyName,
            EventTypeNestableGetterFactory getterFactory,
            BeanEventTypeFactory beanEventTypeFactory,
            bool publicFields)
        {
            _metadata = metadata;
            _getterFactory = getterFactory;
            _beanEventTypeFactory = beanEventTypeFactory;
            _publicFields = publicFields;
            _startTimestampPropertyName = startTimestampPropertyName;
            _endTimestampPropertyName = endTimestampPropertyName;

            _optionalSuperTypes = optionalSuperTypes;
            _optionalDeepSuperTypes = optionalDeepSuperTypes ?? Collections.GetEmptySet<EventType>();

            // determine property set and prepare getters
            var propertySet = EventTypeUtility.GetNestableProperties(
                propertyTypes,
                beanEventTypeFactory.EventBeanTypedEventFactory,
                getterFactory,
                optionalSuperTypes,
                beanEventTypeFactory,
                publicFields);

            _nestableTypes = propertySet.NestableTypes;
            _propertyNames = propertySet.PropertyNameArray;
            _propertyItems = propertySet.PropertyItems;
            _propertyDescriptors = propertySet.PropertyDescriptors.ToArray();

            var desc = EventTypeUtility.ValidatedDetermineTimestampProps(
                this,
                startTimestampPropertyName,
                endTimestampPropertyName,
                optionalSuperTypes);
            _startTimestampPropertyName = desc.Start;
            _endTimestampPropertyName = desc.End;
        }
コード例 #6
0
 public BeanEventType CreateBeanType(
     BeanEventTypeStem stem,
     EventTypeMetadata metadata,
     BeanEventTypeFactory beanEventTypeFactory,
     EventType[] superTypes,
     ICollection<EventType> deepSuperTypes,
     string startTimestampPropertyName,
     string endTimestampPropertyName)
 {
     return new BeanEventType(
         Container,
         stem,
         metadata,
         beanEventTypeFactory,
         superTypes,
         deepSuperTypes,
         startTimestampPropertyName,
         endTimestampPropertyName);
 }
コード例 #7
0
ファイル: VariableUtil.cs プロジェクト: lanicon/nesper
        public static void ConfigureVariables(
            VariableRepositoryPreconfigured repo,
            IDictionary<string, ConfigurationCommonVariable> variables,
            ImportService importService,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            foreach (var entry in variables) {
                string variableName = entry.Key.Trim();
                if (repo.GetMetadata(variableName) != null) {
                    continue;
                }

                VariableMetaData meta;
                try {
                    var variableType = ClassIdentifierWArray.ParseSODA(entry.Value.VariableType);
                    meta = GetTypeInfo(
                        variableName,
                        null,
                        NameAccessModifier.PRECONFIGURED,
                        null,
                        null,
                        null,
                        variableType,
                        true,
                        entry.Value.IsConstant,
                        entry.Value.IsConstant,
                        entry.Value.InitializationValue,
                        importService,
                        ExtensionClassEmpty.INSTANCE,
                        eventBeanTypedEventFactory,
                        eventTypeRepositoryPreconfigured,
                        beanEventTypeFactory);
                }
                catch (Exception t) {
                    throw new ConfigurationException("Error configuring variable '" + entry.Key + "': " + t.Message, t);
                }

                repo.AddVariable(entry.Key, meta);
            }
        }
コード例 #8
0
ファイル: MappedProperty.cs プロジェクト: lanicon/nesper
        // MapEventPropertyGetterAndMapped 
        public override MapEventPropertyGetter GetGetterMap(
            IDictionary<string, object> optionalMapPropTypes,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var type = optionalMapPropTypes.Get(PropertyNameAtomic);
            if (type == null) {
                return null;
            }

            if (type is Type asType && asType.IsGenericStringDictionary()) {
                return new MapMappedPropertyGetter(PropertyNameAtomic, Key);
            }

            if (type is IDictionary<string, object>) {
                return new MapMappedPropertyGetter(PropertyNameAtomic, Key);
            }

            return null;
        }
コード例 #9
0
 public MapEventType(
     EventTypeMetadata metadata,
     IDictionary<string, object> propertyTypes,
     EventType[] optionalSuperTypes,
     ISet<EventType> optionalDeepSuperTypes,
     string startTimestampPropertyName,
     string endTimestampPropertyName,
     BeanEventTypeFactory beanEventTypeFactory)
     : base(
         metadata,
         propertyTypes,
         optionalSuperTypes,
         optionalDeepSuperTypes,
         startTimestampPropertyName,
         endTimestampPropertyName,
         GETTER_FACTORY,
         beanEventTypeFactory,
         false)
 {
 }
コード例 #10
0
 public ObjectArrayEventType(
     EventTypeMetadata metadata,
     IDictionary<string, object> propertyTypes,
     EventType[] optionalSuperTypes,
     ISet<EventType> optionalDeepSuperTypes,
     string startTimestampName,
     string endTimestampName,
     BeanEventTypeFactory beanEventTypeFactory)
     : base(
         metadata,
         propertyTypes,
         optionalSuperTypes,
         optionalDeepSuperTypes,
         startTimestampName,
         endTimestampName,
         GetGetterFactory(metadata.Name, propertyTypes, optionalSuperTypes),
         beanEventTypeFactory,
         false)
 {
 }
コード例 #11
0
        // ObjectArrayEventPropertyGetterAndIndexed 
        public override ObjectArrayEventPropertyGetter GetGetterObjectArray(
            IDictionary<string, int> indexPerProperty,
            IDictionary<string, object> nestableTypes,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            if (!indexPerProperty.TryGetValue(PropertyNameAtomic, out var propertyIndex)) {
                return null;
            }

            var type = nestableTypes.Get(PropertyNameAtomic);
            if (type == null) {
                return null;
            }

            if (type is TypeBeanOrUnderlying[] typeBeanOrUnderlyings) {
                var innerType = typeBeanOrUnderlyings[0].EventType;
                if (!(innerType is ObjectArrayEventType)) {
                    return null;
                }

                return new ObjectArrayArrayPropertyGetter(
                    propertyIndex,
                    Index,
                    eventBeanTypedEventFactory,
                    innerType);
            }

            if (type is Type asType && asType.IsArray) {
                var componentType = asType.GetElementType();
                // its an array
                return new ObjectArrayArrayPONOEntryIndexedPropertyGetter(
                    propertyIndex,
                    Index,
                    eventBeanTypedEventFactory,
                    beanEventTypeFactory,
                    componentType);
            }

            return null;
        }
コード例 #12
0
ファイル: MappedProperty.cs プロジェクト: lanicon/nesper
        // ObjectArrayEventPropertyGetterAndMapped
        public override ObjectArrayEventPropertyGetter GetGetterObjectArray(
            IDictionary<string, int> indexPerProperty,
            IDictionary<string, object> nestableTypes,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            if (!indexPerProperty.TryGetValue(PropertyNameAtomic, out var index)) {
                return null;
            }

            var type = nestableTypes.Get(PropertyNameAtomic);
            if (type is Type asType && asType.IsGenericStringDictionary()) {
                return new ObjectArrayMappedPropertyGetter(index, Key);
            }

            if (type is IDictionary<string, object>) {
                return new ObjectArrayMappedPropertyGetter(index, Key);
            }

            return null;
        }
コード例 #13
0
        public EventPropertyGetterSPI GetGetterIndexedClassArray(
            string propertyNameAtomic,
            int index,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            Type componentType,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var field = FindField(propertyNameAtomic);

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

            if (field.OptionalField != null)
            {
                return(new JsonGetterIndexedProvidedBaseNative(eventBeanTypedEventFactory, beanEventTypeFactory, componentType, field.OptionalField, index));
            }

            return(new JsonGetterIndexedSchema(index, _detail.UnderlyingClassName, null, eventBeanTypedEventFactory, field));
        }
コード例 #14
0
        public EventPropertyGetterSPI GetGetterIndexedUnderlyingArray(
            string propertyNameAtomic,
            int index,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventType innerType,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var field = FindField(propertyNameAtomic);

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

            if (field.OptionalField != null)
            {
                return(new JsonGetterIndexedProvided(index, _detail.UnderlyingClassName, innerType, eventBeanTypedEventFactory, field.OptionalField));
            }

            return(new JsonGetterIndexedSchema(index, _detail.UnderlyingClassName, innerType, eventBeanTypedEventFactory, field));
        }
コード例 #15
0
        public EventPropertyGetterIndexedSPI GetPropertyProvidedGetterIndexed(
            IDictionary <string, object> nestableTypes,
            string indexedPropertyName,
            IndexedProperty indexedProperty,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var field = FindField(indexedPropertyName);

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

            if (field.OptionalField != null)
            {
                return(new JsonGetterIndexedRuntimeIndexProvided(field.OptionalField));
            }

            return(new JsonGetterIndexedRuntimeIndexSchema(field));
        }
コード例 #16
0
        public static void BuildXMLTypes(
            EventTypeRepositoryImpl repo,
            IDictionary<string, ConfigurationCommonEventTypeXMLDOM> eventTypesXMLDOM,
            BeanEventTypeFactory beanEventTypeFactory,
            XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory,
            IResourceManager resourceManager)
        {
            // Add from the configuration the XML DOM names and type def
            foreach (var entry in eventTypesXMLDOM) {
                if (repo.GetTypeByName(entry.Key) != null) {
                    continue;
                }
                
                SchemaModel schemaModel = null;
                if (entry.Value.SchemaResource != null || entry.Value.SchemaText != null) {
                    try {
                        schemaModel = XSDSchemaMapper.LoadAndMap(
                            entry.Value.SchemaResource,
                            entry.Value.SchemaText,
                            resourceManager);
                    }
                    catch (Exception ex) {
                        throw new ConfigurationException(ex.Message, ex);
                    }
                }

                try {
                    AddXMLDOMType(
                        repo,
                        entry.Key,
                        entry.Value,
                        schemaModel,
                        beanEventTypeFactory,
                        xmlFragmentEventTypeFactory);
                }
                catch (Exception ex) {
                    throw new ConfigurationException(ex.Message, ex);
                }
            }
        }
コード例 #17
0
        public override Type GetPropertyTypeMap(
            IDictionary<string, object> optionalMapPropTypes,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var type = optionalMapPropTypes.Get(PropertyNameAtomic);
            if (type == null) {
                return null;
            }

            if (type is TypeBeanOrUnderlying[] typeBeanOrUnderlyings) {
                var innerType = typeBeanOrUnderlyings[0].EventType;
                return innerType is MapEventType 
                    ? typeof(IDictionary<string, object>[]) 
                    : null;
            }

            if (type is Type asType && asType.IsArray) {
                return asType.GetElementType();
            }

            return null;
        }
コード例 #18
0
ファイル: NestedProperty.cs プロジェクト: lanicon/nesper
        public Type GetPropertyType(
            BeanEventType eventType,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            Type result = null;
            var boxed = false;

            var properties = Properties;
            var propertiesCount = properties.Count;
            for (var ii = 0; ii < propertiesCount; ii++) {
                var property = properties[ii];
                boxed |= !(property is SimpleProperty);
                result = property.GetPropertyType(eventType, beanEventTypeFactory);

                if (result == null) {
                    // property not found, return null
                    return null;
                }

                if (ii < (propertiesCount - 1)) {
                    // Map cannot be used to further nest as the type cannot be determined
                    if (result.IsGenericDictionary()) {
                        return null;
                    }

#if IRRELEVANT
                    if (result.IsArray || result.IsValueType || result.IsBuiltinDataType()) {
                        return null;
                    }
#endif

                    var publicFields = eventType.Stem.IsPublicFields;
                    eventType = beanEventTypeFactory.GetCreateBeanType(result, publicFields);
                }
            }

            return !boxed ? result : result.GetBoxedType();
        }
コード例 #19
0
 public ObjectArrayEventType CreateObjectArray(
     EventTypeMetadata metadata,
     IDictionary<string, object> properties,
     string[] superTypes,
     string startTimestampPropertyName,
     string endTimestampPropertyName,
     BeanEventTypeFactory beanEventTypeFactory,
     EventTypeNameResolver eventTypeNameResolver)
 {
     var st = EventTypeUtility.GetSuperTypesDepthFirst(
         superTypes,
         EventUnderlyingType.OBJECTARRAY,
         eventTypeNameResolver);
     properties = BaseNestableEventUtil.ResolvePropertyTypes(properties, eventTypeNameResolver);
     return new ObjectArrayEventType(
         metadata,
         properties,
         st.First,
         st.Second,
         startTimestampPropertyName,
         endTimestampPropertyName,
         beanEventTypeFactory);
 }
コード例 #20
0
        public override EventPropertyGetterSPI GetGetter(
            BeanEventType eventType,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            if (!eventType.Stem.IsPublicFields) {
                var propertyInfo = eventType.UnderlyingType.GetProperty(PropertyNameAtomic);
                if (propertyInfo != null && propertyInfo.CanRead) {
                }

                return new DynamicIndexedPropertyGetterByMethodOrProperty(
                    PropertyNameAtomic,
                    Index,
                    eventBeanTypedEventFactory,
                    beanEventTypeFactory);
            }

            return new DynamicIndexedPropertyGetterByField(
                PropertyNameAtomic,
                Index,
                eventBeanTypedEventFactory,
                beanEventTypeFactory);
        }
コード例 #21
0
        public void SetUp()
        {
            _container = SupportContainer.Reset();

            _beanEventTypeFactory = new BeanEventAdapter(
                _container,
                new ConcurrentDictionary <Type, BeanEventType>(),
                _container.Resolve <EventAdapterService>(),
                new EventTypeIdGeneratorImpl());
            _bean     = SupportBeanCombinedProps.MakeDefaultBean();
            _theEvent = SupportEventBeanFactory.CreateObject(_bean);

            List <EventPropertyGetter> getters = new List <EventPropertyGetter>();

            getters.Add(MakeGetterOne(0));
            getters.Add(MakeGetterTwo("0ma"));
            _getter = new NestedPropertyGetter(getters, _container.Resolve <EventAdapterService>(), typeof(IDictionary <string, object>), null);

            getters = new List <EventPropertyGetter>();
            getters.Add(MakeGetterOne(2));
            getters.Add(MakeGetterTwo("0ma"));
            _getterNull = new NestedPropertyGetter(getters, _container.Resolve <EventAdapterService>(), typeof(IDictionary <string, object>), null);
        }
コード例 #22
0
        public EventPropertyGetterSPI GetGetterIndexedEntryPONO(
            string propertyNameAtomic,
            int index,
            BeanEventPropertyGetter nestedGetter,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            BeanEventTypeFactory beanEventTypeFactory,
            Type propertyTypeGetter)
        {
            var field = FindField(propertyNameAtomic);

            if (field.OptionalField == null)
            {
                throw MakeIllegalState();
            }

            return(new JsonGetterIndexedEntryPONOProvided(
                       field.OptionalField,
                       index,
                       nestedGetter,
                       eventBeanTypedEventFactory,
                       beanEventTypeFactory,
                       propertyTypeGetter));
        }
コード例 #23
0
        public EventPropertyGetterSPI GetGetterNestedPONOProp(
            string propertyName,
            BeanEventPropertyGetter nestedGetter,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            BeanEventTypeFactory beanEventTypeFactory,
            Type nestedReturnType,
            Type nestedComponentType)
        {
            var field = FindField(propertyName);

            if (field == null || field.OptionalField == null)
            {
                return(null);
            }

            return(new JsonGetterNestedPONOPropProvided(
                       eventBeanTypedEventFactory,
                       beanEventTypeFactory,
                       nestedReturnType,
                       nestedComponentType,
                       field.OptionalField,
                       nestedGetter));
        }
コード例 #24
0
ファイル: EventBeanUtility.cs プロジェクト: lanicon/nesper
        /// <summary>
        ///     Create a fragment event type.
        /// </summary>
        /// <param name="propertyType">property return type</param>
        /// <param name="genericType">property generic type parameter, or null if none</param>
        /// <param name="beanEventTypeFactory">for event types</param>
        /// <param name="publicFields">indicator whether classes are public-field-property-accessible</param>
        /// <returns>fragment type</returns>
        public static FragmentEventType CreateNativeFragmentType(
            Type propertyType,
            Type genericType,
            BeanEventTypeFactory beanEventTypeFactory,
            bool publicFields)
        {
            var isIndexed = false;

            if (propertyType.IsArray) {
                isIndexed = true;
                propertyType = propertyType.GetElementType();
            }
            else if (propertyType.IsGenericDictionary()) {
                // Ignore this - technically enumerable
            }
            else if (propertyType.IsGenericEnumerable()) {
                propertyType = GenericExtensions
                    .FindGenericEnumerationInterface(propertyType)
                    .GetGenericArguments()[0];
                isIndexed = true;

#if false
                if (genericType == null) {
                    return null;
                }

                propertyType = genericType;
#endif
            }

            if (!propertyType.IsFragmentableType()) {
                return null;
            }

            EventType type = beanEventTypeFactory.GetCreateBeanType(propertyType, publicFields);
            return new FragmentEventType(type, isIndexed, true);
        }
コード例 #25
0
ファイル: MappedProperty.cs プロジェクト: lanicon/nesper
        public override GenericPropertyDesc GetPropertyTypeGeneric(
            BeanEventType eventType,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var propertyDesc = eventType.GetMappedProperty(PropertyNameAtomic);
            if (propertyDesc == null) {
                return null;
            }

            if (propertyDesc.IsMappedReadMethod) {
                return new GenericPropertyDesc(propertyDesc.ReadMethod.ReturnType);
            }

            if (!propertyDesc.PropertyType.IsSimple()) {
                return null;
            }

            var returnType = propertyDesc.ReturnType;
            if (returnType.IsGenericStringDictionary()) {
                if (propertyDesc.AccessorProp != null) {
                    var genericType = TypeHelper.GetGenericPropertyTypeMap(propertyDesc.AccessorProp, false);
                    return new GenericPropertyDesc(genericType);
                }

                if (propertyDesc.ReadMethod != null) {
                    var genericType = TypeHelper.GetGenericReturnTypeMap(propertyDesc.ReadMethod, false);
                    return new GenericPropertyDesc(genericType);
                }

                if (propertyDesc.AccessorField != null) {
                    var genericType = TypeHelper.GetGenericFieldTypeMap(propertyDesc.AccessorField, false);
                    return new GenericPropertyDesc(genericType);
                }
            }

            return null;
        }
コード例 #26
0
ファイル: MappedProperty.cs プロジェクト: lanicon/nesper
        public override Type GetPropertyType(
            BeanEventType eventType,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var propertyDesc = eventType.GetMappedProperty(PropertyNameAtomic);
            if (propertyDesc == null) {
                return null;
            }

            if (propertyDesc.IsMappedReadMethod) {
                return propertyDesc.ReadMethod.ReturnType;
            }

            if (!propertyDesc.PropertyType.IsSimple()) {
                return null;
            }

            if (propertyDesc.AccessorProp != null) {
                var accessorPropType = propertyDesc.AccessorProp.PropertyType;
                AssertGenericDictionary(accessorPropType);
                return accessorPropType.GetDictionaryValueType();
            }

            if (propertyDesc.IsSimpleReadMethod) {
                var accessorPropType = propertyDesc.ReadMethod.ReturnType;
                AssertGenericDictionary(accessorPropType);
                return accessorPropType.GetDictionaryValueType();
            }

            if (propertyDesc.AccessorField != null) {
                var accessorFieldType = propertyDesc.AccessorField.FieldType;
                AssertGenericDictionary(accessorFieldType);
                return accessorFieldType.GetDictionaryValueType();
            }

            throw new IllegalStateException($"invalid property descriptor: {propertyDesc}");
        }
コード例 #27
0
        public static ObjectArrayEventType MakeOATypeCompileTime(
            EventTypeMetadata metadata,
            IDictionary<string, object> properyTypes,
            EventType[] optionalSuperTypes,
            ISet<EventType> optionalDeepSupertypes,
            string startTimestampName,
            string endTimestampName,
            BeanEventTypeFactory beanEventTypeFactory,
            EventTypeCompileTimeResolver eventTypeCompileTimeResolver)
        {
            if (metadata.ApplicationType != EventTypeApplicationType.OBJECTARR) {
                throw new ArgumentException("Invalid application type " + metadata.ApplicationType);
            }

            IDictionary<string, object> verified = ResolvePropertyTypes(properyTypes, eventTypeCompileTimeResolver);
            return new ObjectArrayEventType(
                metadata,
                verified,
                optionalSuperTypes,
                optionalDeepSupertypes,
                startTimestampName,
                endTimestampName,
                beanEventTypeFactory);
        }
コード例 #28
0
        public static EventType GetBuiltInEventType(
            string moduleName,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var metadata = new EventTypeMetadata(
                "anonymous",
                moduleName,
                EventTypeTypeClass.STREAM,
                EventTypeApplicationType.OBJECTARR,
                NameAccessModifier.TRANSIENT,
                EventTypeBusModifier.NONBUS,
                false,
                EventTypeIdPair.Unassigned());

            return(BaseNestableEventUtil.MakeOATypeCompileTime(
                       metadata,
                       TYPEINFO,
                       null,
                       null,
                       null,
                       null,
                       beanEventTypeFactory,
                       null));
        }
コード例 #29
0
        // MapEventPropertyGetterAndIndexed
        public override MapEventPropertyGetter GetGetterMap(
            IDictionary<string, object> optionalMapPropTypes,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            var type = optionalMapPropTypes.Get(PropertyNameAtomic);
            if (type == null) {
                return null;
            }

            if (type is TypeBeanOrUnderlying[] typeBeanOrUnderlyings) {
                var innerType = typeBeanOrUnderlyings[0].EventType;
                if (!(innerType is MapEventType)) {
                    return null;
                }

                return new MapArrayPropertyGetter(
                    PropertyNameAtomic,
                    Index,
                    eventBeanTypedEventFactory,
                    innerType);
            }

            if (type is Type asType && asType.IsArray) {
                var componentType = asType.GetElementType();
                // its an array
                return new MapArrayPONOEntryIndexedPropertyGetter(
                    PropertyNameAtomic,
                    Index,
                    eventBeanTypedEventFactory,
                    beanEventTypeFactory,
                    componentType);
            }

            return null;
        }
コード例 #30
0
ファイル: TestBeanEventAdapter.cs プロジェクト: ikvm/nesper
 public void SetUp()
 {
     _beanEventTypeFactory = new BeanEventAdapter(new ConcurrentDictionary <Type, BeanEventType>(), SupportEventAdapterService.Service, new EventTypeIdGeneratorImpl());
 }