Example #1
0
 /// <summary>
 /// Implements the <see cref="IMixinObject"/> interface on the mixin type.
 /// </summary>
 /// <param name="typeBuilder">The <see cref="TypeBuilder"/> use to construct the type.</param>
 /// <param name="baseTypeField">The <see cref="FieldBuilder"/> which will hold the instances of the types that make up the mixin.</param>
 private void EmitMixinObjectInterface(
     ITypeBuilder typeBuilder,
     IFieldBuilder baseTypeField)
 {
     var propertyMixinObjects = typeBuilder
                                .NewProperty <object[]>("MixinObjects")
                                .Getter(m => m
                                        .Public()
                                        .Virtual()
                                        .HideBySig()
                                        .NewSlot()
                                        .CallingConvention(CallingConventions.HasThis)
                                        .Body(il => il
                                              .LdArg0()
                                              .LdFld(baseTypeField)
                                              .Ret()));
 }
Example #2
0
 /// <summary>
 /// Implements the <see cref="IDuckTypedObject"/> interface on the duck type.
 /// </summary>
 /// <param name="typeBuilder">The <see cref="TypeBuilder"/> use to construct the type.</param>
 /// <param name="baseTypeField">The <see cref="FieldBuilder"/> which will hold the instance of the type being duck typed.</param>
 private void ImplementDuckTypedObjectInterface(
     ITypeBuilder typeBuilder,
     IFieldBuilder baseTypeField)
 {
     var propertyAdaptedObject = typeBuilder
                                 .NewProperty <object>("DuckTypedObject")
                                 .Getter(m => m
                                         .Public()
                                         .Virtual()
                                         .HideBySig()
                                         .NewSlot()
                                         .CallingConvention(CallingConventions.HasThis)
                                         .Body(il => il
                                               .LdArg0()
                                               .LdFld(baseTypeField)
                                               .Ret()));
 }
Example #3
0
 /// <summary>
 /// Creates a property.
 /// </summary>
 /// <param name="typeBuilder">A type builder.</param>
 /// <param name="propertyName">The name of the property.</param>
 /// <returns>A properrty builder.</returns>
 public static IPropertyBuilder NewProperty <T>(this ITypeBuilder typeBuilder, string propertyName)
 {
     return(typeBuilder.NewProperty(propertyName, typeof(T)));
 }