Example #1
0
        public ICodeLambda Get()
        {
            var type       = new TypeBuilderExtension(null, this.TypeLambda.TypeBuilder);
            var methodAttr = this.TypeLambda.MethodAccessor.MethodAttribute | MethodAttributes.NewSlot | MethodAttributes.Final | MethodAttributes.Virtual | MethodAttributes.SpecialName | MethodAttributes.HideBySig;
            var method     = type.CreateMethod(methodAttr, propertyBuilder.PropertyType, String.Concat("get_", propertyBuilder.Name), Type.EmptyTypes, null, false);

            propertyBuilder.SetGetMethod(method);

            return(new CodeLambda(this.TypeLambda, method.GetILGenerator()));
        }
Example #2
0
        public ICodeLambda Set()
        {
            var type = new TypeBuilderExtension(null, this.TypeLambda.TypeBuilder);

            var methodAttr = this.TypeLambda.MethodAccessor.MethodAttribute | MethodAttributes.NewSlot | MethodAttributes.Final | MethodAttributes.Virtual | MethodAttributes.SpecialName | MethodAttributes.HideBySig;
            var method     = type.CreateMethod(methodAttr, typeof(void), String.Concat("set_", propertyBuilder.Name), new Type[] { propertyBuilder.PropertyType }, null, false);

            method.DefineParameter(1, ParameterAttributes.HasDefault, "value");

            propertyBuilder.SetSetMethod(method);

            return(new CodeLambda(this.TypeLambda, method.GetILGenerator()));
        }