当前位置: 首页>>代码示例>>C#>>正文


C# StringHandle.GetHeapOffset方法代码示例

本文整理汇总了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();
开发者ID:ESgarbi,项目名称:corefx,代码行数:9,代码来源:MetadataTokens.cs

示例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);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:9,代码来源:Heaps.cs

示例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());
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:9,代码来源:Heaps.cs

示例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);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:18,代码来源:Heaps.cs

示例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;
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:9,代码来源:Heaps.cs

示例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);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:15,代码来源:Heaps.cs

示例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);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:29,代码来源:Heaps.cs

示例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);
        }
开发者ID:swaroop-sridhar,项目名称:corefx,代码行数:11,代码来源:StringHeap.cs

示例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);
        }
开发者ID:swaroop-sridhar,项目名称:corefx,代码行数:8,代码来源:StringHeap.cs

示例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);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:18,代码来源:Heaps.cs


注:本文中的StringHandle.GetHeapOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。