Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的情况。我有一个包含字符串数据的数据库。我正在实现本质上是“class.method”格式的令牌来实现动态数据生成。
例如,列的数据可能是:'Hotel $(Generate.GUID)'
其中 Generate 是我创建的类,GUID 是该类的方法。
为了将数据库数据保持在最低限度,我想给这样的调用起别名:'Hotel $(g.guid)'
我想避免使用其他短名称方法更改类。我正在寻找一种简洁的流线型方式来设置它。
产生最干净代码和最易读的方法是保留全名。有时,那一点额外的数据是值得的。
另一种方法是有一个映射表
Full Short --------------- Generate g GUID guid
然后:
Hotel $(g.guid)
然后,在代码中,您可以在启动期间或任何时候将此表读入内存,或者(更易读、更容易出错的选项)也可以在代码中定义此映射。