CodeIdentifiers.AddUnique(String, Object) 方法
定义
将命名的代码实体或类型映射添加到 CodeIdentifiers 实例的范围中,确保名称在该范围内是唯一的。Adds a named code entity or type mapping to the CodeIdentifiers instance's scope, ensuring that the name is unique within the scope.
此 API 支持产品基础结构,不能在代码中直接使用。
public:
System::String ^ AddUnique(System::String ^ identifier, System::Object ^ value);
public string AddUnique (string identifier, object? value);
public string AddUnique (string identifier, object value);
member this.AddUnique : string * obj -> string
Public Function AddUnique (identifier As String, value As Object) As String
参数
- identifier
- String
用于对代码实体进行索引的候选名称。A candidate name that is used to index the code entity.
- value
- Object
代码实体或类型映射信息。The code entity or type mapping information.
返回
标识符参数值;如果存在名称冲突,则为修改后的字符串。The identifier parameter value or a modified string if there is a name collision.
注解
如果标识符参数值在 CodeIdentifiers 实例的范围内不唯一,则会生成一个新的唯一字符串,并将其用于位置。If the identifier parameter value is not unique within the CodeIdentifiers instance's scope, a new, unique string is generated and used in its place. 新字符串通过追加到输入名称来生成。The new string is generated by appending to the input name. 如果原始名称以前传递到 Add 、 AddUnique 或 AddReserved 方法,或者它是由之前的方法调用生成的,则该名称不是唯一的 AddUnique 。The original name is not unique if it was passed previously to the Add, AddUnique, or AddReserved method, or if it was generated by a previous call to the AddUnique method. 在每种情况下,如果新标识符不唯一,则首先将它传递给 MakeUnique 方法以创建新的唯一标识符。In each case, if the new identifier is not unique, it is first passed to the MakeUnique method to create a new unique identifier.
如果要控制绑定到 XML 架构或 Web 服务定义的代码实体的名称,请使用关联的属性,而不是创建类的实例 CodeIdentifiers 。If you want to control the names of code entities that are bound to XML Schema or Web service definitions, use the associated attributes rather than creating an instance of the CodeIdentifiers class. 有关完整列表,请参阅 控制 XML 序列化的属性。For a complete list, see Attributes That Control XML Serialization.