Ejemplo n.º 1
0
        internal Expression Build(Expression source)
        {
            var parameterType = source.Type.GetGenericArguments()[0];

            if (parameterType != typeof(Message))
            {
                source = Expression.Call(typeof(Parse), nameof(Convert), null, source);
            }

            var address = Address;

            if (!string.IsNullOrEmpty(address))
            {
                source = Expression.Call(typeof(Parse), nameof(Filter), null, source, Expression.Constant(address));
            }

            var typeTag = TypeTag;

            if (string.IsNullOrEmpty(typeTag))
            {
                return(source);
            }
            else
            {
                var readerParameter = Expression.Parameter(typeof(BinaryReader));
                var parseMessage    = MessageParser.Content(typeTag, readerParameter);
                var messageParser   = Expression.Lambda(parseMessage, readerParameter);
                return(Expression.Call(typeof(Parse), nameof(Process), new[] { messageParser.ReturnType }, source, messageParser));
            }
        }
Ejemplo n.º 2
0
        protected override Expression BuildSelector(Expression expression)
        {
            var readerParameter = Expression.Parameter(typeof(BinaryReader));
            var builder         = Expression.Constant(this);

            if (string.IsNullOrEmpty(TypeTag))
            {
                return(expression);
            }
            else
            {
                var parseMessage  = MessageParser.Content(TypeTag, readerParameter);
                var messageParser = Expression.Lambda(parseMessage, readerParameter);
                return(Expression.Call(builder, "Process", new[] { messageParser.ReturnType }, expression, messageParser));
            }
        }
Ejemplo n.º 3
0
        protected override Expression BuildCombinator(IEnumerable <Expression> arguments)
        {
            var readerParameter = Expression.Parameter(typeof(BinaryReader));
            var builder         = Expression.Constant(this);

            if (string.IsNullOrEmpty(TypeTag))
            {
                return(Expression.Call(builder, "Generate", null));
            }
            else
            {
                var parseMessage  = MessageParser.Content(TypeTag, readerParameter);
                var messageParser = Expression.Lambda(parseMessage, readerParameter);
                return(Expression.Call(builder, "Generate", new[] { messageParser.ReturnType }, messageParser));
            }
        }