How to: Change the Format Used for the FullAddress and FullName Properties 如何:更改用于FullAddress和FullName属性的格式
There are FullAddress and FullName properties in the Address and Person business classes that are supplied with the Business Class Library. These properties are calculable. The FullAddress property represents a string formed by the concatenation of the Country.Name, StateProvince, City, Street and ZipPostal property values. The FullName property is formed by the concatenation of the FirstName, MiddleName and LastName property values. The FullAddress and FullName properties are implemented so that you can change the order in which the items are concatenated. This topic details how to change this order. You can use this technique when implementing analogous business class properties.
地址和人员业务类中随商务舱库一起提供"全地址"和"全名"属性。这些属性是可计算的。FullAddress 属性表示由Country.Name、省、市、街和 ZipPostal 属性值的串联形成的字符串。FullName 属性由"名字"、中间名和姓氏属性值的串联形成。实现"全地址"和"全名"属性,以便可以更改项的串联顺序。本主题详细介绍了如何更改此顺序。在实现类似的 Business 类属性时,可以使用此技术。
The following images demonstrate how the FullAddress and FullName properties are calculated.
下图演示了如何计算全地址和全名属性。
To format FullAddress and FullName properties, the ObjectFormatter.Format method of the helper ObjectFormatter class is used. In this method, the format, according to which the property value is generated, is taken as a parameter. The format passed for the FullAddress property is specified by the Address class' FullAddressFormat property. The format that is passed for the FullName property is specified by the Person class' FullNameFormat property. Note that FullAddress and FullName properties are non-persistent calculated properties. As such, they require persistent aliases to be created for them to support sorting in Server mode (see CollectionSourceBase.DataAccessMode). For this purpose, there are additional FullNamePersistentAlias and FullAddressPersistentAlias properties. These properties are used to create persistent aliases.
要设置全地址和全名属性的格式,使用帮助器对象Formatter类的"对象Formatter.format"方法。在此方法中,生成属性值的格式被视为参数。为 FullAddress 属性传递的格式由地址类的"完全地址格式"属性指定。为 FullName 属性传递的格式由 Person 类的 FullNameFormat 属性指定。请注意,全地址和全名属性是非持久计算属性。因此,它们需要为它们创建持久别名以支持在服务器模式下排序(请参阅 CollectionSourceBase.DataAccessMode)。为此,还有其他全名持久别名和全地址持久别名属性。这些属性用于创建持久别名。
By default, the FullAddressFormat property is set to the Address class' defaultFullAddressFormat constant, which is the following: "{Country.Name}; {StateProvince}; {City}; {Street}; {ZipPostal}". The FullAddressFormatPersistentAlias property is set to the Address class' defaultFullAddressPersistentAlias constant, which is the following: "concat(Country.Name, StateProvince, City, Street, ZipPostal)". To change these property values, use the SetFullAddressFormat method (SetFullNameFormat for the Person class). These methods are static, so you can call them any place in your solution. For instance, you can specify the required format in the configuration file and read its value in a module's constructor. In addition, override the module's ModuleBase.CustomizeTypesInfo method and process the CalculatedPersistentAlias attribute via the static CalculatedPersistentAliasHelper.CustomizeTypesInfo method.
默认情况下,FullAddressFormat 属性设置为地址类的默认 FullAddressFormat 常量,如下所示:[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[Country.Name];[州省];[城市];[街道];[邮递]。""完全地址格式持久别名"属性设置为地址类的默认"完全地址持久别名"常数,如下所示:"concat(国家名称、省、市、街、Zippostal)"。要更改这些属性值,请使用 SetFullAddressFormat 方法(为 Person 类设置全名称格式)。这些方法是静态的,因此您可以调用它们在解决方案中的任何位置。例如,您可以在配置文件中指定所需的格式,并在模块的构造函数中读取其值。此外,重写模块的模块Base.自定义类型信息方法,并通过静态计算持久别名帮助器处理计算持久别名属性。
<configuration>
<appSettings>
<add key="FullAddressFormat" value="{Country.Name} {City} {Street}" />
<add key="FullAddressFormatPersistentAlias" value="concat(Country.Name, City, Street)" />
<!-- ... -->
</appSettings>
</configuration>
using DevExpress.Persistent.BaseImpl;
using System.Configuration;
//...
public sealed partial class MainDemoModule : ModuleBase {
static MainDemoModule() {
Address.SetFullAddressFormat(ConfigurationManager.AppSettings["FullAddressFormat"],
ConfigurationManager.AppSettings["FullAddressFormatPersistentAlias"]);
}
public override void CustomizeTypesInfo(ITypesInfo typesInfo) {
base.CustomizeTypesInfo(typesInfo);
CalculatedPersistentAliasHelper.CustomizeTypesInfo(typesInfo);
}
//...
}
After formatting a FullAddress property using the specified format, the property names that are enclosed in curly brackets will be replaced with the current object's property values (see the image above).
使用指定格式格式化 FullAddress 属性后,用大括号括起来的属性名称将替换为当前对象的属性值(参见上图)。
Analogous to the Address class' FullAddressFormat property, the Person class' FullNameFormat property is set to the defaultFullNameFormat constant, which is the following: "{FirstName} {MiddleName} {LastName}". The FullNamePersistentAlias property is set to the defaultFullNamePersistentAlias constant, which is the following: "concat(FirstName, MiddleName, LastName)". As the SetFullNameFormat method is static, you are free to call it where required. For instance, you can use the value specified in the configuration file as demonstrated in the code above.
与"地址类的 FullAddressFormat"属性类似,Person 类的 FullNameFormat 属性设置为默认的 FullNameFormat 常量,如下所示:"{NameName}{}}}{}}[姓氏][姓氏]"。"FullName 持久别名"属性设置为默认的"完全名称持久别名"常量,如下所示:"concat(名字、中间名、姓氏)"。由于 SetFullNameFormat 方法是静态的,因此您可以根据需要调用它。例如,可以使用配置文件中指定的值,如上面的代码所示。
Note 注意
In the Main Demo, you can set a custom format for the FullName property in the common module's constructor, as described above.
在主演示中,您可以为公共模块的构造函数中的 FullName 属性设置自定义格式,如上所述。
When implementing business class properties whose values require formatting, introduce static properties like FullAddressFormat and FullNameFormat, so that anyone using your business class can modify the formatting. The following code can be used as an example:
实现其值需要格式化的业务部门属性时,请引入静态属性,如 FullAddressFormat 和 FullNameFormat,以便使用业务类的任何人都可以修改格式。以下代码可用作示例:
public class SampleAddress : BaseObject {
private const string defaultFullAddressFormat = "{Country.Name}; {StateProvince};" +
" {City}; {Street}; {ZipPostal}";
private static string fullAddressFormat = defaultFullAddressFormat;
public static string FullAddressFormat {
get { return fullAddressFormat; }
set {
fullAddressFormat = value;
if(string.IsNullOrEmpty(fullAddressFormat)) {
fullAddressFormat = defaultFullAddressFormat;
}
}
}
public string FullAddress {
get {
return ObjectFormatter.Format(fullAddressFormat, this,
EmptyEntriesMode.RemoveDelimiterWhenEntryIsEmpty );
}
}
}
How to: Change the Format Used for the FullAddress and FullName Properties 如何:更改用于FullAddress和FullName属性的格式的更多相关文章
- [No0000149]ReSharper操作指南6/16-编码协助之其他协助
语法高亮 ReSharper扩展了默认Visual Studio的符号高亮显示.此外,它还会使用可配置的颜色突出显示字段,局部变量,类型和其他标识符.例如,ReSharper语法突出显示允许您轻松区分 ...
- PersistentAliasAttribute & CalculatedAttribute & CalculatedPersistentAliasAttribute
一,PersistentAliasAttribute-[XPO提供] Indicates that a property is not persistent and its value is calc ...
- RHCSA阶段笔记
命令终端字段含义介绍 [root@localhost ~]# 解释: root:当前登录系统用户名(root超级管理员) localhost :当前主机名 :当前用户所在目录( 为家目录) ,root ...
- 2、粘包现象(struct模块)
昨天我们所做的套接字是有漏洞的,它会出现粘包现象,没有发现这个问题的我们今天会进行演示.今天也会稍微讲解一下基于udp的套接字. 一.基于udp的套接字 udp是无链接的,先启动哪一端都不会报错 ud ...
- 29、粘包现象(struct模块)
昨天我们所做的套接字是有漏洞的,它会出现粘包现象,没有发现这个问题的我们今天会进行演示.今天也会稍微讲解一下基于udp的套接字. 本篇导航: 基于udp的套接字 粘包现象 粘包 解决粘包方法 stru ...
- MFC学习小结
2019/1/13 视频来源 一. MFC框架中一些重要的函数 1. InitInstance函数 应用程序类的一个虚函数,MFC应用程序的入口.初始化的作用. 2. PreCreateWindo ...
- 2019/12/10学习内容摘要(Linux文件和目录管理)
1.绝对路径和相对路径 *绝对路径:路径的写法一定是由根目录 / 写起的,例如 /usr/local/mysql *相对路径:路径的写法不是由根目录 / 写起的,例如 首先用户进入到 /home,然后 ...
- linux-RHEL7.0 —— 《Linux就该这么学》阅读笔记
目录 linux-RHEL7.0 安装部署 修改root密码 RPM(红帽软件包管理器) YUM(软件仓库) Systemd初始化进程 总结 linux命令 帮助命令 man 系统工作命令 echo ...
- Commit message 和 Change log 编写指南
来源:http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html Git 每次提交代码,都要写 Commit messa ...
随机推荐
- 一条数据的HBase之旅,简明HBase入门教程1:开篇
[摘要] 这是HBase入门系列的第1篇文章,主要介绍HBase当前的项目活跃度以及搜索引擎热度信息,以及一些概况信息,内容基于HBase 2.0 beta2版本.本系列文章既适用于HBase新手,也 ...
- Selenium 4 Java的最佳测试框架
几十年来,Java一直是开发应用程序服务器端的首选编程语言.尽管JUnit一直在与开发人员一起帮助他们进行自动化的单元测试,但随着时间的推移和测试行业的发展,特别是伴随着自动化测试的兴起,已经开发了许 ...
- luogu P1582 倒水 |数学
题目描述 一天,CC买了N个容量可以认为是无限大的瓶子,开始时每个瓶子里有1升水.接着~~CC发现瓶子实在太多了,于是他决定保留不超过K个瓶子.每次他选择两个当前含水量相同的瓶子,把一个瓶子的水全部倒 ...
- luogu P1768 天路 |01分数规划+负环
题目描述 言归正传,小X的梦中,他在西藏开了一家大型旅游公司,现在,他要为西藏的各个景点设计一组铁路线.但是,小X发现,来旅游的游客都很挑剔,他们乘火车在各个景点间游览,景点的趣味当然是不用说啦,关键 ...
- Word表格斜线怎么弄?这里有三种方法很实用
有些时候我们也会在Word文档中插入表格,因为这样可以准确的表达出文档中的内容.大家应该都知道Excel表格斜线怎么弄,那么Word表格斜线怎么弄吗?今天呢小编就帮大家总结了三种方法哦,有需要的小伙伴 ...
- Java修炼——多维数组
二维数组就是存储一维数组(内存地址/引用)的数组 二维数组的实始化 1) int intA[][]={{1,2},{2,3},{3,4,5}}; 2) int [][] intB=new int[3] ...
- 2019 牛客国庆集训派对day1-C Distinct Substrings(exkmp+概率)
链接:https://ac.nowcoder.com/acm/contest/1099/C来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...
- Spring Cloud第八篇 | Hystrix集群监控Turbine
本文是Spring Cloud专栏的第八篇文章,了解前七篇文章内容有助于更好的理解本文: Spring Cloud第一篇 | Spring Cloud前言及其常用组件介绍概览 Spring Clo ...
- NET视频教程分享
地址:链接:https://pan.baidu.com/s/1q47WN1XFw19vLZ8XZqnB_g 提取码:8ut2 这是我收集的一套.NET学习视频教程(某智24期视频),分享出来, ...
- Jquery判断当前时PC端,移动端,平板端屏幕
$(function(){ // console.log(navigator.userAgent); var os = function (){ var ua = navi ...