UriTemplateTable.MakeReadOnly(Boolean) 方法

定义

UriTemplateTable 设置为只读。Makes the UriTemplateTable read only.

public:
 void MakeReadOnly(bool allowDuplicateEquivalentUriTemplates);
public void MakeReadOnly (bool allowDuplicateEquivalentUriTemplates);
member this.MakeReadOnly : bool -> unit
Public Sub MakeReadOnly (allowDuplicateEquivalentUriTemplates As Boolean)

参数

allowDuplicateEquivalentUriTemplates
Boolean

指定是否允许 UriTemplate 中有重复的等效 UriTemplateTable 实例。Specifies whether to allow duplicate equivalent UriTemplate instances in the UriTemplateTable.

注解

调用 MakeReadOnly(Boolean) 方法时,会发生下列其中一种验证类型:When the MakeReadOnly(Boolean) method is called, one of the following types of validation occurs:

  • 如果在调用 MakeReadOnly(Boolean) 时传入 false,则 UriTemplateTable 会检查以确保表中没有多个结构等效的模板。When MakeReadOnly(Boolean) is called passing in false, the UriTemplateTable checks to make sure the table contains no multiple structurally-equivalent templates. 如果找到这样的模板,则会引发异常。If it finds such templates, an exception is thrown. 如果想要确保只有一个模板与传入的 URI 匹配,则可将此验证类型与 MatchSingle(Uri) 结合使用。This type of validation is used in conjunction with MatchSingle(Uri) when you want to ensure only one template matches an incoming URI.

  • 如果在调用 MakeReadOnly(Boolean) 时传入 true,则 UriTemplateTable 中可能包含多个结构等效的模板。When MakeReadOnly(Boolean) is called passing in true, multiple structurally-equivalent templates can be contained within a UriTemplateTable. 但是,模板中的所有查询字符串必须无歧义;您可以使用相同的查询字符串。However, any query strings in the templates must not be ambiguous; identical query strings are allowed. 如果允许有多个模板与候选 URI 匹配,则可将此验证类型与 Match(Uri) 结合使用。This type of validation is used in conjunction with Match(Uri) when multiple template matches are allowed on the candidate URI.

系统只接受对 MakeReadOnly(Boolean) 的首次调用,而会忽略后续调用,且不引发任何异常。Only the first call to MakeReadOnly(Boolean) is honored, subsequent calls are ignored without any exception being thrown.

适用于