GeneratedRegexAttribute 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指示 System.Text.RegularExpressions 源生成器生成指定正则表达式的实现。
public ref class GeneratedRegexAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property, AllowMultiple=false, Inherited=false)]
public sealed class GeneratedRegexAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)]
public sealed class GeneratedRegexAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property, AllowMultiple=false, Inherited=false)>]
type GeneratedRegexAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)>]
type GeneratedRegexAttribute = class
inherit Attribute
Public NotInheritable Class GeneratedRegexAttribute
Inherits Attribute
- 继承
- 属性
注解
与此特性关联的生成器仅支持 C# 。 它仅在应用于类型为返回 Regex的部分、无参数、非泛型方法或仅获取属性时提供实现。
Regex当支持不区分大小写的匹配(通过传入IgnoreCase或使用模式中的内联(?i)开关)时,正则表达式引擎将使用内部大小写表将传入的模式转换为等效区分大小写的表。 例如,鉴于模式 abc,引擎会将它转换为等效模式 [Aa][Bb][Cc]。 在此内部大小写表中找到的等价值可能会随时间而变化,例如,在新版本的 Unicode 中添加新字符时。 使用源生成器时,此转换在编译时发生,这意味着用于查找等效项的大小写表在编译时将取决于目标框架。 这不同于在运行时执行此转换的 Regex 引擎的其余部分,这意味着它们将始终对当前运行时使用大小写表。
构造函数
| 名称 | 说明 |
|---|---|
| GeneratedRegexAttribute(String, RegexOptions, Int32, String) |
使用指定的模式、选项、超时值和区域性初始化一个新实例 GeneratedRegexAttribute 。 |
| GeneratedRegexAttribute(String, RegexOptions, Int32) |
使用指定的模式、选项和超时值初始化新实例 GeneratedRegexAttribute 。 |
| GeneratedRegexAttribute(String, RegexOptions, String) |
使用指定的模式和选项初始化新实例 GeneratedRegexAttribute 。 |
| GeneratedRegexAttribute(String, RegexOptions) |
使用指定的模式和选项初始化新实例 GeneratedRegexAttribute 。 |
| GeneratedRegexAttribute(String) |
使用指定的模式初始化新实例 GeneratedRegexAttribute 。 |
属性
| 名称 | 说明 |
|---|---|
| CultureName |
获取要用于不区分大小写的比较的区域性的名称。 |
| MatchTimeoutMilliseconds |
获取超时间隔(毫秒),或 Infinite 指示方法不应超时。 |
| Options |
获取修改正则表达式的枚举值的按位组合。 |
| Pattern |
获取要匹配的正则表达式模式。 |
| TypeId |
在派生类中实现时,获取此 Attribute的唯一标识符。 (继承自 Attribute) |
方法
| 名称 | 说明 |
|---|---|
| Equals(Object) |
返回一个值,该值指示此实例是否等于指定对象。 (继承自 Attribute) |
| GetHashCode() |
返回此实例的哈希代码。 (继承自 Attribute) |
| GetType() |
获取当前实例的 Type。 (继承自 Object) |
| IsDefaultAttribute() |
在派生类中重写时,指示此实例的值是否为派生类的默认值。 (继承自 Attribute) |
| Match(Object) |
在派生类中重写时,返回一个值,该值指示此实例是否等于指定对象。 (继承自 Attribute) |
| MemberwiseClone() |
创建当前 Object的浅表副本。 (继承自 Object) |
| ToString() |
返回一个表示当前对象的字符串。 (继承自 Object) |