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


C# MetadataBuilder类代码示例

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


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

示例1: CreateDebugWriter

 public static ImageWriter CreateDebugWriter(ModuleDefinition module, MetadataBuilder metadata, Disposable<Stream> stream)
 {
     var writer = new ImageWriter (module, "PDB V1.0", metadata, stream, metadataOnly: true);
     var length = metadata.text_map.GetLength ();
     writer.text = new Section { SizeOfRawData = length, VirtualSize = length };
     return writer;
 }
开发者ID:jbevain,项目名称:cecil,代码行数:7,代码来源:ImageWriter.cs

示例2: Ctor_Errors

        public void Ctor_Errors()
        {
            var mdBuilder = new MetadataBuilder();

            Assert.Throws<ArgumentNullException>(() => new PortablePdbBuilder(null, MetadataRootBuilder.EmptyRowCounts, default(MethodDefinitionHandle)));
            Assert.Throws<ArgumentNullException>(() => new PortablePdbBuilder(mdBuilder, default(ImmutableArray<int>), default(MethodDefinitionHandle)));

            var rowCounts = new int[128];
            rowCounts[64] = 1;
            Assert.Throws<ArgumentException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));

            rowCounts = new int[64];
            rowCounts[63] = 1;
            Assert.Throws<ArgumentException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));

            rowCounts = new int[64];
            rowCounts[(int)TableIndex.EventPtr] = 1;
            Assert.Throws<ArgumentException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));

            rowCounts = new int[64];
            rowCounts[(int)TableIndex.CustomDebugInformation] = 1;
            Assert.Throws<ArgumentException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));

            rowCounts = new int[64];
            rowCounts[(int)TableIndex.MethodDef] = -1;
            Assert.Throws<ArgumentOutOfRangeException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));

            rowCounts = new int[64];
            rowCounts[(int)TableIndex.GenericParamConstraint] = 0x01000000;
            Assert.Throws<ArgumentOutOfRangeException>(() => new PortablePdbBuilder(mdBuilder, ImmutableArray.Create(rowCounts), default(MethodDefinitionHandle)));
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:31,代码来源:PortablePdbBuilderTests.cs

示例3: Ctor_Errors

        public void Ctor_Errors()
        {
            var mdBuilder = new MetadataBuilder();

            Assert.Throws<ArgumentNullException>(() => new MetadataRootBuilder(null));
            Assert.Throws<ArgumentException>(() => new MetadataRootBuilder(mdBuilder, new string('x', 255)));
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:7,代码来源:MetadataRootBuilderTests.cs

示例4: NetTextBuilder

        public NetTextBuilder(ImageNetDirectory directory)
        {
            _directory = directory;

            ImportBuilder = new ImageImportDirectoryBuilder(directory.Assembly, directory.Assembly.ImportDirectory);

            Segments.Add(ImportBuilder.AddressTablesBuilder);
            Segments.Add(directory);
            Segments.Add(MethodBodyTableBuilder = new MethodBodyTableBuilder());
            Segments.Add(NetResourceDirectoryBuilder = new NetResourceDirectoryBuilder());
            Segments.Add(DataBuilder = new NetDataTableBuilder());

            if (directory.StrongNameData != null)
                Segments.Add(directory.StrongNameData);

            Segments.Add(Metadata = new MetadataBuilder(directory.MetadataHeader));

            if (directory.Assembly.DebugDirectory != null)
            {
                Segments.Add(directory.Assembly.DebugDirectory);
                Segments.Add(directory.Assembly.DebugDirectory.Data);
            }

            Segments.Add(ImportBuilder);
            Segments.Add(StartupCode = new StartupCodeSegmentBuilder());
        }
开发者ID:JerreS,项目名称:AsmResolver,代码行数:26,代码来源:NetTextBuilder.cs

示例5: CodeWriter

		public CodeWriter (MetadataBuilder metadata)
			: base (0)
		{
			this.code_base = metadata.text_map.GetNextRVA (TextSegment.CLIHeader);
			this.current = code_base;
			this.metadata = metadata;
			this.standalone_signatures = new Dictionary<uint, MetadataToken> ();
		}
开发者ID:mayuki,项目名称:Inazuma,代码行数:8,代码来源:CodeWriter.cs

示例6: Serialize_Errors

        public void Serialize_Errors()
        {
            var mdBuilder = new MetadataBuilder();
            var pdbBuilder = new PortablePdbBuilder(mdBuilder, MetadataRootBuilder.EmptyRowCounts, default(MethodDefinitionHandle));
            var builder = new BlobBuilder();

            Assert.Throws<ArgumentNullException>(() => pdbBuilder.Serialize(null));
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:8,代码来源:PortablePdbBuilderTests.cs

示例7: Serialize_Errors

        public void Serialize_Errors()
        {
            var mdBuilder = new MetadataBuilder();
            var rootBuilder = new MetadataRootBuilder(mdBuilder);
            var builder = new BlobBuilder();

            Assert.Throws<ArgumentNullException>(() => rootBuilder.Serialize(null, 0, 0));
            Assert.Throws<ArgumentOutOfRangeException>(() => rootBuilder.Serialize(builder, -1, 0));
            Assert.Throws<ArgumentOutOfRangeException>(() => rootBuilder.Serialize(builder, 0, -1));
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:10,代码来源:MetadataRootBuilderTests.cs

示例8: ImageWriter

 ImageWriter(ModuleDefinition module, MetadataBuilder metadata, Stream stream)
     : base(stream)
 {
     this.module = module;
     this.metadata = metadata;
     this.GetDebugHeader ();
     this.GetWin32Resources ();
     this.text_map = BuildTextMap ();
     this.sections = 2; // text + reloc
     this.pe64 = module.Architecture != TargetArchitecture.I386;
     this.time_stamp = (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds;
 }
开发者ID:sillsdev,项目名称:mono-basic,代码行数:12,代码来源:ImageWriter.cs

示例9: BuildMetadata

 public static void BuildMetadata(MetadataBuilder<MainViewModel> builder) {
     builder.Property(x => x.FirstName)
         .Required(() => "Please enter the first name.");
     builder.Property(x => x.LastName)
         .Required(() => "Please enter the last name.");
     builder.Property(x => x.Email)
         .EmailAddressDataType(() => "Please enter a correct email address.");
     AddPasswordCheck(builder.Property(x => x.Password))
         .Required(() => "Please enter the password.");
     AddPasswordCheck(builder.Property(x => x.ConfirmPassword))
         .Required(() => "Please confirm the password.");
 }
开发者ID:ruisebastiao,项目名称:DevExpress.Mvvm.Free,代码行数:12,代码来源:MainViewModel.cs

示例10: Complex

        public void Complex()
        {
            using (var peStream = new MemoryStream())
            {
                var ilBuilder = new BlobBuilder();
                var metadataBuilder = new MetadataBuilder();
                var entryPoint = ComplexEmit(metadataBuilder, ilBuilder);

                WritePEImage(peStream, metadataBuilder, ilBuilder, entryPoint);

                // peStream.Position = 0;
                // File.WriteAllBytes(@"c:\temp\test.dll", peStream.ToArray());
            }
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:14,代码来源:PEBuilderTests.cs

示例11: BasicValidation

        public void BasicValidation()
        {
            using (var peStream = new MemoryStream())
            {
                var ilBuilder = new BlobBuilder();
                var metadataBuilder = new MetadataBuilder();
                var entryPoint = BasicValidationEmit(metadataBuilder, ilBuilder);
                WritePEImage(peStream, metadataBuilder, ilBuilder, entryPoint);

                peStream.Position = 0;
                var r = new PEReader(peStream);
                var h = r.PEHeaders;
                var mdReader = r.GetMetadataReader();
            }
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:15,代码来源:PEBuilderTests.cs

示例12: ImageWriter

        ImageWriter(ModuleDefinition module, string runtime_version, MetadataBuilder metadata, Disposable<Stream> stream, bool metadataOnly = false)
            : base(stream.value)
        {
            this.module = module;
            this.runtime_version = runtime_version;
            this.text_map = metadata.text_map;
            this.stream = stream;
            this.metadata = metadata;
            if (metadataOnly)
                return;

            this.pe64 = module.Architecture == TargetArchitecture.AMD64 || module.Architecture == TargetArchitecture.IA64;
            this.has_reloc = module.Architecture == TargetArchitecture.I386;
            this.GetDebugHeader ();
            this.GetWin32Resources ();
            this.BuildTextMap ();
            this.sections = (ushort) (has_reloc ? 2 : 1); // text + reloc?
        }
开发者ID:jbevain,项目名称:cecil,代码行数:18,代码来源:ImageWriter.cs

示例13: PatchRawSection

		void PatchRawSection (ByteBuffer buffer, MetadataBuilder metadata)
		{
			var position = base.position;
			Align (4);
			buffer.WriteBytes (base.position - position);

			const byte fat_format = 0x40;
			const byte more_sects = 0x80;

			var flags = ReadByte ();
			if ((flags & fat_format) == 0) {
				buffer.WriteByte (flags);
				PatchRawSmallSection (buffer, metadata);
			} else
				PatchRawFatSection (buffer, metadata);

			if ((flags & more_sects) != 0)
				PatchRawSection (buffer, metadata);
		}
开发者ID:mayuki,项目名称:Inazuma,代码行数:19,代码来源:CodeReader.cs

示例14: PatchRawSmallSection

		void PatchRawSmallSection (ByteBuffer buffer, MetadataBuilder metadata)
		{
			var length = ReadByte ();
			buffer.WriteByte (length);
			Advance (2);

			buffer.WriteUInt16 (0);

			var count = length / 12;

			PatchRawExceptionHandlers (buffer, metadata, count, false);
		}
开发者ID:mayuki,项目名称:Inazuma,代码行数:12,代码来源:CodeReader.cs

示例15: ValidateNestedClassTable

        public void ValidateNestedClassTable()
        {
            var builder = new MetadataBuilder();
            builder.AddNestedType(MetadataTokens.TypeDefinitionHandle(2), default(TypeDefinitionHandle));
            builder.AddNestedType(MetadataTokens.TypeDefinitionHandle(1), default(TypeDefinitionHandle));
            Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());

            builder = new MetadataBuilder();
            builder.AddNestedType(MetadataTokens.TypeDefinitionHandle(1), default(TypeDefinitionHandle));
            builder.AddNestedType(MetadataTokens.TypeDefinitionHandle(1), default(TypeDefinitionHandle));
            Assert.Throws<InvalidOperationException>(() => builder.ValidateOrder());
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:12,代码来源:MetadataBuilderTests.cs


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