//Mapping null double?s to NaN when writing data.
if (memberValue == null)
{
System.Reflection.PropertyInfo p = type.GetProperty(classMember.Name);
if (p != null)
{
Type t = p.PropertyType; // t will be System.String
if (t.IsEquivalentTo(typeof(Nullable<Double>)))
memberValue = Double.NaN;
}
}
FluorineFx.NET
Null values
The <nullable> configuration section allows the use of special value of the given value type as the null value.
Use this solution only when you can identify a value which is unused.
<nullable>
<type name="System.Int32" assembly="MinValue"/>
<type name="System.Double" assembly="MinValue"/>
<type name="System.DateTime" assembly="MinValue"/>
<type name="System.Guid" assembly="Empty"/>
</nullable>
The name attribute is the fully qualified type name, the value attribute is a static member of the type (such as "MinValue") or a parseable value (0 for System.Int32 for example).
The acceptNullValueTypes option
Fluorine will accept null values sent from client for value-types if configured accordingly
<acceptNullValueTypes>false</acceptNullValueTypes>
If acceptNullValueTypes = true (the default is false if not specified) any value-type that is not explicitly initialized with a value will contain the default value for that object type (0 for numeric types, false for Boolean, DateTime.Min for DateTime)
3条答案
按热度按时间xdyibdwo1#
我不知道氟,但我想你可以通过:
这个运算式的型别是
double
,而不是double?
,而且如果myDouble
是null
,它就会是NaN。r8xiu3jd2#
我们只是遇到了同样的问题。我们的解决方案是修改Fluorine代码来写对象。
在文件
AMFWriter
的第1367
行中,在调用WriteAMF3Data(memberValue)
之前,我添加了以下代码:到目前为止,它看起来是可行的。但是,我通常不使用.NET编写代码,所以可能有更好的方法来实现这一点。
ubbxdtey3#
看起来Fluorine有一个配置部分,定义了如何转换空值。我还没有测试过。
从http://www.fluorinefx.com/docs/fluorine/nullable.html复制