Hey,
On 1/9/08, Liviu U <[EMAIL PROTECTED]> wrote:
> Please, could you post a small sample that created a constructor for a
> new type...?
var attributeType = Import (typeof (Attribute));
var customType = new TypeDefinition ("CecilGeneratedAttribute",
string.Empty, TypeAttributes.Public, attributeType);
var ctor = new MethodDefinition (MethodDefinition.Ctor,
MethodAttributes.Public, Import (typeof (void)));
var cil = ctor.Body.CilWorker;
cil.Emit (OpCodes.Ldarg_0);
cil.Emit (OpCodes.Call, typeof (Attribute).GetConstructor
(BindingFlags.NonPublic | BindingFlags.Instance, null,
Type.EmptyTypes, null));
cil.Emit (OpCods.Ret);
customType.Constructors.Add (ctor);
assembly.CustomAttributes.Add (new CustomAttribute (ctor));
--
Jb Evain <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---