MDTable.cs :  » Aspect-Oriented-Frameworks » Runtime-Assembly-Instrumentation-Library » Mono » PEToolkit » Metadata » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Aspect Oriented Frameworks » Runtime Assembly Instrumentation Library 
Runtime Assembly Instrumentation Library » Mono » PEToolkit » Metadata » MDTable.cs
/*
 * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>
 */

using System;
using System.IO;
using System.Collections;
using System.Runtime.InteropServices;

namespace Mono.PEToolkit.Metadata{

  public interface MDTable {
    /// <summary>
    /// Number of rows in the table.
    /// </summary>
    int NumberOfRows {get;}

    /// <summary>
    /// Gets ot sets a row in the metadata table.
    /// </summary>
    Row this [int rowNum] {get; set;}

    void Add(Row row);

    void FromRawData(byte [] buff, int offs, int numRows);

    string Name {get;}

    TableId Id {get;}

    MDHeap Heap {get;}

    void Dump(TextWriter writer);
  }


  public abstract class MDTableBase : MDTable {
    protected ArrayList rows; // rows storage
    protected MDHeap heap;    // base heap

    public MDTableBase(MDHeap heap)
    {
      rows = new ArrayList();
      this.heap = heap;

      if (heap is TablesHeap) {
        (heap as TablesHeap).RegisterTable(this);
      }
    }

    public virtual int NumberOfRows {
      get {
        return rows.Count;
      }
    }


    public virtual Row this [int rowNum] {
      get {
        if (rowNum < 0) throw new IndexOutOfRangeException("Row[]");

        // Zero row, special case
        if (rowNum == 0) return NullRow.Instance;
        return rows [rowNum - 1] as Row;
      }
      set {
        rows.Insert(rowNum, value);
      }
    }

    public virtual void Add(Row row)
    {
      rows.Add(row);
    }

    public abstract void FromRawData(byte [] buff, int offs, int numRows);

    public abstract string Name {get;}

    public abstract TableId Id {get;}

    public virtual MDHeap Heap {
      get {
        return heap;
      }
    }

    public virtual void Dump(TextWriter writer)
    {
      writer.WriteLine("=========================================");
      writer.WriteLine("Table '{0}', id = {1} (0x{2}), rows = {3}",
        Name, Id, ((int) Id).ToString("X"), NumberOfRows);
      int n = 1;
      foreach (Row row in rows) {
        writer.WriteLine();
        writer.WriteLine("Row #{0}", n++);
        writer.WriteLine("-------------");
        row.Dump(writer);
        writer.WriteLine();
      }
    }

  }

}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.