public void TestConvertBindToSFValFinlandLocale() { Thread testThread = new Thread(() => { CultureInfo ci = new CultureInfo("en-FI"); Thread.CurrentThread.CurrentCulture = ci; System.Tuple <string, string> t = SFDataConverter.csharpTypeValToSfTypeVal(System.Data.DbType.Double, 1.2345); Assert.AreEqual("REAL", t.Item1); Assert.AreEqual("1.2345", t.Item2); }); testThread.Start(); testThread.Join(); }
private Dictionary <string, BindingDTO> convertToBindList(List <SnowflakeDbParameter> parameters) { if (parameters == null || parameters.Count == 0) { return(null); } else { Dictionary <string, BindingDTO> binding = new Dictionary <string, BindingDTO>(); foreach (SnowflakeDbParameter parameter in parameters) { string bindingType = ""; object bindingVal; if (parameter.Value.GetType().IsArray&& // byte array and char array will not be treated as array binding parameter.Value.GetType().GetElementType() != typeof(char) && parameter.Value.GetType().GetElementType() != typeof(byte)) { List <object> vals = new List <object>(); foreach (object val in (Array)parameter.Value) { // if the user is using interface, SFDataType will be None and there will // a conversion from DbType to SFDataType // if the user is using concrete class, they should specify SFDataType. if (parameter.SFDataType == SFDataType.None) { Tuple <string, string> typeAndVal = SFDataConverter .csharpTypeValToSfTypeVal(parameter.DbType, val); bindingType = typeAndVal.Item1; vals.Add(typeAndVal.Item2); } else { bindingType = parameter.SFDataType.ToString(); vals.Add(SFDataConverter.csharpValToSfVal(parameter.SFDataType, val)); } } bindingVal = vals; } else { if (parameter.SFDataType == SFDataType.None) { Tuple <string, string> typeAndVal = SFDataConverter .csharpTypeValToSfTypeVal(parameter.DbType, parameter.Value); bindingType = typeAndVal.Item1; bindingVal = typeAndVal.Item2; } else { bindingType = parameter.SFDataType.ToString(); bindingVal = SFDataConverter.csharpValToSfVal(parameter.SFDataType, parameter.Value); } } binding[parameter.ParameterName] = new BindingDTO(bindingType, bindingVal); } return(binding); } }