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


C# MetadataBuilder.SetCapacity方法代码示例

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


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

示例1: SetCapacity

        public void SetCapacity()
        {
            var builder = new MetadataBuilder();

            builder.GetOrAddString("11111");
            builder.GetOrAddGuid(Guid.NewGuid());
            builder.GetOrAddBlobUTF8("2222");
            builder.GetOrAddUserString("3333");

            builder.AddMethodDefinition(0, 0, default(StringHandle), default(BlobHandle), 0, default(ParameterHandle));
            builder.AddMethodDefinition(0, 0, default(StringHandle), default(BlobHandle), 0, default(ParameterHandle));
            builder.AddMethodDefinition(0, 0, default(StringHandle), default(BlobHandle), 0, default(ParameterHandle));

            builder.SetCapacity(TableIndex.MethodDef, 0);
            builder.SetCapacity(TableIndex.MethodDef, 1);
            builder.SetCapacity(TableIndex.MethodDef, 1000);
            Assert.Throws<ArgumentOutOfRangeException>(() => builder.SetCapacity(TableIndex.MethodDef, -1));
            Assert.Throws<ArgumentOutOfRangeException>(() => builder.SetCapacity((TableIndex)0xff, 10));

            builder.SetCapacity(HeapIndex.String, 3);
            builder.SetCapacity(HeapIndex.String, 1000);
            builder.SetCapacity(HeapIndex.Blob, 3);
            builder.SetCapacity(HeapIndex.Blob, 1000);
            builder.SetCapacity(HeapIndex.Guid, 3);
            builder.SetCapacity(HeapIndex.Guid, 1000);
            builder.SetCapacity(HeapIndex.UserString, 3);
            builder.SetCapacity(HeapIndex.UserString, 1000);
            builder.SetCapacity(HeapIndex.String, 0);
            Assert.Throws<ArgumentOutOfRangeException>(() => builder.SetCapacity(HeapIndex.String, -1));
            Assert.Throws<ArgumentOutOfRangeException>(() => builder.SetCapacity((HeapIndex)0xff, 10));
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:31,代码来源:MetadataBuilderTests.cs


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