本文整理汇总了C#中StringHandle.GetHeapOffset方法的典型用法代码示例。如果您正苦于以下问题:C# StringHandle.GetHeapOffset方法的具体用法?C# StringHandle.GetHeapOffset怎么用?C# StringHandle.GetHeapOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringHandle
的用法示例。
在下文中一共展示了StringHandle.GetHeapOffset方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHeapOffset
/// <summary>
/// Returns the offset of metadata heap data that corresponds
/// to the specified <paramref name="handle"/>.
/// </summary>
/// <returns>
/// Zero based offset, or -1 if <paramref name="handle"/> can only be interpreted in a context of a specific <see cref="MetadataReader"/> or <see cref="MetadataBuilder"/>.
/// See <see cref="GetHeapOffset(MetadataReader, Handle)"/>.
/// </returns>
public static int GetHeapOffset(StringHandle handle) => handle.IsVirtual ? -1 : handle.GetHeapOffset();
示例2: StartsWithRaw
/// <summary>
/// Returns true if the given raw (non-virtual) handle represents a string that starts with given ASCII prefix.
/// </summary>
internal bool StartsWithRaw(StringHandle rawHandle, string asciiPrefix)
{
Debug.Assert(!rawHandle.IsVirtual);
Debug.Assert(rawHandle.StringKind != StringKind.DotTerminated, "Not supported");
return this.Block.Utf8NullTerminatedStringStartsWithAsciiPrefix(rawHandle.GetHeapOffset(), asciiPrefix);
}
示例3: BinarySearchRaw
/// <summary>
/// Equivalent to Array.BinarySearch, searches for given raw (non-virtual) handle in given array of ASCII strings.
/// </summary>
internal int BinarySearchRaw(string[] asciiKeys, StringHandle rawHandle)
{
Debug.Assert(!rawHandle.IsVirtual);
Debug.Assert(rawHandle.StringKind != StringKind.DotTerminated, "Not supported");
return this.Block.BinarySearch(asciiKeys, rawHandle.GetHeapOffset());
}
示例4: StartsWith
internal bool StartsWith(StringHandle handle, string value, MetadataStringDecoder utf8Decoder, bool ignoreCase)
{
Debug.Assert(value != null);
if (handle.IsVirtual)
{
// TODO: This can allocate unnecessarily for <WinRT> prefixed handles.
return GetString(handle, utf8Decoder).StartsWith(value, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
}
if (handle.IsNil)
{
return value.Length == 0;
}
char otherTerminator = handle.StringKind == StringKind.DotTerminated ? '.' : '\0';
return this.Block.Utf8NullTerminatedStartsWith(handle.GetHeapOffset(), value, utf8Decoder, otherTerminator, ignoreCase);
}
示例5: EqualsRaw
/// <summary>
/// Returns true if the given raw (non-virtual) handle represents the same string as given ASCII string.
/// </summary>
internal bool EqualsRaw(StringHandle rawHandle, string asciiString)
{
Debug.Assert(!rawHandle.IsVirtual);
Debug.Assert(rawHandle.StringKind != StringKind.DotTerminated, "Not supported");
return this.Block.CompareUtf8NullTerminatedStringWithAsciiString(rawHandle.GetHeapOffset(), asciiString) == 0;
}
示例6: GetNextHandle
internal StringHandle GetNextHandle(StringHandle handle)
{
if (handle.IsVirtual)
{
return default(StringHandle);
}
int terminator = this.Block.IndexOf(0, handle.GetHeapOffset());
if (terminator == -1 || terminator == Block.Length - 1)
{
return default(StringHandle);
}
return StringHandle.FromOffset(terminator + 1);
}
示例7: GetString
internal string GetString(StringHandle handle, MetadataStringDecoder utf8Decoder)
{
byte[] prefix;
if (handle.IsVirtual)
{
switch (handle.StringKind)
{
case StringKind.Virtual:
return s_virtualValues[(int)handle.GetVirtualIndex()];
case StringKind.WinRTPrefixed:
prefix = MetadataReader.WinRTPrefix;
break;
default:
Debug.Assert(false, "We should not get here");
return null;
}
}
else
{
prefix = null;
}
int bytesRead;
char otherTerminator = handle.StringKind == StringKind.DotTerminated ? '.' : '\0';
return this.Block.PeekUtf8NullTerminated(handle.GetHeapOffset(), prefix, utf8Decoder, out bytesRead, otherTerminator);
}
示例8: GetNonVirtualStringMemoryBlock
private unsafe MemoryBlock GetNonVirtualStringMemoryBlock(StringHandle handle)
{
Debug.Assert(handle.StringKind != StringKind.Virtual);
int bytesRead;
char otherTerminator = handle.StringKind == StringKind.DotTerminated ? '.' : '\0';
int offset = handle.GetHeapOffset();
int length = Block.GetUtf8NullTerminatedLength(offset, out bytesRead, otherTerminator);
return new MemoryBlock(Block.Pointer + offset, length);
}
示例9: GetNonVirtualString
private string GetNonVirtualString(StringHandle handle, MetadataStringDecoder utf8Decoder, byte[] prefixOpt)
{
Debug.Assert(handle.StringKind != StringKind.Virtual);
int bytesRead;
char otherTerminator = handle.StringKind == StringKind.DotTerminated ? '.' : '\0';
return Block.PeekUtf8NullTerminated(handle.GetHeapOffset(), prefixOpt, utf8Decoder, out bytesRead, otherTerminator);
}
示例10: Equals
internal bool Equals(StringHandle handle, string value, MetadataStringDecoder utf8Decoder)
{
Debug.Assert(value != null);
if (handle.IsVirtual)
{
// TODO:This can allocate unnecessarily for <WinRT> prefixed handles.
return GetString(handle, utf8Decoder) == value;
}
if (handle.IsNil)
{
return value.Length == 0;
}
char otherTerminator = handle.StringKind == StringKind.DotTerminated ? '.' : '\0';
return this.Block.Utf8NullTerminatedEquals(handle.GetHeapOffset(), value, utf8Decoder, otherTerminator);
}