Table of Contents

Class OperationFeature

Namespace
Gve.Text
Assembly
Gve.Text.dll

A feature attached to a text variant generation operation. This adds metadata to the feature to drive its application to the operation context.

public record OperationFeature : Feature, IEquatable<Feature>, IEquatable<OperationFeature>
Inheritance
OperationFeature
Implements
Inherited Members

Constructors

OperationFeature(string, string?, FeatureSetPolicy, bool, bool, bool)

Initializes a new instance of the OperationFeature class.

public OperationFeature(string name, string? value, FeatureSetPolicy setPolicy = FeatureSetPolicy.Multiple, bool isNegated = false, bool isGlobal = false, bool isShortLived = false)

Parameters

name string

The name.

value string

The value.

setPolicy FeatureSetPolicy

The set policy.

isNegated bool

if set to true is negated.

isGlobal bool

if set to true is global.

isShortLived bool

if set to true is short-lived.

Exceptions

ArgumentNullException

name

Properties

IsGlobal

Gets a value indicating whether this feature globally refers to the operation context as a whole, rather than to its affected nodes.

public bool IsGlobal { get; init; }

Property Value

bool

IsNegated

Gets or sets a value indicating whether this feature is negated. A negated feature means that any existing feature with the same name should be removed.

public bool IsNegated { get; init; }

Property Value

bool

IsShortLived

Gets or sets a value indicating whether this instance is short-lived. When true, the feature is removed on the next update.

public bool IsShortLived { get; init; }

Property Value

bool

Methods

Parse(string)

Parses the specified text representing a feature, with syntax name=value or name="value", where = can be replaced by := for a single feature or by == for a single-first feature. When value is null, the text just contains the feature name.

public static OperationFeature Parse(string text)

Parameters

text string

The text.

Returns

OperationFeature

Feature.

Exceptions

ArgumentNullException

text

FormatException

Invalid feature

ToString()

Converts to a parsable string with format !NAME^=VALUE where !=negated, =global, and operator is = for multiple, := for single, and == for single-first. Value is enclosed in double quotes if it contains white spaces. Suffix ^ is used for short-lived features.

public override string ToString()

Returns

string

A string that represents this instance.

TryParse(string, out OperationFeature?)

Tries parsing the specified feature.

public static bool TryParse(string text, out OperationFeature? feature)

Parameters

text string

The text representing the feature.

feature OperationFeature

The feature.

Returns

bool

True if success.

Exceptions

ArgumentNullException

text

UpdateFeature(OperationFeature, IList<OperationFeature>, bool)

Updates targets features with source feature. If source is negated, the feature is removed from targets; otherwise, it is added or updated, handling existing features with the same name according to the source set policy.

public static void UpdateFeature(OperationFeature source, IList<OperationFeature> targets, bool first)

Parameters

source OperationFeature

The source feature.

targets IList<OperationFeature>

The target features.

first bool

True if source is the first feature being added with that name in the context of a features set update.

Exceptions

ArgumentNullException

source or targets

See Also