Skip to content

Commit 8770454

Browse files
committed
NH-3807 - Replace uses of ToShortTimeString, ToShortDateString, Comparer.DefaultInvariant, and CreateSpecificCulture.
These have been removed from CoreClr. Use new CultureInfo(string) instead of CultureInfo.CreateSpecificCulture(string)
1 parent 549e685 commit 8770454

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

src/NHibernate/Type/ByteType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ public virtual object Seed(ISessionImplementor session)
7878

7979
public IComparer Comparator
8080
{
81-
get { return Comparer.DefaultInvariant; }
81+
get { return System.Collections.Generic.Comparer<byte>.Default; }
8282
}
8383

8484
public override object DefaultValue
8585
{
8686
get { return ZERO; }
8787
}
8888
}
89-
}
89+
}

src/NHibernate/Type/CultureInfoType.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,14 @@ public override string ToString(object value)
8080
/// <returns></returns>
8181
public override object FromStringValue(string xml)
8282
{
83-
return CultureInfo.CreateSpecificCulture(xml);
83+
return CreateSpecificCulture(xml);
84+
}
85+
86+
private static CultureInfo CreateSpecificCulture(string name)
87+
{
88+
var culture = new CultureInfo(name);
89+
90+
return !culture.IsNeutralCulture ? culture : CultureInfo.InvariantCulture;
8491
}
8592

8693
/// <summary></summary>
@@ -100,4 +107,4 @@ public string ObjectToSQLString(object value, Dialect.Dialect dialect)
100107
return ((ILiteralType) NHibernateUtil.String).ObjectToSQLString(value.ToString(), dialect);
101108
}
102109
}
103-
}
110+
}

src/NHibernate/Type/DateType.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public override int GetHashCode(object x, EntityMode entityMode)
9696

9797
public override string ToString(object val)
9898
{
99-
return ((DateTime) val).ToShortDateString();
99+
return ((DateTime) val).ToString("d");
100100
}
101101

102102
public override object FromStringValue(string xml)
@@ -121,7 +121,7 @@ public override object DefaultValue
121121

122122
public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
123123
{
124-
return "\'" + ((DateTime)value).ToShortDateString() + "\'";
124+
return "\'" + ((DateTime)value).ToString("d") + "\'";
125125
}
126126

127127
public void SetParameterValues(IDictionary<string, string> parameters)
@@ -137,4 +137,4 @@ public void SetParameterValues(IDictionary<string, string> parameters)
137137
}
138138
}
139139
}
140-
}
140+
}

src/NHibernate/Type/TimeType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public override object DefaultValue
131131

132132
public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
133133
{
134-
return "'" + ((DateTime)value).ToShortTimeString() + "'";
134+
return "'" + ((DateTime)value).ToString("t") + "'";
135135
}
136136
}
137137
}

src/NHibernate/Type/TimestampType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public virtual object Seed(ISessionImplementor session)
101101

102102
public IComparer Comparator
103103
{
104-
get { return Comparer.DefaultInvariant; }
104+
get { return System.Collections.Generic.Comparer<DateTime>.Default; }
105105
}
106106

107107
#endregion
@@ -126,4 +126,4 @@ public override string ObjectToSQLString(object value, Dialect.Dialect dialect)
126126
return '\'' + value.ToString() + '\'';
127127
}
128128
}
129-
}
129+
}

0 commit comments

Comments
 (0)