public SortKey GetSortKey(string source) { #if NET461 return(_collator.GetSortKey(source)); #elif NETSTANDARD2_0 Icu.SortKey icuSortKey = _collator.GetSortKey(source); SortKey sortKey = CultureInfo.InvariantCulture.CompareInfo.GetSortKey(string.Empty, CompareOptions.None); string keyDataFieldName, origStringFieldName; if (Platform.IsDotNetFramework) { keyDataFieldName = "m_KeyData"; origStringFieldName = "m_String"; } else if (Platform.IsDotNetCore) { keyDataFieldName = "_keyData"; origStringFieldName = "_string"; } else if (Platform.IsMono) { keyDataFieldName = "key"; origStringFieldName = "source"; } else { throw new PlatformNotSupportedException(); } SetInternalFieldForPublicProperty(sortKey, "SortKey.KeyData", keyDataFieldName, icuSortKey.KeyData); SetInternalFieldForPublicProperty(sortKey, "SortKey.OriginalString", origStringFieldName, icuSortKey.OriginalString); return(sortKey); #endif }
public override void SetStringValue(string value) { key = collator.GetSortKey(value); bytes.Bytes = key.KeyData; bytes.Offset = 0; bytes.Length = key.KeyData.Length; }
public override void FillBytesRef() { BytesRef bytes = this.BytesRef; SortKey key = collator.GetSortKey(ToString()); bytes.Bytes = key.KeyData; bytes.Offset = 0; bytes.Length = key.KeyData.Length; }
public override bool IncrementToken() { if (m_input.IncrementToken()) { char[] termBuffer = termAtt.Buffer; string termText = new string(termBuffer, 0, termAtt.Length); reusableKey = collator.GetSortKey(termText); int encodedLength = IndexableBinaryStringTools.GetEncodedLength( reusableKey.KeyData, 0, reusableKey.KeyData.Length); if (encodedLength > termBuffer.Length) { termAtt.ResizeBuffer(encodedLength); } termAtt.SetLength(encodedLength); IndexableBinaryStringTools.Encode(reusableKey.KeyData, 0, reusableKey.KeyData.Length, termAtt.Buffer, 0, encodedLength); return(true); } else { return(false); } }