public Expression Build(IEventTraceOperand operand, ParameterExpression eventRecordReader, ParameterExpression eventRecordWriter, ParameterExpression eventMetadataTable, ParameterExpression runtimeMetadata)
        {
            var eventMetadata = Expression.Parameter(typeof(EventMetadata));
            var properties    = Expression.Parameter(typeof(PropertyMetadata[]));

            var variables = new List <ParameterExpression>
            {
                eventMetadata,
                properties
            };

            var expGenerator = new ExpressionGenerator(eventRecordReader, eventRecordWriter, properties);
            var list         = new List <Expression>
            {
                Expression.Assign(eventMetadata, Expression.ArrayAccess(eventMetadataTable, Expression.Constant(operand.EventMetadataTableIndex))),
                Expression.Assign(properties, Expression.PropertyOrField(eventMetadata, "Properties")),
                eventRecordWriter.Call("WriteEventBegin", eventMetadata, runtimeMetadata),
                expGenerator.CodeGenerate(operand.EventPropertyOperands),
                eventRecordWriter.Call("WriteEventEnd")
            };

            var returnExpression = Expression.Block(variables, list);

            return(returnExpression);
        }
        public Expression Build(IEventTraceOperand operand, ParameterExpression eventRecordReader, ParameterExpression eventRecordWriter, ParameterExpression eventMetadataTable, ParameterExpression runtimeMetadata)
        {
            var eventMetadata = Expression.Parameter(typeof(EventMetadata));
            var properties = Expression.Parameter(typeof(PropertyMetadata[]));

            var variables = new List<ParameterExpression>
            {
                eventMetadata,
                properties
            };

            var expGenerator = new ExpressionGenerator(eventRecordReader, eventRecordWriter, properties);
            var list = new List<Expression>
            {
                Expression.Assign(eventMetadata, Expression.ArrayAccess(eventMetadataTable, Expression.Constant(operand.EventMetadataTableIndex))),
                Expression.Assign(properties, Expression.PropertyOrField(eventMetadata, "Properties")),
                eventRecordWriter.Call("WriteEventBegin", eventMetadata, runtimeMetadata),
                expGenerator.CodeGenerate(operand.EventPropertyOperands),
                eventRecordWriter.Call("WriteEventEnd")
            };

            var returnExpression = Expression.Block(variables, list);
            return returnExpression;
        }