惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Full Disclosure
博客园 - 聂微东
博客园_首页
人人都是产品经理
人人都是产品经理
N
News | PayPal Newsroom
云风的 BLOG
云风的 BLOG
U
Unit 42
T
Tailwind CSS Blog
Recent Announcements
Recent Announcements
Security Archives - TechRepublic
Security Archives - TechRepublic
T
The Blog of Author Tim Ferriss
Stack Overflow Blog
Stack Overflow Blog
The Register - Security
The Register - Security
The Hacker News
The Hacker News
博客园 - Franky
Engineering at Meta
Engineering at Meta
Jina AI
Jina AI
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
F
Fortinet All Blogs
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
有赞技术团队
有赞技术团队
TaoSecurity Blog
TaoSecurity Blog
博客园 - 司徒正美
GbyAI
GbyAI
G
Google Developers Blog
B
Blog
G
GRAHAM CLULEY
Y
Y Combinator Blog
雷峰网
雷峰网
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
V
V2EX
罗磊的独立博客
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
T
Troy Hunt's Blog
S
SegmentFault 最新的问题
P
Privacy & Cybersecurity Law Blog
T
Threat Research - Cisco Blogs
H
Help Net Security
N
Netflix TechBlog - Medium
Help Net Security
Help Net Security
L
LangChain Blog
D
Docker

博客园 - 云水浮萍

结构体和类中属性定义需要static地方 十万个为什么收集 群里人问的消息切换分页问题,我就标记一下 AnsiString类型定义的时候可以直接指定代码页,比如950繁体字,936日文 CopyMemory Move使用笔记 System.Length 函数 向量定义笔记 关于日期与字符串转换时出错的分隔符,小记一下容易忘记 类型与泛型标记 http://docwiki.embarcadero.com/RADStudio/XE7/en/Delphi_Data_Types Delphi中GUID相等检查中经典指针应用 test是否被执行? 每次看到某个数据结构的时候,有两个指针,一个起始,一个结束,一直没想明白为何是起始与结束,不是起始加数量,是怎么操作的? 给自己一个书单 pureMVC学习之一 泛型与无聊 队列与DelphiXe新语法 猫儿山之行计划书 一个错误,一个教训,关于堆栈平衡 - 云水浮萍 - 博客园
Delphi Helper Record Class
云水浮萍 · 2015-04-02 · via 博客园 - 云水浮萍
unit Unit1;

{$DEFINE USESGUIDHELP}

interface

implementation

{$IFDEF USESGUIDHELP}
uses System.SysUtils;
{$ENDIF}

procedure test;
var
  a:TGUID;//System单元
begin
  {$IFDEF USEGUIDHELP}
  a.NewGuid   //调用System.SysUtils.TGuidHelper
  a.Create()  //调用System.SysUtils.TGuidHelper
  {$ENDIF}
end;

end.
  PGUID = ^TGUID;
  TGUID = packed record
    D1: LongWord;
    D2: Word;
    D3: Word;
    D4: array[0..7] of Byte;
    class operator Equal(const Left, Right: TGUID): Boolean;
    class operator NotEqual(const Left, Right: TGUID): Boolean;
    class function Empty: TGUID; static;
  end;
type
  TGuidHelper = record helper for TGUID
    class function Create(const B: TBytes): TGUID; overload; static;
    class function Create(const S: string): TGUID; overload; static;
    class function Create(A: Integer; B: SmallInt; C: SmallInt; const D: TBytes): TGUID; overload; static;
    class function Create(A: Integer; B: SmallInt; C: SmallInt; D, E, F, G, H, I, J, K: Byte): TGUID; overload; static;
    class function Create(A: Cardinal; B: Word; C: Word; D, E, F, G, H, I, J, K: Byte): TGUID; overload; static;
    class function NewGuid: TGUID; static;
    function ToByteArray: TBytes;
    function ToString: string;
  end;

1、Record不支持继承,使用Helper间接是完成了继承

2、将Record分别在各自的单元(命名空间下),可选择的使用Helper,即可在不影响原调用的情况下,在扩展代码中使用Helper的方法,也可以无需修改原Record或class定义而直接覆盖它们中的方法。