Exemple #1
0
        private static EventType ValidateExpressionGetEventType(
            string msgprefix,
            IList<AnnotationDesc> annotations,
            StatementCompileTimeServices services)
        {
            var annos = AnnotationUtil.MapByNameLowerCase(annotations);

            // check annotations used
            var typeAnnos = annos.Delete("type");
            if (!annos.IsEmpty()) {
                throw new ExprValidationException(msgprefix + " unrecognized annotation '" + annos.Keys.First() + "'");
            }

            // type determination
            EventType optionalType = null;
            if (typeAnnos != null) {
                var typeName = AnnotationUtil.GetExpectSingleStringValue(msgprefix, typeAnnos);
                optionalType = services.EventTypeCompileTimeResolver.GetTypeByName(typeName);
                if (optionalType == null) {
                    throw new ExprValidationException(msgprefix + " failed to find event type '" + typeName + "'");
                }
            }

            return optionalType;
        }
        private static EventType ValidateExpressionGetEventType(string msgprefix, IList <AnnotationDesc> annotations, EventAdapterService eventAdapterService)

        {
            IDictionary <String, IList <AnnotationDesc> > annos = AnnotationUtil.MapByNameLowerCase(annotations);

            // check annotations used
            IList <AnnotationDesc> typeAnnos = annos.Pluck("type");

            if (!annos.IsEmpty())
            {
                throw new ExprValidationException(msgprefix + " unrecognized annotation '" + annos.Keys.First() + "'");
            }

            // type determination
            EventType optionalType = null;

            if (typeAnnos != null)
            {
                string typeName = AnnotationUtil.GetExpectSingleStringValue(msgprefix, typeAnnos);
                optionalType = eventAdapterService.GetEventTypeByName(typeName);
                if (optionalType == null)
                {
                    throw new ExprValidationException(msgprefix + " failed to find event type '" + typeName + "'");
                }
            }

            return(optionalType);
        }