我试图使用xml配置配置autofac但遇到locale问题。我尝试注册的组件之一需要双参数,在我的本地系统上有格式xxx,yyy - 使用逗号作为小数分隔符。我必须使用的另一个系统使用点作为小数分隔符。有没有办法如何强制autofac忽略区域设置,只解析带点作为小数分隔符的数字?
这个配置
<?xml version="1.0" encoding="utf-8" ?>
<autofac>
<components name="0">
<type>Geometry.SomeRule, Geometry</type>
<services name="0" type="Geometry.IValidationRule, Geometry" />
<parameters>
<min>3.048</min>
<max>4.572</max>
</parameters>
</components>
</autofac>
投
Autofac.Core.DependencyResolutionException: 'An exception was thrown while activating IValidationRule[] -> SomeRule.'
Inner exceptions: Exception: 3,048 is not a valid value for Double.
如果我在我的设备上使用逗号注册工作,但另一方面没有。
我能够通过在注册和容器构建期间设置CurrentThread.CurrentCulture来克服这个问题,但它对我来说似乎不是一个正确的解决方案。