C# Class CK.Text.StringMatcherTextExtension

Extends StringMatcher with useful (yet basic) methods.
Exibir arquivo Open project: Invenietis/ck-core

Public Properties

Property Type Description
RegexDouble System.Text.RegularExpressions.Regex

Public Methods

Method Description
MatchInt32 ( this @this, int &i, int minValue = int.MinValue, int maxValue = int.MaxValue ) : bool

Matches Int32 values that must not start with '0' ('0' is valid but '0d', where d is any digit, is not). A signed integer starts with a '-'. '-0' is valid but '-0d' (where d is any digit) is not. If the value is to big for an Int32, it fails.

TryMatchDoubleValue ( this @this ) : bool

Matches a double without getting its value nor setting an error if match fails. This uses RegexDouble.

TryMatchDoubleValue ( this @this, double &value ) : bool

Matches a double and gets its value. No error is set if match fails.

TryMatchGuid ( this @this, System.Guid &id ) : bool

Matches a Guid. No error is set if match fails.

Any of the 5 forms of Guid can be matched: N00000000000000000000000000000000 D00000000-0000-0000-0000-000000000000 B{00000000-0000-0000-0000-000000000000} P(00000000-0000-0000-0000-000000000000) X{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}

TryMatchJSONQuotedString ( this @this, bool allowNull = false ) : bool

Matches a quoted string without extracting its content.

TryMatchJSONQuotedString ( this @this, string &content, bool allowNull = false ) : bool

Matches a JSON quoted string without setting an error if match fails.

TryMatchJSONTerminalValue ( this @this ) : bool

Matches a JSON value: a "string", null, a number (double value), true or false. This method ignores the actual value and does not set any error if match fails.

TryMatchJSONValue ( this @this, object &value ) : bool

Matches a JSON value: a "string", null, a number (double value), true or false. Not error is set if match fails.

Private Methods

Method Description
ReadHexDigit ( char c ) : int

Method Details

MatchInt32() public static method

Matches Int32 values that must not start with '0' ('0' is valid but '0d', where d is any digit, is not). A signed integer starts with a '-'. '-0' is valid but '-0d' (where d is any digit) is not. If the value is to big for an Int32, it fails.
public static MatchInt32 ( this @this, int &i, int minValue = int.MinValue, int maxValue = int.MaxValue ) : bool
@this this
i int The result integer. 0 on failure.
minValue int Optional minimal value.
maxValue int Optional maximal value.
return bool

TryMatchDoubleValue() public static method

Matches a double without getting its value nor setting an error if match fails. This uses RegexDouble.
public static TryMatchDoubleValue ( this @this ) : bool
@this this
return bool

TryMatchDoubleValue() public static method

Matches a double and gets its value. No error is set if match fails.
public static TryMatchDoubleValue ( this @this, double &value ) : bool
@this this
value double The read value on success.
return bool

TryMatchGuid() public static method

Matches a Guid. No error is set if match fails.
Any of the 5 forms of Guid can be matched: N00000000000000000000000000000000 D00000000-0000-0000-0000-000000000000 B{00000000-0000-0000-0000-000000000000} P(00000000-0000-0000-0000-000000000000) X{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}
public static TryMatchGuid ( this @this, System.Guid &id ) : bool
@this this
id System.Guid The result Guid. on failure.
return bool

TryMatchJSONQuotedString() public static method

Matches a quoted string without extracting its content.
public static TryMatchJSONQuotedString ( this @this, bool allowNull = false ) : bool
@this this
allowNull bool True to allow 'null'.
return bool

TryMatchJSONQuotedString() public static method

Matches a JSON quoted string without setting an error if match fails.
public static TryMatchJSONQuotedString ( this @this, string &content, bool allowNull = false ) : bool
@this this
content string Extracted content.
allowNull bool True to allow 'null'.
return bool

TryMatchJSONTerminalValue() public static method

Matches a JSON value: a "string", null, a number (double value), true or false. This method ignores the actual value and does not set any error if match fails.
public static TryMatchJSONTerminalValue ( this @this ) : bool
@this this
return bool

TryMatchJSONValue() public static method

Matches a JSON value: a "string", null, a number (double value), true or false. Not error is set if match fails.
public static TryMatchJSONValue ( this @this, object &value ) : bool
@this this
value object The parsed value. Can be null.
return bool

Property Details

RegexDouble static_oe public_oe property

The Regex that TryMatchDoubleValue(StringMatcher) uses to avoid calling double.TryParse(string, out double) when resolving the value is useless.
static public Regex,System.Text.RegularExpressions RegexDouble
return System.Text.RegularExpressions.Regex