Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to extract common override 'TooLow' getter code to a single 'template' getter? Generics? Overload '<'?
    primarykey
    data
    text
    <p>How to extract common override 'TooLow' getter code to a single 'template' getter? Generics? Overload '&lt;'?</p> <p><code>get { bool rtn = _prmpt.MinValue.HasValue &amp;&amp; (_prmpt.ResultValue &lt; _prmpt.MinValue); return rtn; }</code></p> <p>The goal is to only have this code once. However I haven't figured out how to handle 'int?' and 'decimal?' invocations to do <code>.HasValue</code> and <code>&lt;</code> correctly using generics. . . . Suggestions? Thank you in advance.</p> <pre><code> /// &lt;summary&gt; /// abstracted Generic Prompt Base /// &lt;/summary&gt; public abstract class GenPromptBase { public string InputValueType { get; set; } public abstract bool TooLow { get; } } /// &lt;summary&gt; /// Derived Generic 'Money' class of 'GenPromptBase' /// &lt;/summary&gt; public class GenPromptMoney : GenPromptBase { PromptMoney _prmpt; public GenPromptMoney(PromptMoney prmptParms) { _prmpt = prmptParms; InputValueType = _prmpt.InputValueType; } public override void ParseInput(string result) { _prmpt.ResultValue = decimal.Parse(result); } public override bool TooLow { get { bool rtn = _prmpt.MinValue.HasValue &amp;&amp; (_prmpt.ResultValue &lt; _prmpt.MinValue); return rtn; } } } /// &lt;summary&gt; /// Derived Generic 'Value' class of 'GenPromptBase' /// &lt;/summary&gt; public class GenPromptValue : GenPromptBase { PromptValue _prmpt; public GenPromptValue(PromptValue prmptParms) { _prmpt = prmptParms; InputValueType = _prmpt.InputValueType; } public override void ParseInput(string result) { _prmpt.ResultValue = int.Parse(result); } public override bool TooLow { get { bool rtn = _prmpt.MinValue.HasValue &amp;&amp; (_prmpt.ResultValue &lt; _prmpt.MinValue); return rtn; } } } /// &lt;summary&gt; /// Generic Prompt Class /// &lt;/summary&gt; public class GenPrompt&lt;Z&gt; { public string InputValueType { get; set; } public Z MinValue; public Z MaxValue; } /// &lt;summary&gt; /// Derived 'Money' class of 'GenPrompt« decimal? »' /// &lt;/summary&gt; public class PromptMoney : GenPrompt&lt;decimal?&gt; { public PromptMoney( decimal? minValue = null, decimal? maxValue = null, string inputValueType = Constants.U_GOI_FORMAT_OPTION_MONEY) { InputValueType = inputValueType; MinValue = minValue; MaxValue = maxValue; ResultValue = null; } public decimal? ResultValue; } /// &lt;summary&gt; /// Derived 'Value' class of 'GenPrompt« int? »' /// &lt;/summary&gt; public class PromptValue : GenPrompt&lt;int?&gt; { public PromptValue( int? minValue = null, int? maxValue = null, string inputValueType = Constants.U_GOI_FORMAT_OPTION_NUMBER) { InputValueType = inputValueType; MinValue = minValue; MaxValue = maxValue; ResultValue = null; } public int? ResultValue; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload