A label string with format value tags.
sealed class
|
Label
|
The Grammar of a label is as follows:
label := (text | tag)* ; !tag := '{' '0'..'9'+ expr? '}' ; text := text-char+ ; !expr := expr-choice | expr-plural | expr-singular ; text-char := '{{' | ]{[ ; expr-choice := '>' argument ('|' argument)* ; expr-plural := '?' argument ('|' argument)? ; expr-singular := '!' argument ('|' argument)? ; !argument := (char+ | '#')* ; char := ]}#\\|[ | '\\' [}#\\|] ;Here are some examples:
'Hello
Mr.
Label!'
'Hello
{0}
Label!'
{0}
=
'Ms.'
evaluates
to
'Hello
Ms.
Label!'
'Hello
{0:Mr.|Mrs.|Ms.}
Label!'
{0}
=
'1'
evaluates
to
'Hello
Mrs.
Label!'
'Found
{0:no|one|#}
file{0:s||s}
in
{1:#|one|#}
director{1:ies|y|ies}!'
{0},
{1}
=
'0'
evaluates
to
'Found
no
files
in
0
directories!'
{0},
{1}
=
'1'
evaluates
to
'Found
one
file
in
one
directory!'
{0},
{1}
=
'2'
evaluates
to
'Found
2
files
in
2
directories!'
#
in
a
tag
choice
will
insert
the
tag
value
itself.
'Found
{0!one|#}
file{0?s}
in
{1!one|#}
director{1!y|ies}!'
{0!one|#}
is
the
compact
form
of
{0:#|one|#}
{0!one}
is
the
compact
form
of
{0:|one|}
{0?s|#}
is
the
compact
form
of
{0:s|#|s}
{0?s}
is
the
compact
form
of
{0:s||s}
{0},
{1}
=
'0'
evaluates
to
'Found
0
files
in
0
directories!'
{0},
{1}
=
'1'
evaluates
to
'Found
one
file
in
one
directory!'
{0},
{1}
=
'2'
evaluates
to
'Found
2
files
in
2
directories!'
{{
as
replacement
of
{
||
as
replacement
of
|
}}
as
replacement
of
}
##
as
replacement
of
#
true
:=
1,
false
:=
0
'0'
:=
0,
...
'9'
:=
9
null
:=
0,
1
otherwise.
null
,
empty
and
string
containing
only
whitespace
characters:
0
,
otherwise
1
.
A
label
that
consists
of
a
single
placeholder:
{0}
.
public
static
readonly
field
|
Any
|
||
type
|
Label
|
Formats this label with custom tag values.
public
property
|
Format
{
get
}
|
||
type
|
LabelFormat
|
||
value
|
The label formatter. |
Parses a label.
public
static
method
|
From
(string source)
|
||
type
|
Label
|
||
params
|
source
|
[not-null]
|
The label source code. |
returns
|
|
The parsed label. |
Exceptions:
public
override
method
|
ToString
()
|
||
type
|
string
|