Tag Archives | .Net Framework

Building Expression Evaluator with Expression Trees in C# – Improving the Api

This post is part of a series about building a simple mathematical expression evaluator. For previous posts and full source code see Table of Contents.

Introduction

In previous part we added support for variables but it has a big disadvantage: values of the variables are bound by position and not by name. This means that you should pass values for the variables in the same order as they appear in the expression. For example the following test will fail: Continue Reading →

3
Spread the word...Tweet about this on TwitterShare on Google+Share on RedditShare on FacebookEmail this to someone

Using Reactive Extensions for Streaming Data from Database

You have probably heard about Reactive Extensions, a library from Microsoft that greatly simplifies working with asynchronous data streams and allows to query them with Linq operators. There are many different scenarios where using rx results in a much more simple and flexible code. This post demonstrates how to use reactive extensions for loading data from database asynchronously in chunks. Continue Reading →

17
Spread the word...Tweet about this on TwitterShare on Google+Share on RedditShare on FacebookEmail this to someone

Building Expression Evaluator with Expression Trees in C# – Table of Contents

This is table of contents for Building Expression Evaluator with Expression Trees in C# series. We are going to build a simple mathematical expression evaluator in C# using expression trees. The library supports simple expressions such as 2.5+5.9, 17.89-2.47+7.16, 5/2/2+1.5*3+4.58, expressions with parentheses (((9-6/2)*2-4)/2-6-1)/(2+24/(2+4)) and expressions with variables:

var a = 6;
var b = 4.32m;
var c = 24.15m;
Assert.That(engine.Evaluate("(((9-a/2)*2-b)/2-a-1)/(2+c/(2+4))", a, b, c), 
            Is.EqualTo((((9 - a / 2) * 2 - b) / 2 - a - 1) / (2 + c / (2 + 4))));

At the end of the series full source code will be available at github and the library will be published to NuGet.

Source code is available at github: Math-Expression-Evaluator

Table of Contents

  1. Building Expression Evaluator with Expression Trees in C# – A basic implementation.
  2. Building Expression Evaluator with Expression Trees in C# – Adding support for parentheses.
  3. Building Expression Evaluator with Expression Trees in C# – Adding support for variables.
  4. Building Expression Evaluator with Expression Trees in C# – Improving the Api
2
Spread the word...Tweet about this on TwitterShare on Google+Share on RedditShare on FacebookEmail this to someone

Bugs in System.Diagnostics.Process Class

While working on an application which makes use of Process class I found several bugs which occur in special conditions. More specifically accessing StartTime or HasExited properties causes a Win32Exception with NativeErrorCode equal to five. This indicates that the exception is caused by not having enough rights to retrieve the required information.

The exception occurs under the following conditions: Continue Reading →

2
Spread the word...Tweet about this on TwitterShare on Google+Share on RedditShare on FacebookEmail this to someone