MetaDataDispenserEx.cs :  » Development » devAdvantage » AnticipatingMinds » PlatformServices » UnmanagedReflection » 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 » Development » devAdvantage 
devAdvantage » AnticipatingMinds » PlatformServices » UnmanagedReflection » MetaDataDispenserEx.cs
using System;
using System.Runtime.InteropServices;

namespace AnticipatingMinds.PlatformServices.UnmanagedReflection{
  /// <summary>Wrapper for the IMetaDataDispenserEx COM unmanaged API</summary>
  /// <remarks>The methods on this class are documented in the Metadata Unmanaged API document in the SDK Tool Developers Guide</remarks> 
  /// <example>
  /// <code>
  /// IMetaDataDispenserEx dispenser=new MetaDataDispenserEx();
  /// IMetaDataImport impScope=null;
  /// object rawScope=null;
  /// Guid iidImp=Constants.IID_IMetaDataImport;
  /// dispenser.OpenScope("bytecode.exe",0,ref iidImp,out rawScope);
  /// impScope=(IMetaDataImport)rawScope;
  /// </code>
  /// </example>
  [ComImport,GuidAttribute("31BCFCE2-DAFB-11D2-9F81-00C04F79A0A3"),InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  public interface IMetaDataDispenserEx 
  { 

    // IMPORTANT: Order of methods in this interface is SIGNIFICANT

    /// <summary>Define a new metadata scope</summary>
    /// <param name="rclsid">A Guid representing Constants.CLSID_CorMetaDataRuntime.ToByteArray();</param>
    /// <param name="flags">Always pass 0</param>
    /// <param name="iid">A GUID for the required interface, one of IID_IMetaDataEmit, IID_IMetadataImport, IID_IMetaDataAssemblyEmit or IID_IMetadataAssemblyImport</param>
    /// <param name="scope">Output parameter which will be initialised to the new scope. Should be cast to the interface specified in <paramref name="iid"/></param>
    /// <returns>The HRESULT from the COM method</returns>
    int DefineScope(ref Guid rclsid,uint flags,ref Guid iid,[MarshalAs(UnmanagedType.Interface)] out object scope);    

    /// <summary>Open a metadata scope on an existing assembly file</summary>
    /// <param name="file">A fully qualified file name of an assembly</param>
    /// <param name="flags">0 for read, 1 for write</param>
    /// <param name="iid">GUID for the required interface, one of IID_IMetaDataEmit, IID_IMetadataImport, IID_IMetaDataAssemblyEmit or IID_IMetadataAssemblyImport</param>
    /// <param name="scope">Output parameter which will be initialised to the new scope. Should be cast to the interface specified in <paramref name="iid"/></param>
    /// <returns>The HRESULT from the COM method</returns>
    int OpenScope([MarshalAs(UnmanagedType.LPWStr)] string file,uint flags,ref Guid iid,[MarshalAs(UnmanagedType.Interface)] out Object scope);

    /// <summary>Open a metadata scope on an existing set of metadata mapped into memory</summary>
    /// <param name="data">The bytes of the assembly (i.e. base address of a mapped assembly dll file)</param>
    /// <param name="size">Count of bytes in <paramref name="data"/></param>
    /// <param name="flags">0 for read, 1 for write</param>
    /// <param name="iid">GUID for the required interface, one of IID_IMetaDataEmit, IID_IMetadataImport, IID_IMetaDataAssemblyEmit or IID_IMetadataAssemblyImport</param>
    /// <param name="scope">Output parameter which will be initialised to the new scope. Should be cast to the interface specified in <paramref name="iid"/></param>
    /// <returns>The HRESULT from the COM method</returns>
    int OpenScopeOnMemory(IntPtr data,uint size,uint flags,ref Guid iid,[MarshalAs(UnmanagedType.Interface)] out object scope);

    /// <summary>Set an option for the metadata API behaviour</summary>
    /// <param name="iid">GUID for the metadata option to set</param>
    /// <param name="optValue">Option specific variant data. Note that this object must be convertable to a variant according to the rules in the topic "Default Marshaling for Objects" in the SDK help</param>
    /// <returns>The HRESULT from the COM method</returns>
    int SetOption(ref Guid iid,[MarshalAs(UnmanagedType.Struct)] object optValue);

    /// <summary>Get an option for the metadata API behaviour</summary>
    /// <param name="iid">GUID for the metadata option to set</param>
    /// <param name="optValue">Option specific variant data. Note that this object must be convertable to a variant according to the rules in the topic "Default Marshaling for Objects" in the SDK help</param>
    /// <returns>The HRESULT from the COM method</returns>
    int GetOption(ref Guid iid,[MarshalAs(UnmanagedType.Struct)] out object optValue);

    /// <summary>Open a metadata scope on an object description from a COM type library (I think)</summary>
    /// <param name="info">A COM ITypeInfo interface pointer for a type in a type library</param>
    /// <param name="flags">0 for read, 1 for write</param>
    /// <param name="iid">GUID for the required interface, one of IID_IMetaDataEmit, IID_IMetadataImport, IID_IMetaDataAssemblyEmit or IID_IMetadataAssemblyImport</param>
    /// <param name="scope">Output parameter which will be initialised to the new scope. Should be cast to the interface specified in <paramref name="iid"/></param>
    /// <returns>The HRESULT from the COM method</returns>
    int OpenScopeOnITypeInfo([MarshalAs(UnmanagedType.Interface)] UCOMITypeInfo info,uint flags,ref Guid iid,[MarshalAs(UnmanagedType.Interface)] out object scope);

    /// <summary>Get the system directory for the CIL Runtime</summary>
    /// <param name="dir">A char buffer big enough to hold the longest result</param>
    /// <param name="size">Size of the buffer <paramref name="dir"/></param>
    /// <param name="count">Number of chars written into <paramref name="dir"/> or number of required chars if larger than <paramref name="size"/></param>
    /// <returns>The HRESULT from the COM method</returns>
    int GetCORSystemDirectory([MarshalAs(UnmanagedType.LPArray,SizeParamIndex=1)] char[] dir,int size,out int count);

    /// <summary>Find the best match for an assembly using the rules from the CIL Runtime</summary>
    /// <returns>The HRESULT from the COM method</returns>
    int FindAssembly([MarshalAs(UnmanagedType.LPWStr)] string appBase,[MarshalAs(UnmanagedType.LPWStr)] string privBin,[MarshalAs(UnmanagedType.LPWStr)] string globalBin,[MarshalAs(UnmanagedType.LPWStr)] string name,[MarshalAs(UnmanagedType.LPArray,SizeParamIndex=5)] char[] nameOut,int buffSize,out int nameLen);

    /// <summary>Find the best match for an assembly module using the rules from the CIL Runtime</summary>
    /// <returns>The HRESULT from the COM method</returns>
    int FindAssemblyModule([MarshalAs(UnmanagedType.LPWStr)] string appBase,[MarshalAs(UnmanagedType.LPWStr)] string privBin,[MarshalAs(UnmanagedType.LPWStr)] string globalBin,[MarshalAs(UnmanagedType.LPWStr)] string name,[MarshalAs(UnmanagedType.LPArray,SizeParamIndex=5)]char[] nameOut,int buffSize,out int nameLen);    
  }

  /// <summary>Alternate interface for IMetaDataDispenserEx. tlbimp.exe creates these, I don't know why so I copied it</summary>
  /// <remarks>The GUID may be incorrect on this interface</remarks>
  [ComImport,GuidAttribute("31BCFCE2-DAFB-11D2-9F81-00C04F79A0A3"),CoClass(typeof(MetaDataDispenserExClass))]
  public interface MetaDataDispenserEx: IMetaDataDispenserEx 
  {
  }

  /// <summary>Co class for the MetadataDispenserEx interface</summary>
  [ComImport,GuidAttribute("E5CB7A31-7512-11D2-89CE-0080C792E5D8")]
  public class MetaDataDispenserExClass 
  {
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.