Пример #1
0
 /// <summary>
 /// Converts the given SIFSimpleType instance to an XML string value
 /// </summary>
 /// <param name="formatter">The formatter to sue for the current version of SIF being written to</param>
 /// <param name="sifType">The value to write</param>
 /// <returns>A string representing the XML payload used for the specified version
 /// of SIF. All types are nullable in SIF, so the resulting value could be null/</returns>
 public override String ToString(SifFormatter formatter,
                                 AdkDataType <TimeSpan?> sifType)
 {
     if (sifType.Value.HasValue)
     {
         return(formatter.ToString(sifType.Value));
     }
     return(null);
 }
Пример #2
0
            /// <summary>
            /// Converts the given SIFSimpleType instance to an XML string value
            /// </summary>
            /// <param name="formatter">The formatter to sue for the current version of SIF being written to</param>
            /// <param name="value">The value to write</param>
            /// <returns>A string representing the XML payload used for the specified version
            /// of SIF. All types are nullable in SIF, so the resulting value could be null/</returns>
            public override String ToString(SifFormatter formatter,
                                            AdkDataType <float?> value)
            {
                float?i = value.Value;

                if (i.HasValue)
                {
                    return(formatter.ToString(i));
                }
                return(null);
            }
Пример #3
0
        private void assertintParsing(SifFormatter formatter, String stringValue, int value)
        {
            Console.WriteLine("Testing int parse of '" + stringValue + "' using " + formatter.ToString());
            int? testValue = formatter.ToInt(stringValue);
            Assertion.AssertEquals("int Value", value, testValue);
            Assertion.AssertEquals("String Value", stringValue, formatter.ToString(value));

            testValue = formatter.ToInt(null);
            Assertion.AssertNull("int value should be null", testValue);
        }
Пример #4
0
        private void assertFloatParsing(SifFormatter formatter, String stringValue, float value)
        {
            Console.WriteLine( "Testing Float parse of '" + stringValue + "' using " + formatter.ToString() );
            float? testValue = formatter.ToFloat( stringValue );
            Assert.AreEqual( value, testValue );
            Assert.AreEqual( stringValue, formatter.ToString( value ), "String Value" );

            testValue = formatter.ToFloat( null );
            Assert.IsFalse( testValue.HasValue, "Float value should be null" );
        }
Пример #5
0
        private void AssertDateParsing(SifFormatter formatter, String stringValue, Calendar value)
        {
            Console.WriteLine("Testing Date parse of '" + stringValue + "' using " + formatter.ToString());
            //Calendar testValue = formatter.ToDate(stringValue);
            DateTime testValue = (DateTime) formatter.ToDate(stringValue);
            Assertion.AssertEquals("Date Value", value, testValue);
            Assertion.AssertEquals("String Value", stringValue, (String) formatter.ToDateString(testValue));

            testValue = (DateTime) formatter.ToDate(null);
            Assertion.AssertNull("Date value should be null", testValue);
        }
Пример #6
0
        private void assertBooleanParsing(SifFormatter formatter, String stringValue, Boolean value)
        {
            Console.WriteLine("Testing Boolean parse of '" + stringValue + "' using " + formatter.ToString());
            Boolean? testValue = formatter.ToBool(stringValue);
            Assertion.AssertEquals("Boolean Value", value, testValue);
            Assertion.AssertEquals("String Value", stringValue, formatter.ToString(value));

            testValue = formatter.ToBool(null);
            Assertion.AssertNull("Boolean value should be null", testValue);
        }