diff --git a/ExpressionEvaluator.sln b/ExpressionEvaluator.sln index 92b4760..e683db1 100644 --- a/ExpressionEvaluator.sln +++ b/ExpressionEvaluator.sln @@ -1,11 +1,15 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30011.22 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32421.90 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionEvaluator", "ExpressionEvaluator\ExpressionEvaluator.csproj", "{8CE7CD5B-C847-4CC3-B173-D85B74D356C9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExpressionEvaluatorTests", "ExpressionEvaluatorTests\ExpressionEvaluatorTests.csproj", "{F10EECC5-380C-4A7C-8345-EE49F44C7C3D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionEvaluatorTests", "ExpressionEvaluatorTests\ExpressionEvaluatorTests.csproj", "{F10EECC5-380C-4A7C-8345-EE49F44C7C3D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionEvaluatorUI", "ExpressionEvaluatorUi\ExpressionEvaluatorUI.csproj", "{77C9678B-6B41-445A-B032-CB8E59046A7B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionEvaluatorDemo", "ExpressionEvaluatorDemo\ExpressionEvaluatorDemo.csproj", "{65C7882E-0F2B-458C-BE8E-1BA75E9F166F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +25,14 @@ Global {F10EECC5-380C-4A7C-8345-EE49F44C7C3D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F10EECC5-380C-4A7C-8345-EE49F44C7C3D}.Release|Any CPU.ActiveCfg = Release|Any CPU {F10EECC5-380C-4A7C-8345-EE49F44C7C3D}.Release|Any CPU.Build.0 = Release|Any CPU + {77C9678B-6B41-445A-B032-CB8E59046A7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {77C9678B-6B41-445A-B032-CB8E59046A7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {77C9678B-6B41-445A-B032-CB8E59046A7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {77C9678B-6B41-445A-B032-CB8E59046A7B}.Release|Any CPU.Build.0 = Release|Any CPU + {65C7882E-0F2B-458C-BE8E-1BA75E9F166F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {65C7882E-0F2B-458C-BE8E-1BA75E9F166F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {65C7882E-0F2B-458C-BE8E-1BA75E9F166F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {65C7882E-0F2B-458C-BE8E-1BA75E9F166F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ExpressionEvaluator/Expression.cs b/ExpressionEvaluator/Expression.cs index 4a725c4..2f5581c 100644 --- a/ExpressionEvaluator/Expression.cs +++ b/ExpressionEvaluator/Expression.cs @@ -7,6 +7,8 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +using System.Reflection; +using System.Runtime.Serialization; using System.Text; namespace Vanderbilt.Biostatistics.Wfccm2 @@ -126,6 +128,7 @@ public void AddSetVariable(string name, DateTime val) public void AddSetVariable(string name, bool val) { AddSetVariable(name, val); } public void AddSetVariable(string name, string val) { AddSetVariable(name, val); } + /// /// Clears all information. @@ -442,7 +445,7 @@ private IOperand Evaluate() if (op.Name == "if" || op.Name == "elseif" || op.Name == "else") { - switch (op.Name) { + switch (op.Name) { case "elseif": if (currentConditionalDepth > 0) { // Eat the result. diff --git a/ExpressionEvaluator/Keywords/Procedure.cs b/ExpressionEvaluator/Keywords/Procedure.cs index 95272e8..637b089 100644 --- a/ExpressionEvaluator/Keywords/Procedure.cs +++ b/ExpressionEvaluator/Keywords/Procedure.cs @@ -59,6 +59,9 @@ public Procedure(string name, int precedance, int numParams, bool alwaysReturnsV public bool AlwaysReturnsValue { get; private set; } public int NumParameters { get; set; } public bool VariableOperandsCount { get; private set; } + public string Category { get; set; } + public string Description { get; set; } + public IOperand Evaluate() { diff --git a/ExpressionEvaluator/Procedures/Functions/Absolute.cs b/ExpressionEvaluator/Procedures/Functions/Absolute.cs index 38c458c..67790f1 100644 --- a/ExpressionEvaluator/Procedures/Functions/Absolute.cs +++ b/ExpressionEvaluator/Procedures/Functions/Absolute.cs @@ -10,6 +10,8 @@ public Absolute(int precedance) : base("abs", precedance, 1, false) { _name2 = "Absolute"; + Category = "Mathematical Function"; + Description = "Returns the absolute value of a specified number."; DecimalDecimal = x => { double dblResult = Math.Abs((double)x); if (double.IsNaN(dblResult)) { diff --git a/ExpressionEvaluator/Procedures/Functions/Avg.cs b/ExpressionEvaluator/Procedures/Functions/Avg.cs index 7b0bb2c..8413e39 100644 --- a/ExpressionEvaluator/Procedures/Functions/Avg.cs +++ b/ExpressionEvaluator/Procedures/Functions/Avg.cs @@ -9,6 +9,8 @@ public Avg(int precedance) : base("avg", precedance, 1, true) { _name2 = "Avg"; + Category = "Mathematical Function"; + Description = "Calculates the average of the values."; DecimalDecimalOperandList = x => x.Average(); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Ceiling.cs b/ExpressionEvaluator/Procedures/Functions/Ceiling.cs index 45b805a..25661f8 100644 --- a/ExpressionEvaluator/Procedures/Functions/Ceiling.cs +++ b/ExpressionEvaluator/Procedures/Functions/Ceiling.cs @@ -9,6 +9,8 @@ public Ceiling(int precedance) : base("ceiling", precedance, 2, true) { _name2 = "Ceiling"; + Category = "Mathematical Function"; + Description = "Return the smallest integral value greater than or equal to the specified number"; DecimalDecimalOperandList = x => { if (x.Count > 2) throw new ExpressionException("Ceiling only takes one or two paramters."); diff --git a/ExpressionEvaluator/Procedures/Functions/Concatenate.cs b/ExpressionEvaluator/Procedures/Functions/Concatenate.cs index 08ab153..7f447ec 100644 --- a/ExpressionEvaluator/Procedures/Functions/Concatenate.cs +++ b/ExpressionEvaluator/Procedures/Functions/Concatenate.cs @@ -9,6 +9,8 @@ public Concatenate(int precedance) : base("concatenate", precedance, 1, true) { _name2 = "Concatenate"; + Category = "String"; + Description = "Appends one string to the end of another string."; ObjectStringOperandList = x => x.Aggregate("", (current, i) => current + i); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Contains.cs b/ExpressionEvaluator/Procedures/Functions/Contains.cs index 931a233..b53dd85 100644 --- a/ExpressionEvaluator/Procedures/Functions/Contains.cs +++ b/ExpressionEvaluator/Procedures/Functions/Contains.cs @@ -8,6 +8,8 @@ public Contains(int precedance) : base("contains", precedance, 2, false) { _name2 = "Contains"; + Category = "String"; + Description = "Checks if the string contains the given substring."; StringStringBool = (x, y) => x.ToLower() .Contains(y.ToLower()); } diff --git a/ExpressionEvaluator/Procedures/Functions/Days.cs b/ExpressionEvaluator/Procedures/Functions/Days.cs index 8ab01a0..e627aa5 100644 --- a/ExpressionEvaluator/Procedures/Functions/Days.cs +++ b/ExpressionEvaluator/Procedures/Functions/Days.cs @@ -9,6 +9,8 @@ public Days(int precedance) : base("days", precedance, 1, false) { _name2 = "Days"; + Category = "Date/Time"; + Description = "Given the days as input, returns the days in DD:HH:MM:SS format."; DecimalTimespan = x => new TimeSpan((long)(x * TimeSpan.TicksPerDay)); } } diff --git a/ExpressionEvaluator/Procedures/Functions/DaysComponent.cs b/ExpressionEvaluator/Procedures/Functions/DaysComponent.cs index 4b900dc..85eadf3 100644 --- a/ExpressionEvaluator/Procedures/Functions/DaysComponent.cs +++ b/ExpressionEvaluator/Procedures/Functions/DaysComponent.cs @@ -8,6 +8,8 @@ public DaysComponent(int precedance) : base("dayscomponent", precedance, 1, false) { _name2 = "DaysComponent"; + Category = "Date/Time"; + Description = "Returns the no. of days between two given dates"; TimespanDecimal = x => (decimal)x.Days; } } diff --git a/ExpressionEvaluator/Procedures/Functions/Floor.cs b/ExpressionEvaluator/Procedures/Functions/Floor.cs index 9a9c636..52d26d0 100644 --- a/ExpressionEvaluator/Procedures/Functions/Floor.cs +++ b/ExpressionEvaluator/Procedures/Functions/Floor.cs @@ -9,6 +9,8 @@ public Floor(int precedance) : base("floor", precedance, 2, true) { _name2 = "Floor"; + Category = "Mathematical Function"; + Description = "Return the largest integer, which is less than or equal to the passed argument"; DecimalDecimalOperandList = x => { if (x.Count > 2) throw new ExpressionException("Floor only takes one or two paramters."); diff --git a/ExpressionEvaluator/Procedures/Functions/Hours.cs b/ExpressionEvaluator/Procedures/Functions/Hours.cs index 896c5fd..250f46a 100644 --- a/ExpressionEvaluator/Procedures/Functions/Hours.cs +++ b/ExpressionEvaluator/Procedures/Functions/Hours.cs @@ -9,6 +9,8 @@ public Hours(int precedance) : base("hours", precedance, 1, false) { _name2 = "Hours"; + Category = "Date/Time"; + Description = "Given the hours as input, returns the hours in DD:HH:MM:SS format."; DecimalTimespan = x => new TimeSpan((long)(x * TimeSpan.TicksPerHour)); } } diff --git a/ExpressionEvaluator/Procedures/Functions/HoursComponent.cs b/ExpressionEvaluator/Procedures/Functions/HoursComponent.cs index e7dfc8b..3a3bba6 100644 --- a/ExpressionEvaluator/Procedures/Functions/HoursComponent.cs +++ b/ExpressionEvaluator/Procedures/Functions/HoursComponent.cs @@ -8,6 +8,8 @@ public HoursComponent(int precedance) : base("hourscomponent", precedance, 1, false) { _name2 = "HoursComponent"; + Category = "Date/Time"; + Description = "Returns the no. of hours between two given times."; TimespanDecimal = x => (decimal)x.Hours; } } diff --git a/ExpressionEvaluator/Procedures/Functions/IsNumber.cs b/ExpressionEvaluator/Procedures/Functions/IsNumber.cs index fc60f59..f98cfb0 100644 --- a/ExpressionEvaluator/Procedures/Functions/IsNumber.cs +++ b/ExpressionEvaluator/Procedures/Functions/IsNumber.cs @@ -9,6 +9,8 @@ public IsNumber(int precedance) : base("isnumber", precedance, 1, false) { _name2 = "IsNumber"; + Category = "Mathematical Function"; + Description = "Checks if the given argument is a number or not."; AnyBool = x => x != null && StringBool(x.ToString()); StringBool = x => { try { diff --git a/ExpressionEvaluator/Procedures/Functions/Length.cs b/ExpressionEvaluator/Procedures/Functions/Length.cs index 6fba5aa..df96433 100644 --- a/ExpressionEvaluator/Procedures/Functions/Length.cs +++ b/ExpressionEvaluator/Procedures/Functions/Length.cs @@ -8,6 +8,8 @@ public Length(int precedance) : base("length", precedance, 1, false) { _name2 = "Length"; + Category = "String"; + Description = "Returns the length of given string."; StringDecimal = x => x.Length; } } diff --git a/ExpressionEvaluator/Procedures/Functions/Max.cs b/ExpressionEvaluator/Procedures/Functions/Max.cs index 2236502..1955ffc 100644 --- a/ExpressionEvaluator/Procedures/Functions/Max.cs +++ b/ExpressionEvaluator/Procedures/Functions/Max.cs @@ -9,6 +9,8 @@ public Max(int precedance) : base("max", precedance, 1, true) { _name2 = "Max"; + Category = "Mathematical Function"; + Description = "Returns the larger of the specified numbers."; DecimalDecimalOperandList = x => x.Max(); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Min.cs b/ExpressionEvaluator/Procedures/Functions/Min.cs index 50a07e4..d8cf42b 100644 --- a/ExpressionEvaluator/Procedures/Functions/Min.cs +++ b/ExpressionEvaluator/Procedures/Functions/Min.cs @@ -9,6 +9,8 @@ public Min(int precedance) : base("min", precedance, 1, true) { _name2 = "Min"; + Category = "Mathematical Function"; + Description = "Returns the minimum of the specified numbers."; DecimalDecimalOperandList = x => x.Min(); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Minutes.cs b/ExpressionEvaluator/Procedures/Functions/Minutes.cs index 8d667dc..bca3235 100644 --- a/ExpressionEvaluator/Procedures/Functions/Minutes.cs +++ b/ExpressionEvaluator/Procedures/Functions/Minutes.cs @@ -9,6 +9,8 @@ public Minutes(int precedance) : base("minutes", precedance, 1, false) { _name2 = "Minutes"; + Category = "Date/Time"; + Description = "Given the minutes as input, returns the minutes in DD:HH:MM:SS format."; DecimalTimespan = x => new TimeSpan((long)(x * TimeSpan.TicksPerMinute)); } } diff --git a/ExpressionEvaluator/Procedures/Functions/MinutesComponent.cs b/ExpressionEvaluator/Procedures/Functions/MinutesComponent.cs index 22d58c7..865d0c4 100644 --- a/ExpressionEvaluator/Procedures/Functions/MinutesComponent.cs +++ b/ExpressionEvaluator/Procedures/Functions/MinutesComponent.cs @@ -8,6 +8,8 @@ public MinutesComponent(int precedance) : base("minutescomponent", precedance, 1, false) { _name2 = "MinutesComponent"; + Category = "Date/Time"; + Description = "Returns the no. of minutes between two given times."; TimespanDecimal = x => (decimal)x.Minutes; } } diff --git a/ExpressionEvaluator/Procedures/Functions/NaturalLog.cs b/ExpressionEvaluator/Procedures/Functions/NaturalLog.cs index a94e741..fa3a235 100644 --- a/ExpressionEvaluator/Procedures/Functions/NaturalLog.cs +++ b/ExpressionEvaluator/Procedures/Functions/NaturalLog.cs @@ -10,6 +10,8 @@ public NaturalLog(int precedance) : base("ln", precedance, 1, false) { _name2 = "NaturalLog"; + Category = "Mathematical Function"; + Description = "Returns the natural (base e) logarithm of a specified number."; DecimalDecimal = x => { double dblResult = Math.Log((double)x); if (double.IsNaN(dblResult)) { diff --git a/ExpressionEvaluator/Procedures/Functions/Negate.cs b/ExpressionEvaluator/Procedures/Functions/Negate.cs index 4ae266f..07303dc 100644 --- a/ExpressionEvaluator/Procedures/Functions/Negate.cs +++ b/ExpressionEvaluator/Procedures/Functions/Negate.cs @@ -8,6 +8,8 @@ public Negate(int precedance) : base("neg", precedance, 1, false) { _name2 = "Negate"; + Category = "Mathematical Function"; + Description = "Returns the result of multiplying the specified value by negative one."; DecimalDecimal = x => -1 * x; } } diff --git a/ExpressionEvaluator/Procedures/Functions/Now.cs b/ExpressionEvaluator/Procedures/Functions/Now.cs index 67c7479..07bd7a5 100644 --- a/ExpressionEvaluator/Procedures/Functions/Now.cs +++ b/ExpressionEvaluator/Procedures/Functions/Now.cs @@ -9,6 +9,8 @@ public Now(int precedance) : base("now", precedance, 0, false) { _name2 = "Now"; + Category = "Date/Time"; + Description = "Gets the current Date and Time."; Datetime = () => DateTime.Now; } } diff --git a/ExpressionEvaluator/Procedures/Functions/Round.cs b/ExpressionEvaluator/Procedures/Functions/Round.cs index 88290b0..360adcc 100644 --- a/ExpressionEvaluator/Procedures/Functions/Round.cs +++ b/ExpressionEvaluator/Procedures/Functions/Round.cs @@ -9,6 +9,8 @@ public Round(int precedance) : base("round", precedance, 2, false) { _name2 = "Round"; + Category = "Mathematical Function"; + Description = "Rounds the number to a specified number of digits"; DecimalDecimalDecimal = (x, y) => Math.Round(x, (int)y, MidpointRounding.AwayFromZero); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Seconds.cs b/ExpressionEvaluator/Procedures/Functions/Seconds.cs index 226be6e..8742ce8 100644 --- a/ExpressionEvaluator/Procedures/Functions/Seconds.cs +++ b/ExpressionEvaluator/Procedures/Functions/Seconds.cs @@ -9,6 +9,8 @@ public Seconds(int precedance) : base("seconds", precedance, 1, false) { _name2 = "Seconds"; + Category = "Date/Time"; + Description = "Given the seconds as input, returns the seconds in DD:HH:MM:SS format."; DecimalTimespan = x => new TimeSpan((long)(x * TimeSpan.TicksPerSecond)); } } diff --git a/ExpressionEvaluator/Procedures/Functions/SecondsComponent.cs b/ExpressionEvaluator/Procedures/Functions/SecondsComponent.cs index f343dfd..38bbaca 100644 --- a/ExpressionEvaluator/Procedures/Functions/SecondsComponent.cs +++ b/ExpressionEvaluator/Procedures/Functions/SecondsComponent.cs @@ -8,6 +8,8 @@ public SecondsComponent(int precedance) : base("secondscomponent", precedance, 1, false) { _name2 = "SecondsComponent"; + Category = "Date/Time"; + Description = "Returns the no. of seconds between two given times."; TimespanDecimal = x => (decimal)x.Seconds; } } diff --git a/ExpressionEvaluator/Procedures/Functions/Sign.cs b/ExpressionEvaluator/Procedures/Functions/Sign.cs index 3b40407..ddbd158 100644 --- a/ExpressionEvaluator/Procedures/Functions/Sign.cs +++ b/ExpressionEvaluator/Procedures/Functions/Sign.cs @@ -8,6 +8,8 @@ public Sign(int precedance) : base("sign", precedance, 1, false) { _name2 = "Sign"; + Category = "Mathematical Function"; + Description = "Returns an integer that specifes the sign of the numbery."; DecimalDecimal = x => x >= 0 ? 1 : -1; } } diff --git a/ExpressionEvaluator/Procedures/Functions/StdDev.cs b/ExpressionEvaluator/Procedures/Functions/StdDev.cs index e6f759f..1708aca 100644 --- a/ExpressionEvaluator/Procedures/Functions/StdDev.cs +++ b/ExpressionEvaluator/Procedures/Functions/StdDev.cs @@ -10,6 +10,8 @@ public StdDev(int precedance) : base("stddev", precedance, 1, true) { _name2 = "StdDev"; + Category = "Mathematical Function"; + Description = "Returns the standard deviation of the given numbers"; DecimalDecimalOperandList = x => { var avg = (double)x.Average(); return (decimal)Math.Sqrt(x.Average(v => Math.Pow((double)v - avg, 2))); diff --git a/ExpressionEvaluator/Procedures/Functions/Substring.cs b/ExpressionEvaluator/Procedures/Functions/Substring.cs index d4dc5e3..e5e59f9 100644 --- a/ExpressionEvaluator/Procedures/Functions/Substring.cs +++ b/ExpressionEvaluator/Procedures/Functions/Substring.cs @@ -8,6 +8,8 @@ public Substring(int precedance) : base("substring", precedance, 3, false) { _name2 = "Substring"; + Category = "String"; + Description = "Extracts the substring of the string with the specified start and end position."; StringDecimalDecimalString = (x, y, z) => x.Substring((int)y, (int)z); } } diff --git a/ExpressionEvaluator/Procedures/Functions/Sum.cs b/ExpressionEvaluator/Procedures/Functions/Sum.cs index ef4c5f8..4adb880 100644 --- a/ExpressionEvaluator/Procedures/Functions/Sum.cs +++ b/ExpressionEvaluator/Procedures/Functions/Sum.cs @@ -8,6 +8,8 @@ public Sum(int precedance) : base("sum", precedance, 1, true) { _name2 = "Sum"; + Category = "Mathematical Function"; + Description = "Returns the sum of the given numbers."; DecimalDecimalOperandList = x => { decimal sum = 0; foreach (var i in x) { diff --git a/ExpressionEvaluator/Procedures/Functions/ToNumber.cs b/ExpressionEvaluator/Procedures/Functions/ToNumber.cs index 52061bb..9ef271b 100644 --- a/ExpressionEvaluator/Procedures/Functions/ToNumber.cs +++ b/ExpressionEvaluator/Procedures/Functions/ToNumber.cs @@ -9,6 +9,8 @@ public ToNumber(int precedance) : base("tonumber", precedance, 1, false) { _name2 = "ToNumber"; + Category = "String"; + Description = "Returns the number equivalent of the given string."; StringDecimal = x => { try { return decimal.Parse(x); diff --git a/ExpressionEvaluator/Procedures/Functions/ToString.cs b/ExpressionEvaluator/Procedures/Functions/ToString.cs index d315488..ba55887 100644 --- a/ExpressionEvaluator/Procedures/Functions/ToString.cs +++ b/ExpressionEvaluator/Procedures/Functions/ToString.cs @@ -8,6 +8,8 @@ public ToString(int precedance) : base("tostring", precedance, 1, false) { _name2 = "ToString"; + Category = "String"; + Description = "Returns the string equivalent of the given number."; DecimalString = x => x.ToString(); DateTimeString = x => x.ToString(); BoolString = x => x.ToString(); diff --git a/ExpressionEvaluator/Procedures/Functions/ToStringFormat.cs b/ExpressionEvaluator/Procedures/Functions/ToStringFormat.cs index 5246d00..d8e7bfa 100644 --- a/ExpressionEvaluator/Procedures/Functions/ToStringFormat.cs +++ b/ExpressionEvaluator/Procedures/Functions/ToStringFormat.cs @@ -8,6 +8,8 @@ public ToStringFormat(int precedance) : base("tostringformat", precedance, 2, false) { _name2 = "ToStringFormat"; + Category = "String"; + Description = "Adds leading or trailing zeros to a no. and returns the string equivalent."; DecimalStringString = (x, y) => x.ToString(y); } } diff --git a/ExpressionEvaluator/Procedures/Functions/TotalDays.cs b/ExpressionEvaluator/Procedures/Functions/TotalDays.cs index dceec40..6a6f870 100644 --- a/ExpressionEvaluator/Procedures/Functions/TotalDays.cs +++ b/ExpressionEvaluator/Procedures/Functions/TotalDays.cs @@ -8,6 +8,8 @@ public TotalDays(int precedance) : base("totaldays", precedance, 1, false) { _name2 = "TotalDays"; + Category = "Date/Time"; + Description = "Returns the total no. of days between two given timestamps."; TimespanDecimal = x => (decimal)x.TotalDays; } } diff --git a/ExpressionEvaluator/Procedures/Functions/TotalHours.cs b/ExpressionEvaluator/Procedures/Functions/TotalHours.cs index e95a00d..e58d1a1 100644 --- a/ExpressionEvaluator/Procedures/Functions/TotalHours.cs +++ b/ExpressionEvaluator/Procedures/Functions/TotalHours.cs @@ -8,6 +8,8 @@ public TotalHours(int precedance) : base("totalhours", precedance, 1, false) { _name2 = "TotalHours"; + Category = "Date/Time"; + Description = "Returns the total no. of hours between two given timestamps."; TimespanDecimal = x => (decimal)x.TotalHours; } } diff --git a/ExpressionEvaluator/Procedures/Functions/TotalMinutes.cs b/ExpressionEvaluator/Procedures/Functions/TotalMinutes.cs index 960f4b4..28bd4a4 100644 --- a/ExpressionEvaluator/Procedures/Functions/TotalMinutes.cs +++ b/ExpressionEvaluator/Procedures/Functions/TotalMinutes.cs @@ -8,6 +8,8 @@ public TotalMinutes(int precedance) : base("totalminutes", precedance, 1, false) { _name2 = "TotalMinutes"; + Category = "Date/Time"; + Description = "Returns the total no. of minutes between two given timestamps."; TimespanDecimal = x => (decimal)x.TotalMinutes; } } diff --git a/ExpressionEvaluator/Procedures/Functions/TotalSeconds.cs b/ExpressionEvaluator/Procedures/Functions/TotalSeconds.cs index 6908019..43aac80 100644 --- a/ExpressionEvaluator/Procedures/Functions/TotalSeconds.cs +++ b/ExpressionEvaluator/Procedures/Functions/TotalSeconds.cs @@ -8,6 +8,8 @@ public TotalSeconds(int precedance) : base("totalseconds", precedance, 1, false) { _name2 = "TotalSeconds"; + Category = "Date/Time"; + Description = "Returns the total no. of seconds between two given timestamps."; TimespanDecimal = x => (decimal)x.TotalSeconds; } } diff --git a/ExpressionEvaluator/Procedures/Operators/Addition.cs b/ExpressionEvaluator/Procedures/Operators/Addition.cs index a3749ba..a5926bc 100644 --- a/ExpressionEvaluator/Procedures/Operators/Addition.cs +++ b/ExpressionEvaluator/Procedures/Operators/Addition.cs @@ -9,6 +9,8 @@ public Addition(int precedance) : base("+", precedance, 2, false) { _name2 = "Addition"; + Category = "Arithmetic"; + Description = "Add two operands."; DecimalDecimalDecimal = (x, y) => x+y; DatetimeTimespanDatetime = (x, y) => x + y; TimespanDatetimeDatetime = (x, y) => y + x; @@ -17,5 +19,7 @@ public Addition(int precedance) DecimalStringString = (x, y) => x + y; StringDecimalString = (x, y) => x + y; } + + } } diff --git a/ExpressionEvaluator/Procedures/Operators/And.cs b/ExpressionEvaluator/Procedures/Operators/And.cs index 00218c0..4e40c4e 100644 --- a/ExpressionEvaluator/Procedures/Operators/And.cs +++ b/ExpressionEvaluator/Procedures/Operators/And.cs @@ -8,6 +8,8 @@ public And(int precedance) : base("&&", precedance, 2, false) { _name2 = "And"; + Category = "Logical"; + Description = "Check if both the operands are true."; BoolBoolBool = (x, y) => x && y; } } diff --git a/ExpressionEvaluator/Procedures/Operators/Division.cs b/ExpressionEvaluator/Procedures/Operators/Division.cs index 86144fc..5cdee1f 100644 --- a/ExpressionEvaluator/Procedures/Operators/Division.cs +++ b/ExpressionEvaluator/Procedures/Operators/Division.cs @@ -10,6 +10,8 @@ public Division(int precedance) : base("/", precedance, 2, false) { _name2 = "Division"; + Category = "Arithmetic"; + Description = "Divide two operands and gives the quotient as the answer."; DecimalDecimalDecimal = (x, y) => { if (y == 0) { throw new DivideByZeroException(); diff --git a/ExpressionEvaluator/Procedures/Operators/Equal.cs b/ExpressionEvaluator/Procedures/Operators/Equal.cs index 89ff933..29a1061 100644 --- a/ExpressionEvaluator/Procedures/Operators/Equal.cs +++ b/ExpressionEvaluator/Procedures/Operators/Equal.cs @@ -8,6 +8,8 @@ public Equal(int precedance) : base("==", precedance, 2, false) { _name2 = "Equal"; + Category = "Relational"; + Description = "Check if both operands are equal."; DecimalDecimalBool = (x, y) => x == y; BoolBoolBool = (x, y) => x == y; StringStringBool = (x, y) => x.ToLower() == y.ToLower(); diff --git a/ExpressionEvaluator/Procedures/Operators/GreaterEqual.cs b/ExpressionEvaluator/Procedures/Operators/GreaterEqual.cs index 2ed5763..dec1d38 100644 --- a/ExpressionEvaluator/Procedures/Operators/GreaterEqual.cs +++ b/ExpressionEvaluator/Procedures/Operators/GreaterEqual.cs @@ -8,6 +8,8 @@ public GreaterEqual(int precedance) : base(">=", precedance, 2, false) { _name2 = "GreaterEqual"; + Category = "Relational"; + Description = "Check if the first operand is greater than or equal to the second."; DecimalDecimalBool = (x, y) => x >= y; TimespanTimespanBool = (x, y) => x >= y; DatetimeDatetimeBool = (x, y) => x >= y; diff --git a/ExpressionEvaluator/Procedures/Operators/GreaterThan.cs b/ExpressionEvaluator/Procedures/Operators/GreaterThan.cs index f13d007..6ef3a82 100644 --- a/ExpressionEvaluator/Procedures/Operators/GreaterThan.cs +++ b/ExpressionEvaluator/Procedures/Operators/GreaterThan.cs @@ -8,6 +8,8 @@ public GreaterThan(int precedance) : base(">", precedance, 2, false) { _name2 = "GreaterThan"; + Category = "Relational"; + Description = "Check if the first operand is greater than the second."; DecimalDecimalBool = (x, y) => x > y; TimespanTimespanBool = (x, y) => x > y; DatetimeDatetimeBool = (x, y) => x > y; diff --git a/ExpressionEvaluator/Procedures/Operators/LesserEqual.cs b/ExpressionEvaluator/Procedures/Operators/LesserEqual.cs index 0443525..4ee0f74 100644 --- a/ExpressionEvaluator/Procedures/Operators/LesserEqual.cs +++ b/ExpressionEvaluator/Procedures/Operators/LesserEqual.cs @@ -8,6 +8,8 @@ public LesserEqual(int precedance) : base("<=", precedance, 2, false) { _name2 = "LesserEqual"; + Category = "Relational"; + Description = "Check if the first operand is lesser than or equal to the second."; DecimalDecimalBool = (x, y) => x <= y; TimespanTimespanBool = (x, y) => x <= y; DatetimeDatetimeBool = (x, y) => x <= y; diff --git a/ExpressionEvaluator/Procedures/Operators/LesserThan.cs b/ExpressionEvaluator/Procedures/Operators/LesserThan.cs index 9d4312a..6ad342b 100644 --- a/ExpressionEvaluator/Procedures/Operators/LesserThan.cs +++ b/ExpressionEvaluator/Procedures/Operators/LesserThan.cs @@ -8,6 +8,8 @@ public LesserThan(int precedance) : base("<", precedance, 2, false) { _name2 = "LessThan"; + Category = "Relational"; + Description = "Check if the first operand is lesser than the second."; DecimalDecimalBool = (x, y) => x < y; TimespanTimespanBool = (x, y) => x < y; DatetimeDatetimeBool = (x, y) => x < y; diff --git a/ExpressionEvaluator/Procedures/Operators/Modulo.cs b/ExpressionEvaluator/Procedures/Operators/Modulo.cs index 81b8425..31b45e6 100644 --- a/ExpressionEvaluator/Procedures/Operators/Modulo.cs +++ b/ExpressionEvaluator/Procedures/Operators/Modulo.cs @@ -8,6 +8,8 @@ public Modulo(int precedance) : base("%", precedance, 2, false) { _name2 = "Modulo"; + Category = "Arithmetic"; + Description = "Find the remains of two integers and gives the remainder after the division."; DecimalDecimalDecimal = (x, y) => x % y; } } diff --git a/ExpressionEvaluator/Procedures/Operators/Multiplication.cs b/ExpressionEvaluator/Procedures/Operators/Multiplication.cs index fb7e748..684d088 100644 --- a/ExpressionEvaluator/Procedures/Operators/Multiplication.cs +++ b/ExpressionEvaluator/Procedures/Operators/Multiplication.cs @@ -8,6 +8,8 @@ public Multiplication(int precedance) : base("*", precedance, 2, false) { _name2 = "Multiplication"; + Category = "Arithmetic"; + Description = "Multiply two operands."; DecimalDecimalDecimal = (x, y) =>x*y; } } diff --git a/ExpressionEvaluator/Procedures/Operators/NotEqual.cs b/ExpressionEvaluator/Procedures/Operators/NotEqual.cs index e5298ed..3f813b9 100644 --- a/ExpressionEvaluator/Procedures/Operators/NotEqual.cs +++ b/ExpressionEvaluator/Procedures/Operators/NotEqual.cs @@ -8,6 +8,8 @@ public NotEqual(int precedance) : base("!=", precedance, 2, false) { _name2 = "NotEqual"; + Category = "Relational"; + Description = "Check if both operands are not equal."; DecimalDecimalBool = (x, y) => x != y; BoolBoolBool = (x, y) => x != y; StringStringBool = (x, y) => x != y; diff --git a/ExpressionEvaluator/Procedures/Operators/Or.cs b/ExpressionEvaluator/Procedures/Operators/Or.cs index 3b9fb95..83e19ca 100644 --- a/ExpressionEvaluator/Procedures/Operators/Or.cs +++ b/ExpressionEvaluator/Procedures/Operators/Or.cs @@ -8,6 +8,8 @@ public Or(int precedance) : base("||", precedance, 2, false) { _name2 = "Or"; + Category = "Logical"; + Description = "Check if at least one of the operand is true."; BoolBoolBool = (x, y) => x || y; } } diff --git a/ExpressionEvaluator/Procedures/Operators/Power.cs b/ExpressionEvaluator/Procedures/Operators/Power.cs index 5217b7c..e4a1817 100644 --- a/ExpressionEvaluator/Procedures/Operators/Power.cs +++ b/ExpressionEvaluator/Procedures/Operators/Power.cs @@ -10,6 +10,8 @@ public Power(int precedance) : base("^", precedance, 2, false) { _name2 = "Power"; + Category = "Arithmetic"; + Description = "Raise the number on the left to the power of the exponent of the right."; DecimalDecimalDecimal = (x, y) => { double dblResult = Math.Pow((double)x, (double)y); if (double.IsNaN(dblResult)) { diff --git a/ExpressionEvaluator/Procedures/Operators/Subtraction.cs b/ExpressionEvaluator/Procedures/Operators/Subtraction.cs index a4ce044..4d5ccdc 100644 --- a/ExpressionEvaluator/Procedures/Operators/Subtraction.cs +++ b/ExpressionEvaluator/Procedures/Operators/Subtraction.cs @@ -8,6 +8,8 @@ public Subtraction(int precedance) : base("-", precedance, 2, false) { _name2 = "Subtraction"; + Category = "Arithmetic"; + Description = "Subtract two operands."; DecimalDecimalDecimal = (x, y) => x - y; TimespanTimespanTimespan = (x, y) => x - y; DatetimeTimespanDatetime = (x, y) => x - y; diff --git a/ExpressionEvaluatorDemo/App.xaml b/ExpressionEvaluatorDemo/App.xaml new file mode 100644 index 0000000..f072528 --- /dev/null +++ b/ExpressionEvaluatorDemo/App.xaml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/ExpressionEvaluatorDemo/App.xaml.cs b/ExpressionEvaluatorDemo/App.xaml.cs new file mode 100644 index 0000000..c75906c --- /dev/null +++ b/ExpressionEvaluatorDemo/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace ExpressionEvaluatorDemo +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/ExpressionEvaluatorDemo/AssemblyInfo.cs b/ExpressionEvaluatorDemo/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/ExpressionEvaluatorDemo/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/ExpressionEvaluatorDemo/ExpressionEvaluatorDemo.csproj b/ExpressionEvaluatorDemo/ExpressionEvaluatorDemo.csproj new file mode 100644 index 0000000..051b65f --- /dev/null +++ b/ExpressionEvaluatorDemo/ExpressionEvaluatorDemo.csproj @@ -0,0 +1,14 @@ + + + + WinExe + netcoreapp3.1 + true + + + + + + + + diff --git a/ExpressionEvaluatorDemo/MainWindow.xaml b/ExpressionEvaluatorDemo/MainWindow.xaml new file mode 100644 index 0000000..2bdb9a0 --- /dev/null +++ b/ExpressionEvaluatorDemo/MainWindow.xaml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/ExpressionEvaluatorDemo/MainWindow.xaml.cs b/ExpressionEvaluatorDemo/MainWindow.xaml.cs new file mode 100644 index 0000000..95d4c01 --- /dev/null +++ b/ExpressionEvaluatorDemo/MainWindow.xaml.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace ExpressionEvaluatorDemo +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/ExpressionEvaluatorTests/ConcatenateTests.cs b/ExpressionEvaluatorTests/ConcatenateTests.cs index 7656215..3332dd1 100644 --- a/ExpressionEvaluatorTests/ConcatenateTests.cs +++ b/ExpressionEvaluatorTests/ConcatenateTests.cs @@ -63,5 +63,6 @@ public void Concatenate_WithVariables_CorrectValue() func.AddSetVariable("a", "word"); Assert.AreEqual("a1word", func.Evaluate()); } + } } diff --git a/ExpressionEvaluatorTests/ContainsTests.cs b/ExpressionEvaluatorTests/ContainsTests.cs index 50bf755..f70b198 100644 --- a/ExpressionEvaluatorTests/ContainsTests.cs +++ b/ExpressionEvaluatorTests/ContainsTests.cs @@ -65,5 +65,6 @@ public void Contains_StringIsASubstring_True() _func.Function = @"Contains('abcd','bc')"; Assert.AreEqual(true, _func.EvaluateBoolean()); } + } } diff --git a/ExpressionEvaluatorTests/DateTimeTests.cs b/ExpressionEvaluatorTests/DateTimeTests.cs index 21d0deb..cc9d4d4 100644 --- a/ExpressionEvaluatorTests/DateTimeTests.cs +++ b/ExpressionEvaluatorTests/DateTimeTests.cs @@ -495,5 +495,11 @@ public void Subtraction_TimeSpanTimeSpan_IsCorrect() _func.AddSetVariable("a", _now); Assert.AreEqual(new TimeSpan(1, 0, 0, 0), _func.Evaluate()); } + [Test] + public void Now_test() { + _func.Function = "a"; + _func.AddSetVariable("a", _now); + Assert.AreEqual(_now, _func.Evaluate()); + } } } diff --git a/ExpressionEvaluatorTests/LengthTests.cs b/ExpressionEvaluatorTests/LengthTests.cs index cd5a503..90c2afe 100644 --- a/ExpressionEvaluatorTests/LengthTests.cs +++ b/ExpressionEvaluatorTests/LengthTests.cs @@ -28,5 +28,12 @@ public void Length_ValidSTring_IsCorrect() _func.Function = @"Length('abcd')"; Assert.AreEqual(4, _func.EvaluateNumeric()); } + + [Test] + public void Length_EmptyString() + { + _func.Function = @"Length('')"; + Assert.AreEqual(0, _func.EvaluateNumeric()); + } } } diff --git a/ExpressionEvaluatorTests/MultiplicationOperatorTests.generated.cs b/ExpressionEvaluatorTests/MultiplicationOperatorTests.generated.cs index ad31916..fe7d6aa 100644 --- a/ExpressionEvaluatorTests/MultiplicationOperatorTests.generated.cs +++ b/ExpressionEvaluatorTests/MultiplicationOperatorTests.generated.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using NUnit.Framework; using Vanderbilt.Biostatistics.Wfccm2; @@ -592,6 +593,5 @@ public void MultiplicationOperator_MalformedExpressionNegativeFractionRightOfOpe ExpressionException ex = Assert.Throws(() => _func.Function = func); StringAssert.Contains("Operator error", ex.Message); } - } } diff --git a/ExpressionEvaluatorTests/StringTests.cs b/ExpressionEvaluatorTests/StringTests.cs index 9532ef7..d6e6ff2 100644 --- a/ExpressionEvaluatorTests/StringTests.cs +++ b/ExpressionEvaluatorTests/StringTests.cs @@ -140,5 +140,6 @@ public void ToStringOperator_VariableWithSapce_SpaceIsIncluded() _func.Function = "'Test '"; Assert.AreEqual("Test ", _func.Evaluate()); } + } } diff --git a/ExpressionEvaluatorTests/ToStringFormatTests.cs b/ExpressionEvaluatorTests/ToStringFormatTests.cs index 72ba55c..8c35aaa 100644 --- a/ExpressionEvaluatorTests/ToStringFormatTests.cs +++ b/ExpressionEvaluatorTests/ToStringFormatTests.cs @@ -34,5 +34,6 @@ public void ToStringFormat_TrailingZero_CorrectValue() func.Function = @"ToStringFormat(10.1, '0.00')"; Assert.AreEqual("10.10", func.Evaluate()); } + } } diff --git a/ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj b/ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj new file mode 100644 index 0000000..7901cd3 --- /dev/null +++ b/ExpressionEvaluatorUi/ExpressionEvaluatorUi.csproj @@ -0,0 +1,42 @@ + + + + Library + netcoreapp3.1;net48 + latest + true + true + Aprajit Katiyar + Siemens Healthineers + $(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + + + true + ExpressionEvaluator.dll + + + + + + + + + \ No newline at end of file diff --git a/ExpressionEvaluatorUi/Images/close.png b/ExpressionEvaluatorUi/Images/close.png new file mode 100644 index 0000000..cf58908 Binary files /dev/null and b/ExpressionEvaluatorUi/Images/close.png differ diff --git a/ExpressionEvaluatorUi/Images/edit.png b/ExpressionEvaluatorUi/Images/edit.png new file mode 100644 index 0000000..c468724 Binary files /dev/null and b/ExpressionEvaluatorUi/Images/edit.png differ diff --git a/ExpressionEvaluatorUi/Model/IVariable.cs b/ExpressionEvaluatorUi/Model/IVariable.cs new file mode 100644 index 0000000..7e7940c --- /dev/null +++ b/ExpressionEvaluatorUi/Model/IVariable.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ExpressionEvaluatorUi.Model +{ + public interface IVariable + { + string Name { get; set; } + string Type { get; set; } + string Description { get; set; } + object Value { get; set; } + } +} diff --git a/ExpressionEvaluatorUi/Model/Operator.cs b/ExpressionEvaluatorUi/Model/Operator.cs new file mode 100644 index 0000000..4deb695 --- /dev/null +++ b/ExpressionEvaluatorUi/Model/Operator.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ExpressionEvaluatorUi.Model +{ + public class Operator + { + public string Category { get; set; } + public string Type { get; set; } + public string Description { get; set; } + } +} diff --git a/ExpressionEvaluatorUi/Model/Variable.cs b/ExpressionEvaluatorUi/Model/Variable.cs new file mode 100644 index 0000000..902d80c --- /dev/null +++ b/ExpressionEvaluatorUi/Model/Variable.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace ExpressionEvaluatorUi.Model +{ + public class Variable:IVariable,INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + private string _name; + private string _type; + private string _description; + private object _value; + public string Name + { + get { return _name; } + set + { + _name = value; + OnPropertyChanged(nameof(Name)); + } + } + public string Type + { + get { return _type; } + set + { + _type = value; + OnPropertyChanged((nameof(Type))); + } + } + public string Description + { + get { return _description; } + set + { + _description = value; + OnPropertyChanged(nameof(Description)); + } + } + public object Value + { + get { return _value; } + set + { + _value = value; + OnPropertyChanged(nameof(Value)); + } + } + protected void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/ExpressionEvaluatorUi/ResourceDictionaries/ButtonDictionary.xaml b/ExpressionEvaluatorUi/ResourceDictionaries/ButtonDictionary.xaml new file mode 100644 index 0000000..ee13a60 --- /dev/null +++ b/ExpressionEvaluatorUi/ResourceDictionaries/ButtonDictionary.xaml @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/ExpressionEvaluatorUi/ResourceDictionaries/OperatorListViewDictionary.xaml b/ExpressionEvaluatorUi/ResourceDictionaries/OperatorListViewDictionary.xaml new file mode 100644 index 0000000..833202d --- /dev/null +++ b/ExpressionEvaluatorUi/ResourceDictionaries/OperatorListViewDictionary.xaml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/ExpressionEvaluatorUi/View/AddEditVariableView.xaml b/ExpressionEvaluatorUi/View/AddEditVariableView.xaml new file mode 100644 index 0000000..bfae76a --- /dev/null +++ b/ExpressionEvaluatorUi/View/AddEditVariableView.xaml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +