c# - Design assistance: Calculation of time with expression parsed at runtime -
I have some columns in the database that have time in the Now in the above case, I can call the runtime using my I like this How do I parse the expressions? I do not need coding help because I already have I would say store it to find a string and operator. Create a recursive function parse endacam (string input), which parse the result in the correct order and calculates. Something like this: HH: MM format. Now if there are no simple expressions like
11:00 - 12:00 then I can easily call an extension method in C # as the
subtractTime and its logic At the runtime I will store my formula in the database for example:
condition value exam time frame & gt; 10:00 SubtractTime (original, left)
subtractTime function, but my problem is What if my expressions become complicated:
10:00 + 12:00 * 00:02 - 10:11
HH: MM after designing my extension for time, it's more of a design question. I need a scalable solution so that I can make a rule engine efficiently.
double parse endcack (string input) {string [] sub; Double result = 0; If (input.Contains ("+")) {sub = input.Split ('+'); Foreach (sub-string in sub) {result = pars endcall (substrings); }} And if (input. ("-")) {sub = input.Split ('-'); Foreign currency (sub-string in sub) {Results - = purse endacamples; }} And if (Input. ("*")) {Sub = input.Split ('*'); Foreach (in string sub-sub) {result * = pars endcakal (substring); }} And if (Input. ("/")) {Sub = input.Split ('/'); Forecheck (sub-string in sub) {double purse = purse endcake (substring); If (pars! = 0) {Results / = parse endcakal (substring); } Else {// error}}} Return result; }
Comments
Post a Comment