Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -32,7 +32,7 @@ namespace System.Globalization {
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class TextInfo : ICloneable, IDeserializationCallback
public partial class TextInfo : ICloneable, IDeserializationCallback
{
//--------------------------------------------------------------------//
// Internal Information //
@@ -73,8 +73,10 @@ namespace System.Globalization {
private String m_cultureName; // Name of the culture that created this text info
[NonSerialized]private CultureData m_cultureData; // Data record for the culture that made us, not for this textinfo
[NonSerialized]private String m_textInfoName; // Name of the text info we're using (ie: m_cultureData.STEXTINFO)
#if !MONO
[NonSerialized]private IntPtr m_dataHandle; // Sort handle
[NonSerialized]private IntPtr m_handleOrigin;
#endif
[NonSerialized]private bool? m_IsAsciiCasingSameAsInvariant;
@@ -103,7 +105,7 @@ namespace System.Globalization {
this.m_cultureData = cultureData;
this.m_cultureName = this.m_cultureData.CultureName;
this.m_textInfoName = this.m_cultureData.STEXTINFO;
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
IntPtr handleOrigin;
this.m_dataHandle = CompareInfo.InternalInitSortHandle(m_textInfoName, out handleOrigin);
this.m_handleOrigin = handleOrigin;
@@ -178,7 +180,7 @@ namespace System.Globalization {
// Get the text info name belonging to that culture
this.m_cultureData = CultureInfo.GetCultureInfo(m_cultureName).m_cultureData;
this.m_textInfoName = this.m_cultureData.STEXTINFO;
#if !FEATURE_CORECLR
#if !FEATURE_CORECLR && !MONO
IntPtr handleOrigin;
this.m_dataHandle = CompareInfo.InternalInitSortHandle(m_textInfoName, out handleOrigin);
this.m_handleOrigin = handleOrigin;
@@ -231,7 +233,7 @@ namespace System.Globalization {
// (not necessarily true for sorting, but OK for casing & then we apply normal hash code rules)
return (Invariant.GetCaseInsensitiveHashCode(s, forceRandomizedHashing, additionalEntropy));
}
#if !MONO
[System.Security.SecuritySafeCritical]
[ResourceExposure(ResourceScope.None)]
[ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
@@ -239,7 +241,7 @@ namespace System.Globalization {
{
return InternalTryFindStringOrdinalIgnoreCase(searchFlags, source, count, startIndex, value, value.Length, ref foundIndex);
}
#endif
// This function doesn't check arguments. Please do check in the caller.
// The underlying unmanaged code will assert the sanity of arguments.
[System.Security.SecuritySafeCritical] // auto-generated
@@ -294,9 +296,11 @@ namespace System.Globalization {
string valueUpper = value.ToUpper(CultureInfo.InvariantCulture);
#else
// fast path
#if !MONO
int ret = -1;
if (TryFastFindStringOrdinalIgnoreCase(Microsoft.Win32.Win32Native.FIND_FROMSTART, source, startIndex, value, count, ref ret))
return ret;
#endif
#endif
// the search space within [source] starts at offset [startIndex] inclusive and includes
@@ -364,9 +368,11 @@ namespace System.Globalization {
string valueUpper = value.ToUpper(CultureInfo.InvariantCulture);
#else
// fast path
#if !MONO
int ret = -1;
if (TryFastFindStringOrdinalIgnoreCase(Microsoft.Win32.Win32Native.FIND_FROMEND, source, startIndex, value, count, ref ret))
return ret;
#endif
#endif
// the search space within [source] ends at offset [startIndex] inclusive
@@ -592,7 +598,11 @@ namespace System.Globalization {
{
return ToLowerAsciiInvariant(c);
}
#if MONO
return ToLowerInternal (c);
#else
return (InternalChangeCaseChar(this.m_dataHandle, this.m_handleOrigin, this.m_textInfoName, c, false));
#endif
}
[System.Security.SecuritySafeCritical] // auto-generated
@@ -601,6 +611,9 @@ namespace System.Globalization {
if (str == null) { throw new ArgumentNullException("str"); }
Contract.EndContractBlock();
#if MONO
return ToLowerInternal (str);
#else
String toLower = InternalChangeCaseString(this.m_dataHandle, this.m_handleOrigin, this.m_textInfoName, str, false);
#if __APPLE__
//
@@ -624,7 +637,7 @@ namespace System.Globalization {
}
#endif
return toLower;
#endif
}
static private Char ToLowerAsciiInvariant(Char c)
@@ -655,7 +668,12 @@ namespace System.Globalization {
{
return ToUpperAsciiInvariant(c);
}
#if MONO
return ToUpperInternal (c);
#else
return (InternalChangeCaseChar(this.m_dataHandle, this.m_handleOrigin, this.m_textInfoName, c, true));
#endif
}
@@ -664,6 +682,10 @@ namespace System.Globalization {
{
if (str == null) { throw new ArgumentNullException("str"); }
Contract.EndContractBlock();
#if MONO
return ToUpperInternal (str);
#else
String toUpper = InternalChangeCaseString(this.m_dataHandle, this.m_handleOrigin, this.m_textInfoName, str, true);
#if __APPLE__
//
@@ -687,6 +709,7 @@ namespace System.Globalization {
}
#endif
return toUpper;
#endif
}
static private Char ToUpperAsciiInvariant(Char c)
@@ -709,10 +732,14 @@ namespace System.Globalization {
{
if (m_IsAsciiCasingSameAsInvariant == null)
{
#if MONO
m_IsAsciiCasingSameAsInvariant = !(m_cultureData.SISO639LANGNAME == "az" || m_cultureData.SISO639LANGNAME == "tr");
#else
m_IsAsciiCasingSameAsInvariant =
CultureInfo.GetCultureInfo(m_textInfoName).CompareInfo.Compare("abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
CompareOptions.IgnoreCase) == 0;
#endif
}
return (bool)m_IsAsciiCasingSameAsInvariant;
}
@@ -1044,10 +1071,14 @@ namespace System.Globalization {
}
Contract.EndContractBlock();
#if MONO
return StringComparer.CurrentCultureIgnoreCase.GetHashCode (str);
#else
// Return our result
return (InternalGetCaseInsHash(this.m_dataHandle, this.m_handleOrigin, this.m_textInfoName, str, forceRandomizedHashing, additionalEntropy));
#endif
}
#if !MONO
// Change case (ToUpper/ToLower) -- COMNlsInfo::InternalChangeCaseChar
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
@@ -1083,6 +1114,7 @@ namespace System.Globalization {
[SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
private static unsafe extern bool InternalTryFindStringOrdinalIgnoreCase(int searchFlags, String source, int sourceCount, int startIndex, String target, int targetCount, ref int foundIndex);
#endif
}
}