Skip to content

Commit 3dd57df

Browse files
committed
fixed InvariantCulture
1 parent d80b9ac commit 3dd57df

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

Example/Data/Context.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
2727
//optionsBuilder.UseFileContext("json", "encrypted");
2828

2929
//XML
30-
//optionsBuilder.UseFileContext("xml");
31-
optionsBuilder.UseFileContext("xml", "private");
30+
optionsBuilder.UseFileContext("xml");
31+
//optionsBuilder.UseFileContext("xml", "private");
3232

3333
//CSV
3434
//optionsBuilder.UseFileContext("csv");
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This file is used by the publish/package process of your project. You can customize the behavior of this process
4+
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
5+
-->
6+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
7+
<PropertyGroup>
8+
<PublishProtocol>FileSystem</PublishProtocol>
9+
<Configuration>Release</Configuration>
10+
<TargetFramework>netcoreapp2.0</TargetFramework>
11+
<PublishDir>bin\Release\PublishOutput</PublishDir>
12+
</PropertyGroup>
13+
</Project>

FileContextCore/Serializer/SerializerHelper.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Text;
45

56
namespace FileContextCore.Serializer
@@ -15,23 +16,25 @@ public static object Deserialize(this string input, Type type)
1516

1617
if (type == typeof(TimeSpan))
1718
{
18-
return TimeSpan.Parse(input);
19+
return TimeSpan.Parse(input, CultureInfo.InvariantCulture);
1920
}
2021
else if(type == typeof(Guid))
2122
{
2223
return Guid.Parse(input);
2324
}
2425
else
2526
{
26-
return Convert.ChangeType(input, type);
27+
return Convert.ChangeType(input, type, CultureInfo.InvariantCulture);
2728
}
2829
}
2930

3031
public static string Serialize(this object input)
3132
{
3233
if(input != null)
3334
{
34-
return input.ToString();
35+
IFormattable formattable = input as IFormattable;
36+
37+
return formattable != null ? formattable.ToString(null, CultureInfo.InvariantCulture) : input.ToString();
3538
}
3639

3740
return "";

0 commit comments

Comments
 (0)