public virtual void AddIPropertyDescriptorImplementation() { if (this.ImplementInterface(typeof(Interfaces.IPropertyDescriptor)) == false) { return; } { var method = this.TypeBuilder.DefineMethod("GetAllPropertyTypes", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig, typeof(Type[]), new Type[] { }); var il = method.GetILGenerator(); var overrideMethod = typeof(Interfaces.IPropertyDescriptor).GetMethod("GetAllPropertyTypes"); if (overrideMethod == null) { throw new Exception("Can not find Method 'GetAllPropertyTypes' in interface."); } var helper = new Helper.ILEmitter(this.TypeBuilder, this, il); var allProperties = Properties.Select(s => s.Type).ToArray(); helper.EmitGetTypeArrayMethodIL(il, allProperties); TypeBuilder.DefineMethodOverride(method, overrideMethod); } { var method = this.TypeBuilder.DefineMethod("GetAllPropertyNames", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig, typeof(string[]), new Type[] { }); var il = method.GetILGenerator(); var overrideMethod = typeof(Interfaces.IPropertyDescriptor).GetMethod("GetAllPropertyNames"); if (overrideMethod == null) { throw new Exception("Can not find Method 'GetAllPropertyNames' in interface."); } var helper = new Helper.ILEmitter(this.TypeBuilder, this, il); var allProperties = Properties.Select(s => s.Name).ToArray(); helper.EmitGetStringArrayMethodIL(il, allProperties); TypeBuilder.DefineMethodOverride(method, overrideMethod); } }