大佬教程收集整理的这篇文章主要介绍了delphi – 如何在TVirtualInterface TVirtualInterfaceInvokeEvent中获取(Method:TRttiMethod)的所有权属性?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个界面:
IPerson = interface(IInvokablE) ['{45CE428C-F880-4D61-A2C1-0F3CB47130B5}'] procedure SetName(const Value: String); function GetName(): String; [TEntityField('Field Name Here')] property Name: String read GetName write SetName; end;
而这堂课:
type TVirtualEntity<T: IInvokable> = class(TVirtualInterfacE) public constructor Create(); reintroduce; overload; end; constructor TVirtualEntity<T>.Create; begin inherited Create(TypeInfo(T)); Self.onInvoke := procedure(Method: TRttiMethod; const Args: TArray<TValue>; out Result: Tvalue) var attributes: TArray<TCustomAttribute>; attributesmanager: TAttributesmanager; entityFieldAttribute: TEntityField; begin attributesmanager := TAttributesmanager.Create(Method.GetAttributes); try if attributesmanager.HasAttribute<TEntityField>() then begin Result := attributesmanager.GetAttribute<TEntityField>.FieldName; end; finally attributesmanager.Free; end; end; end;
我想获得方法的TRttiProperty:TRttiMethod,但是如何?
如果我将界面更改为:
IPerson = interface(IInvokablE) ['{45CE428C-F880-4D61-A2C1-0F3CB47130B5}'] procedure SetName(const Value: String); [TEntityField('Field Name Here')] function GetName(): String; property Name: String read GetName write SetName; end;
代码工作,但我想用这样的用户界面:
IPerson = interface(IInvokablE) ['{45CE428C-F880-4D61-A2C1-0F3CB47130B5}'] procedure SetName(const Value: String); function GetName(): String; [TEntityField('Field Name Here')] property Name: String read GetName write SetName; end;
以上是大佬教程为你收集整理的delphi – 如何在TVirtualInterface TVirtualInterfaceInvokeEvent中获取(Method:TRttiMethod)的所有权属性?全部内容,希望文章能够帮你解决delphi – 如何在TVirtualInterface TVirtualInterfaceInvokeEvent中获取(Method:TRttiMethod)的所有权属性?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。