Example #1
0
        public static void BuildBeanTypes(
            BeanEventTypeStemService beanEventTypeStemService,
            EventTypeRepositoryImpl repo,
            IDictionary<string, Type> beanTypes,
            BeanEventTypeFactoryPrivate privateFactory,
            IDictionary<string, ConfigurationCommonEventTypeBean> configs)
        {
            if (beanTypes.IsEmpty()) {
                beanTypes = new Dictionary<string, Type>();
            }

            AddPredefinedBeanEventTypes(beanTypes);

            foreach (var beanType in beanTypes) {
                if (repo.GetTypeByName(beanType.Key) == null) {
                    BuildPublicBeanType(
                        beanEventTypeStemService,
                        repo,
                        beanType.Key,
                        beanType.Value,
                        privateFactory,
                        configs);
                }
            }
        }
Example #2
0
        private EventType ResolvePreconfigured(string typeName)
        {
            var eventType = publics.GetTypeByName(typeName);
            if (eventType == null) {
                return null;
            }

            moduleDependencies.AddPublicEventType(typeName);
            return eventType;
        }
Example #3
0
        private EventType FindTypeMayNull(string eventTypeName)
        {
            var eventType = eventTypeRepositoryPreconfigured.GetTypeByName(eventTypeName);
            if (eventType != null) {
                return eventType;
            }

            try {
                eventType = pathEventTypes.GetAnyModuleExpectSingle(eventTypeName, null).First;
            }
            catch (PathException ex) {
                throw new EPException("Failed to obtain event type '" + eventTypeName + "': " + ex.Message, ex);
            }

            return eventType;
        }
Example #4
0
        private static VariableMetaData GetTypeInfo(
            string variableName,
            string variableModuleName,
            NameAccessModifier variableVisibility,
            string optionalContextName,
            NameAccessModifier? optionalContextVisibility,
            string optionalContextModule,
            ClassIdentifierWArray variableTypeWArray,
            bool preconfigured,
            bool constant,
            bool compileTimeConstant,
            object valueAsProvided,
            ImportService importService,
            ExtensionClass extensionClass,
            EventBeanTypedEventFactory eventBeanTypedEventFactory,
            EventTypeRepositoryImpl eventTypeRepositoryPreconfigured,
            BeanEventTypeFactory beanEventTypeFactory)
        {
            // Determine the variable type
            var primitiveType = TypeHelper.GetPrimitiveTypeForName(variableTypeWArray.ClassIdentifier);
            var type = TypeHelper.GetTypeForSimpleName(variableTypeWArray.ClassIdentifier).GetBoxedType();
            Type arrayType = null;
            EventType eventType = null;
            if (type == null) {
                if (variableTypeWArray.ClassIdentifier.Equals("object", StringComparison.InvariantCultureIgnoreCase)) {
                    type = TypeHelper.GetArrayType(typeof(object), variableTypeWArray.ArrayDimensions);
                }

                if (type == null) {
                    eventType = eventTypeRepositoryPreconfigured.GetTypeByName(variableTypeWArray.ClassIdentifier);
                    if (eventType != null) {
                        type = eventType.UnderlyingType;
                    }
                }

                ImportException lastException = null;
                if (type == null) {
                    try {
                        type = importService.ResolveClass(variableTypeWArray.ClassIdentifier, false, extensionClass);
                        type = TypeHelper.GetArrayType(type, variableTypeWArray.ArrayDimensions);
                    }
                    catch (ImportException e) {
                        Log.Debug("Not found '" + type + "': " + e.Message, e);
                        lastException = e;
                        // expected
                    }
                }

                if (type == null) {
                    throw new VariableTypeException(
                        "Cannot create variable '" +
                        variableName +
                        "', type '" +
                        variableTypeWArray.ClassIdentifier +
                        "' is not a recognized type",
                        lastException);
                }

                if (variableTypeWArray.ArrayDimensions > 0 && eventType != null) {
                    throw new VariableTypeException(
                        "Cannot create variable '" +
                        variableName +
                        "', type '" +
                        variableTypeWArray.ClassIdentifier +
                        "' cannot be declared as an array type as it is an event type",
                        lastException);
                }
            }
            else {
                if (variableTypeWArray.ArrayDimensions > 0) {
                    if (variableTypeWArray.IsArrayOfPrimitive) {
                        if (primitiveType == null) {
                            throw new VariableTypeException(
                                "Cannot create variable '" +
                                variableName +
                                "', type '" +
                                variableTypeWArray.ClassIdentifier +
                                "' is not a primitive type");
                        }

                        arrayType = TypeHelper.GetArrayType(primitiveType, variableTypeWArray.ArrayDimensions);
                    }
                    else {
                        arrayType = TypeHelper.GetArrayType(type, variableTypeWArray.ArrayDimensions);
                    }
                }
            }

            if (eventType == null &&
                !type.IsBuiltinDataType() &&
                type != typeof(object) &&
                !type.IsArray &&
                !type.IsEnum) {
                if (variableTypeWArray.ArrayDimensions > 0) {
                    throw new VariableTypeException(
                        "Cannot create variable '" +
                        variableName +
                        "', type '" +
                        variableTypeWArray.ClassIdentifier +
                        "' cannot be declared as an array, only scalar types can be array");
                }

                eventType = beanEventTypeFactory.GetCreateBeanType(type, false);
            }

            if (arrayType != null) {
                type = arrayType;
            }

            var coerced = GetCoercedValue(valueAsProvided, eventType, variableName, type, eventBeanTypedEventFactory);
            return new VariableMetaData(
                variableName,
                variableModuleName,
                variableVisibility,
                optionalContextName,
                optionalContextVisibility,
                optionalContextModule,
                type,
                eventType,
                preconfigured,
                constant,
                compileTimeConstant,
                coerced,
                true);
        }