This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var boolli = new Evaluator(); | |
string booleanExpression = "not 1 and 0 or (true and false)"; | |
bool result = boolli.EvaluateBooleanExpression(booleanExpression); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var boolli = new Evaluator(); | |
string booleanExpression = "not true and false or (true and false)"; | |
bool result = boolli.EvaluateBooleanExpression(booleanExpression); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expr: factor((and | or) factor)* | |
factor: (not)* factor | boolean | LPAR expr RPAR | |
boolean: true | false | 0 | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsProcessRunning(string processPath) | |
{ | |
var runningProcessByName = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(processPath)); | |
return runningProcessByName.Length > 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"PathToApplicationToMonitor": "C:\\Program Files (x86)\\AnApplicationThatMayCrash.exe", | |
"CheckInterval": "00:00:10", | |
"StartApplicationOnlyAfterFirstExecution": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var boolli = new Evaluator(); | |
bool result = boolli.EvaluateFuncOfBoolExpression( | |
"f1 and f2", | |
new NamedBooleanFunction[] | |
{ | |
new NamedBooleanFunction("f1", () => true), | |
new NamedBooleanFunction("f2", () => false), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var boolli = new Evaluator(); | |
string booleanExpression = "not 1 and 0 or (true and false)"; | |
bool result = boolli.EvaluateBooleanExpression(booleanExpression); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var boolli = new Evaluator(); | |
string booleanExpression = "not true and false or (true and false)"; | |
bool result = boolli.EvaluateBooleanExpression(booleanExpression); |