本文整理汇总了C#中StringHandle.GetVirtualIndex方法的典型用法代码示例。如果您正苦于以下问题:C# StringHandle.GetVirtualIndex方法的具体用法?C# StringHandle.GetVirtualIndex怎么用?C# StringHandle.GetVirtualIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringHandle
的用法示例。
在下文中一共展示了StringHandle.GetVirtualIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVirtualHandleMemoryBlock
private MemoryBlock GetVirtualHandleMemoryBlock(StringHandle handle)
{
Debug.Assert(handle.IsVirtual);
var heap = VirtualHeap.GetOrCreateVirtualHeap(ref _lazyVirtualHeap);
VirtualHeapBlob virtualBlob;
lock (heap)
{
if (!heap.Table.TryGetValue(handle.RawValue, out virtualBlob))
{
byte[] bytes;
switch (handle.StringKind)
{
case StringKind.Virtual:
bytes = Encoding.UTF8.GetBytes(GetVirtualString(handle.GetVirtualIndex()));
break;
case StringKind.WinRTPrefixed:
bytes = GetNonVirtualStringBytes(handle, MetadataReader.WinRTPrefix);
break;
default:
throw ExceptionUtilities.UnexpectedValue(handle.StringKind);
}
virtualBlob = new VirtualHeapBlob(bytes);
heap.Table.Add(handle.RawValue, virtualBlob);
}
}
return virtualBlob.GetMemoryBlock();
}
示例2: 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);
}
示例3: GetVirtualHandleString
private string GetVirtualHandleString(StringHandle handle, MetadataStringDecoder utf8Decoder)
{
Debug.Assert(handle.IsVirtual);
switch (handle.StringKind)
{
case StringKind.Virtual:
return GetVirtualString(handle.GetVirtualIndex());
case StringKind.WinRTPrefixed:
return GetNonVirtualString(handle, utf8Decoder, MetadataReader.WinRTPrefix);
}
throw ExceptionUtilities.UnexpectedValue(handle.StringKind);
}