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


C# StringBuffer.CopyFrom方法代码示例

本文整理汇总了C#中System.Runtime.InteropServices.StringBuffer.CopyFrom方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuffer.CopyFrom方法的具体用法?C# StringBuffer.CopyFrom怎么用?C# StringBuffer.CopyFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Runtime.InteropServices.StringBuffer的用法示例。


在下文中一共展示了StringBuffer.CopyFrom方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetInputBuffer

        private static ulong GetInputBuffer(StringBuffer content, bool isUnc, out StringBuffer buffer)
        {
            ulong length = content.Length;
            length += isUnc ? (ulong)PathInternal.UncExtendedPrefixToInsert.Length : (ulong)PathInternal.ExtendedPathPrefix.Length;
            buffer = new StringBuffer(length);

            if (isUnc)
            {
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.UncExtendedPathPrefix);
                ulong prefixDifference = (ulong)(PathInternal.UncExtendedPathPrefix.Length - PathInternal.UncPathPrefix.Length);
                content.CopyTo(bufferIndex: prefixDifference, destination: buffer, destinationIndex: (ulong)PathInternal.ExtendedPathPrefix.Length, count: content.Length - prefixDifference);
                return prefixDifference;
            }
            else
            {
                ulong prefixSize = (ulong)PathInternal.ExtendedPathPrefix.Length;
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.ExtendedPathPrefix);
                content.CopyTo(bufferIndex: 0, destination: buffer, destinationIndex: prefixSize, count: content.Length);
                return prefixSize;
            }
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:21,代码来源:PathHelper.Windows.cs

示例2: GetInputBuffer

        private static uint GetInputBuffer(StringBuffer content, bool isDosUnc, out StringBuffer buffer)
        {
            uint length = content.Length;

            length += isDosUnc
                ? (uint)PathInternal.UncExtendedPrefixLength - PathInternal.UncPrefixLength
                : PathInternal.DevicePrefixLength;

            buffer = new StringBuffer(length);

            if (isDosUnc)
            {
                // Put the extended UNC prefix (\\?\UNC\) in front of the path
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.UncExtendedPathPrefix);

                // Copy the source buffer over after the existing UNC prefix
                content.CopyTo(
                    bufferIndex: PathInternal.UncPrefixLength,
                    destination: buffer,
                    destinationIndex: PathInternal.UncExtendedPrefixLength,
                    count: content.Length - PathInternal.UncPrefixLength);

                // Return the prefix difference
                return (uint)PathInternal.UncExtendedPrefixLength - PathInternal.UncPrefixLength;
            }
            else
            {
                uint prefixSize = (uint)PathInternal.ExtendedPathPrefix.Length;
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.ExtendedPathPrefix);
                content.CopyTo(bufferIndex: 0, destination: buffer, destinationIndex: prefixSize, count: content.Length);
                return prefixSize;
            }
        }
开发者ID:nietras,项目名称:coreclr,代码行数:33,代码来源:LongPathHelper.cs

示例3: CopyFromStringThrowsIndexingBeyondStringLength

 public void CopyFromStringThrowsIndexingBeyondStringLength(string value, int index, int count)
 {
     using (var buffer = new StringBuffer())
     {
         Assert.Throws<ArgumentOutOfRangeException>(() => { buffer.CopyFrom(0, value, index, count); });
     }
 }
开发者ID:rajeevkb,项目名称:corefx,代码行数:7,代码来源:StringBufferTests.cs

示例4: CopyFromStringThrowsIndexingBeyondBufferLength

 public void CopyFromStringThrowsIndexingBeyondBufferLength()
 {
     using (var buffer = new StringBuffer())
     {
         Assert.Throws<ArgumentOutOfRangeException>(() => { buffer.CopyFrom(1, ""); });
     }
 }
开发者ID:rajeevkb,项目名称:corefx,代码行数:7,代码来源:StringBufferTests.cs

示例5: CopyFromStringThrowsOnNull

 public void CopyFromStringThrowsOnNull()
 {
     using (var buffer = new StringBuffer())
     {
         Assert.Throws<ArgumentNullException>(() => { buffer.CopyFrom(0, null); });
     }
 }
开发者ID:rajeevkb,项目名称:corefx,代码行数:7,代码来源:StringBufferTests.cs

示例6: CopyFromString

 public void CopyFromString(string content, string source, ulong bufferIndex, int sourceIndex, int count, string expected)
 {
     using (var buffer = new StringBuffer(content))
     {
         buffer.CopyFrom(bufferIndex, source, sourceIndex, count);
         Assert.Equal(expected, buffer.ToString());
     }
 }
开发者ID:rajeevkb,项目名称:corefx,代码行数:8,代码来源:StringBufferTests.cs


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