Skip to content

Instantly share code, notes, and snippets.

View FrancescoBonizzi's full-sized avatar
🛰️
May the source be with you... ✨

Francesco Bonizzi FrancescoBonizzi

🛰️
May the source be with you... ✨
View GitHub Profile
var boolli = new Evaluator();
string booleanExpression = "not 1 and 0 or (true and false)";
bool result = boolli.EvaluateBooleanExpression(booleanExpression);
var boolli = new Evaluator();
string booleanExpression = "not true and false or (true and false)";
bool result = boolli.EvaluateBooleanExpression(booleanExpression);
expr: factor((and | or) factor)*
factor: (not)* factor | boolean | LPAR expr RPAR
boolean: true | false | 0 | 1
while (true)
{
if (!ProcessUtilities.IsProcessRunning(configuration.PathToApplicationToMonitor))
{
logger.LogInformation("Process restarting...");
var processInfo = new ProcessStartInfo(configuration.PathToApplicationToMonitor)
{
// This is very important as if the restarted application searches for assets
// in relative folder, it couldn't find them
WorkingDirectory = Path.GetDirectoryName(configuration.PathToApplicationToMonitor)
public static bool IsProcessRunning(string processPath)
{
var runningProcessByName = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(processPath));
return runningProcessByName.Length > 0;
}
{
"PathToApplicationToMonitor": "C:\\Program Files (x86)\\AnApplicationThatMayCrash.exe",
"CheckInterval": "00:00:10",
"StartApplicationOnlyAfterFirstExecution": true
}
var boolli = new Evaluator();
bool result = await boolli.EvaluateFuncOfBoolExpressionAsync(
"f3 and f4",
new NamedAsyncBooleanFunction[]
{
new NamedAsyncBooleanFunction(
"f3",
async () => { await Task.Delay(100); return true; }),
new NamedAsyncBooleanFunction(
"f4",
var boolli = new Evaluator();
bool result = boolli.EvaluateFuncOfBoolExpression(
"f1 and f2",
new NamedBooleanFunction[]
{
new NamedBooleanFunction("f1", () => true),
new NamedBooleanFunction("f2", () => false),
});
var boolli = new Evaluator();
string booleanExpression = "not 1 and 0 or (true and false)";
bool result = boolli.EvaluateBooleanExpression(booleanExpression);
var boolli = new Evaluator();
string booleanExpression = "not true and false or (true and false)";
bool result = boolli.EvaluateBooleanExpression(booleanExpression);