Imported Upstream version 4.4.2.4

Former-commit-id: 92904c9c5915c37244316e42ba99e7b934ed7ee2
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-07-21 09:40:10 +00:00
parent 589d484eee
commit 0b4a830db1
343 changed files with 9849 additions and 688 deletions

View File

@@ -0,0 +1,98 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.Diagnostics.Contracts;
namespace System.Globalization
{
public static class GlobalizationExtensions
{
public static StringComparer GetStringComparer(this CompareInfo compareInfo, CompareOptions options)
{
if (compareInfo == null)
{
throw new ArgumentNullException(nameof(compareInfo));
}
if (options == CompareOptions.Ordinal)
{
return StringComparer.Ordinal;
}
if (options == CompareOptions.OrdinalIgnoreCase)
{
return StringComparer.OrdinalIgnoreCase;
}
if ((options & CultureAwareComparer.ValidCompareMaskOffFlags) != 0)
{
throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options));
}
return new CultureAwareComparer(compareInfo, options);
}
}
internal sealed class CultureAwareComparer : StringComparer
{
internal const CompareOptions ValidCompareMaskOffFlags =
~(CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreNonSpace |
CompareOptions.IgnoreWidth | CompareOptions.IgnoreKanaType | CompareOptions.StringSort);
private readonly CompareInfo _compareInfo;
private readonly CompareOptions _options;
internal CultureAwareComparer(CompareInfo compareInfo, CompareOptions options)
{
Debug.Assert((options & ValidCompareMaskOffFlags) == 0);
_compareInfo = compareInfo;
_options = options;
}
public override int Compare(string x, string y)
{
if (Object.ReferenceEquals(x, y)) return 0;
if (x == null) return -1;
if (y == null) return 1;
return _compareInfo.Compare(x, y, _options);
}
public override bool Equals(string x, string y)
{
if (Object.ReferenceEquals(x, y)) return true;
if (x == null || y == null) return false;
return (_compareInfo.Compare(x, y, _options) == 0);
}
public override int GetHashCode(string obj)
{
if (obj == null)
{
throw new ArgumentNullException(nameof(obj));
}
Contract.EndContractBlock();
// StringSort used in compare operation and not with the hashing
return _compareInfo.GetHashCode(obj, _options & (~CompareOptions.StringSort));
}
// Equals method for the comparer itself.
public override bool Equals(object obj)
{
CultureAwareComparer comparer = obj as CultureAwareComparer;
return
comparer != null &&
_options == comparer._options &&
_compareInfo.Equals(comparer._compareInfo);
}
public override int GetHashCode()
{
return _compareInfo.GetHashCode() ^ ((int)_options & 0x7FFFFFFF);
}
}
}

View File

@@ -0,0 +1,4 @@
partial class SR
{
public const string Argument_InvalidFlag = "Value of flags is invalid.";
}

View File

@@ -0,0 +1,61 @@
//
// StringNormalizationExtensions.cs
//
// Author:
// Alexander Köplinger (alexander.koeplinger@xamarin.com)
//
// (C) 2016 Xamarin, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Text;
namespace System
{
public static class StringNormalizationExtensions
{
[MonoTODO]
public static bool IsNormalized(this string value)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static bool IsNormalized(this string value, NormalizationForm normalizationForm)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static String Normalize(this string value)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static String Normalize(this string value, NormalizationForm normalizationForm)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -1,3 +1,7 @@
TypeForwarders.cs
AssemblyInfo.cs
../../../build/common/MonoTODOAttribute.cs
SR.cs
GlobalizationExtensions.cs
StringNormalizationExtensions.cs

View File

@@ -22,5 +22,3 @@
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Globalization.IdnMapping))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Text.NormalizationForm))]
// Missing: [assembly:System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Globalization.GlobalizationExtensions))]
// Missing: [assembly:System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.StringNormalizationExtensions))]