Table of Contents

Class ParserFactory

Namespace
Cuemon.Text
Assembly
Cuemon.Core.dll

Provides access to factory methods that are tailored for parsing operations adhering IParser and IConfigurableParser<TOptions>.

public static class ParserFactory
Inheritance
ParserFactory

Methods

CreateConfigurableParser<TOptions>(Func<String, Type, Action<TOptions>, Object>)

Creates an IConfigurableParser<TOptions> implementation from the specified parser.

public static IConfigurableParser<TOptions> CreateConfigurableParser<TOptions>(Func<string, Type, Action<TOptions>, object> parser)
    where TOptions : class, IParameterObject, new()

Parameters

parser Func<String, Type, Action<TOptions>, Object>

The function delegate that does the actual parsing of a String.

Returns

IConfigurableParser<TOptions>

An IConfigurableParser<TOptions> implementation.

Type Parameters

TOptions

The type of the delegate setup.

CreateConfigurableParser<TResult, TOptions>(Func<String, Action<TOptions>, TResult>)

Creates an IConfigurableParser<TResult, TOptions> implementation from the specified parser.

public static IConfigurableParser<TResult, TOptions> CreateConfigurableParser<TResult, TOptions>(Func<string, Action<TOptions>, TResult> parser)
    where TOptions : class, IParameterObject, new()

Parameters

parser Func<String, Action<TOptions>, TResult>

The function delegate that does the actual parsing of a String.

Returns

IConfigurableParser<TResult, TOptions>

An IConfigurableParser<TResult, TOptions> implementation.

Type Parameters

TResult

The type of the converted result.

TOptions

The type of the delegate setup.

CreateParser(Func<String, Type, Object>)

Creates an IParser implementation from the specified parser.

public static IParser CreateParser(Func<string, Type, object> parser)

Parameters

parser Func<String, Type, Object>

The function delegate that does the actual parsing of a String.

Returns

IParser

An IParser implementation.

CreateParser<TResult>(Func<String, TResult>)

Creates an IParser<TResult> implementation from the specified parser.

public static IParser<TResult> CreateParser<TResult>(Func<string, TResult> parser)

Parameters

parser Func<String, TResult>

The function delegate that does the actual parsing of a String.

Returns

IParser<TResult>

An IParser<TResult> implementation.

Type Parameters

TResult

The type of the converted result.

FromBase64()

Creates a parser that converts a String, represented in base-64 digits, to its equivalent byte[].

public static IParser<byte[]> FromBase64()

Returns

IParser<Byte[]>

An IConfigurableParser{byte[]} implementation.

Exceptions

ArgumentNullException

String cannot be null.

FormatException

String consist of illegal base-64 digits.

FromBinaryDigits()

Creates a parser that converts a String, represented in binary digits, to its equivalent byte[].

public static IParser<byte[]> FromBinaryDigits()

Returns

IParser<Byte[]>

An IConfigurableParser{byte[]} implementation.

Exceptions

ArgumentNullException

String cannot be null.

ArgumentException

String cannot be empty or consist only of white-space characters.

FormatException

String must consist only of binary digits.

FromEnum()

Creates a parser that converts a String to its equivalent Enum.

public static IConfigurableParser<EnumStringOptions> FromEnum()

Returns

IConfigurableParser<EnumStringOptions>

An IConfigurableParser{EnumStringOptions} implementation.

Exceptions

ArgumentNullException

String cannot be null -or- Type cannot be null.

ArgumentException

String cannot be empty or consist only of white-space characters -or- Type does not represents an enumeration.

OverflowException

String is outside the range of the underlying type of Type.

InvalidOperationException

String is not type SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, or UInt64, or String.

FromGuid()

Creates a parser that converts a String to its equivalent Guid.

public static IConfigurableParser<Guid, GuidStringOptions> FromGuid()

Returns

IConfigurableParser<Guid, GuidStringOptions>

An IConfigurableParser{Guid,GuidStringOptions} implementation.

Exceptions

ArgumentNullException

String cannot be null.

ArgumentException

String cannot be empty or consist only of white-space characters.

FormatException

String was not recognized to be a GUID.

See Also

FromHexadecimal()

Creates a parser that converts a String, represented in hexadecimal digits, to its equivalent byte[].

public static IParser<byte[]> FromHexadecimal()

Returns

IParser<Byte[]>

An IConfigurableParser{byte[]} implementation.

Exceptions

ArgumentNullException

String cannot be null.

ArgumentException

String must be hexadecimal.

FromObject()

Creates a parser that converts a String to an Object of a particular type.

public static IConfigurableParser<ObjectFormattingOptions> FromObject()

Returns

IConfigurableParser<ObjectFormattingOptions>

An IConfigurableParser{ObjectFormattingOptions} implementation.

Remarks

If the underlying IFormatProvider of FormatProvider is a CultureInfo, then this will be used in the conversion.

Exceptions

NotSupportedException

String cannot be converted to the specified Type.

FromProtocolRelativeUri()

Creates a parser that converts a String, represented as a protocol relative URL, to its equivalent Uri.

public static IConfigurableParser<Uri, ProtocolRelativeUriStringOptions> FromProtocolRelativeUri()

Returns

IConfigurableParser<Uri, ProtocolRelativeUriStringOptions>

An IConfigurableParser{Uri,UriStringOptions} implementation.

Exceptions

ArgumentNullException

String cannot be null.

ArgumentException

String cannot be empty or consist only of white-space characters.

FromUri()

Creates a parser that converts a String, represented as an URL, to its equivalent Uri.

public static IConfigurableParser<Uri, UriStringOptions> FromUri()

Returns

IConfigurableParser<Uri, UriStringOptions>

An IConfigurableParser{Uri,UriStringOptions} implementation.

Exceptions

ArgumentNullException

String cannot be null.

ArgumentException

String cannot be empty or consist only of white-space characters.

FromUriScheme()

Creates a parser that converts a String, represented as an URI scheme, to its equivalent UriScheme.

public static IParser<UriScheme> FromUriScheme()

Returns

IParser<UriScheme>

An IConfigurableParser{UriScheme} implementation.

Exceptions

ArgumentNullException

String cannot be null.

ArgumentException

String cannot be empty or consist only of white-space characters.

FromUrlEncodedBase64()

Creates a parser that converts a String, represented in URL-safe base-64 digits, to its equivalent byte[].

public static IParser<byte[]> FromUrlEncodedBase64()

Returns

IParser<Byte[]>

An IConfigurableParser{byte[]} implementation.

Exceptions

ArgumentNullException

String cannot be null.

ArgumentException

String cannot be empty or consist only of white-space characters.

FormatException

String consist of illegal base-64 digits.

FromValueType()

Creates a parser that converts a String, represented as a simple input type, to its equivalent Boolean, Byte, Int32, Int64, Double, Single, DateTime or Guid.

public static IConfigurableParser<object, FormattingOptions> FromValueType()

Returns

IConfigurableParser<Object, FormattingOptions>

An IConfigurableParser{object,FormattingOptions} implementation.