TypeWrappers

TypeWrappers in Geny are managed by the TypeWrapper GenYrator. It locates actual typewrappers by using MEF, and calls them one by one with a number of types, defined by filters we'll get to in a little bit.

The Typewrapper comes with its own xml based file format with the extension ".tw". Using these files you can filter out types, namespaces and members to wrap. Typewrapper files are just xml that look like this:

<TypeWrapper>
  <Name-of-wrapper>
    <Include>
      <Namespace Name="ConsoleApplication14"/>
      <Type Name="System.Windows.Controls.Primitives.ButtonBase ">
        <IncludeMember Name="Click">
      </Type>
    </Include>
  </Name-of-wrapper>
</TypeWrapper>

The Name-of-wrapper is the name that MEF uses to identify this perticular typewrapper. The Include and Exclude(not shown) element and Include/ExcludeMember elements define what types and members are sent to the wrapper. If any IncludeMember element is present for a perticular type, only those members will be sent to the typewrapper, if no such elements are present, all members for that type will be included, except for those defined in ExcludeMember elements.

Another thing to note is that inheirited members are not included for each type since this would result in alot of redundant methods.

Some time in the future i'll make a proper xsd and a vs item template, but right now, Geny must be manually applied as a custom tool to .tw files.

A typewrapper file can contain any number of <Name-of-Wrapper> elements. Each of them will be invoked and get their own output file.

Creating your own typewrapper

Creating a type wrapper is quite easy. Simply implement the ITypeWrapper interface and apply the Typewrapper attribute to a class, place it in the TypeWrapper directory and your type wrapper will get picked up. The type wrapper framework will take care of filtering and only call your typewrapper with the relevant types and members. it will also find and load all the assemblies the project references. it also creates an appdomin for assembly loading and code generation and unloads it when generation is complete.

Last edited Nov 27, 2009 at 1:49 PM by aL3891, version 7

Comments

No comments yet.