private static string SerializeDecimalResult(DecimalResult r) { switch (r.state) { case EDecimalResultState.eDecimalResultState_Valid: return(r.value.ToString()); case EDecimalResultState.eDecimalResultState_NaN: return("NaN"); case EDecimalResultState.eDecimalResultState_INF: return("INF"); default: throw new ArgumentOutOfRangeException("r.state"); } }
public void Test01Decfloat() { //string telegram = "<DecimalResult xmlns='LancePlatform'><timestamp>2016-02-04T09:27:32.7300</timestamp><state>eDecimalResultState_Valid</state><value>1.034</value></DecimalResult>"; string telegram = "<DecimalResult xmlns='tf'><timestamp>2016-02-04T09:27:32.7300</timestamp><state>0</state><value>1.034</value></DecimalResult>"; StringReader stringReader = new StringReader(telegram); XmlTextReader reader = new XMLSerializationCustomization.PdkXmlTextReader(stringReader); { DecimalResult objResultMessage = new DecimalResult(); XmlRootAttribute xmlRoot = new XmlRootAttribute(); xmlRoot.Namespace = "tf"; xmlRoot.IsNullable = true; XmlSerializer xmlser = new XmlSerializer(objResultMessage.GetType(), xmlRoot); objResultMessage = (DecimalResult)xmlser.Deserialize(reader); } }
/// <summary> /// Add a decimal solution to the answer cell /// </summary> /// <param name="row">The row of the answer cell</param> /// <param name="column">The column of the answer cell</param> /// <param name="expectedValue">The expected value of the answer cell</param> /// <param name="epsilon">The tolerance range for the input. See the decimal result for a detailed description</param> protected void AddDecimalSolution(int row, int column, decimal expectedValue, decimal epsilon = 0) { IResult result = new DecimalResult(expectedValue, epsilon); AddSolution(result, row, column); }