GeneratedRegexAttribute 类

定义

指示 System.Text.RegularExpressions 源生成器生成指定正则表达式的实现。

public ref class GeneratedRegexAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)]
public sealed class GeneratedRegexAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false, Inherited=false)>]
type GeneratedRegexAttribute = class
    inherit Attribute
Public NotInheritable Class GeneratedRegexAttribute
Inherits Attribute
继承
GeneratedRegexAttribute
属性

注解

与此特性关联的生成器仅支持 C#。 它仅在应用于类型化为返回 Regex的部分、无参数的非泛型方法时提供实现。

Regex当 支持不区分大小写的匹配 (通过传递IgnoreCase或使用模式中的内联 “ (?i) ” 开关) 正则表达式引擎将使用内部大小写表将传入的模式转换为区分大小写的等效模式。 例如,给定模式“abc”,引擎会将其转换为等效模式“[Aa][Bb][Cc]”。 在此内部大小写表中找到的等效性可能会随时间而更改,例如,在将新字符添加到新版本的 Unicode 时。 使用源生成器时,此转换在编译时发生,这意味着用于查找等效项的大小写表将取决于编译时的目标框架。 这不同于其他 Regex 引擎,后者在运行时执行此转换,这意味着它们将始终对当前运行时使用大小写表。

构造函数

GeneratedRegexAttribute(String)

使用指定的模式初始化 的新 GeneratedRegexAttribute 实例。

GeneratedRegexAttribute(String, RegexOptions)

使用指定的模式和选项初始化 的新实例 GeneratedRegexAttribute

GeneratedRegexAttribute(String, RegexOptions, Int32)

使用指定的模式、选项和超时值初始化 的新实例 GeneratedRegexAttribute

GeneratedRegexAttribute(String, RegexOptions, Int32, String)

使用指定的模式、选项、超时值和区域性初始化 的新实例 GeneratedRegexAttribute

GeneratedRegexAttribute(String, RegexOptions, 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)

适用于