Class ParserFactory
Provides access to factory methods that are tailored for parsing operations adhering IParser and IConfigurableParser<TOptions>.
Namespace: Cuemon.Text
Assembly: Cuemon.Core.dll
Syntax
public static class ParserFactory
Methods
| Improve this Doc View SourceCreateConfigurableParser<TOptions>(Func<String, Type, Action<TOptions>, Object>)
Creates an IConfigurableParser<TOptions> implementation from the specified parser
.
Declaration
public static IConfigurableParser<TOptions> CreateConfigurableParser<TOptions>(Func<string, Type, Action<TOptions>, object> parser)
where TOptions : class, IParameterObject, new()
Parameters
Type | Name | Description |
---|---|---|
Func<String, Type, Action<TOptions>, Object> | parser | The function delegate that does the actual parsing of a String. |
Returns
Type | Description |
---|---|
IConfigurableParser<TOptions> | An IConfigurableParser<TOptions> implementation. |
Type Parameters
Name | Description |
---|---|
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
.
Declaration
public static IConfigurableParser<TResult, TOptions> CreateConfigurableParser<TResult, TOptions>(Func<string, Action<TOptions>, TResult> parser)
where TOptions : class, IParameterObject, new()
Parameters
Type | Name | Description |
---|---|---|
Func<String, Action<TOptions>, TResult> | parser | The function delegate that does the actual parsing of a String. |
Returns
Type | Description |
---|---|
IConfigurableParser<TResult, TOptions> | An IConfigurableParser<TResult, TOptions> implementation. |
Type Parameters
Name | Description |
---|---|
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
.
Declaration
public static IParser CreateParser(Func<string, Type, object> parser)
Parameters
Type | Name | Description |
---|---|---|
Func<String, Type, Object> | parser | The function delegate that does the actual parsing of a String. |
Returns
Type | Description |
---|---|
IParser | An IParser implementation. |
CreateParser<TResult>(Func<String, TResult>)
Creates an IParser<TResult> implementation from the specified parser
.
Declaration
public static IParser<TResult> CreateParser<TResult>(Func<string, TResult> parser)
Parameters
Type | Name | Description |
---|---|---|
Func<String, TResult> | parser | The function delegate that does the actual parsing of a String. |
Returns
Type | Description |
---|---|
IParser<TResult> | An IParser<TResult> implementation. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the converted result. |
FromBase64()
Creates a parser that converts a String, represented in base-64 digits, to its equivalent byte[].
Declaration
public static IParser<byte[]> FromBase64()
Returns
Type | Description |
---|---|
IParser<Byte[]> | An IConfigurableParser{byte[]} implementation. |
Exceptions
Type | Condition |
---|---|
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[].
Declaration
public static IParser<byte[]> FromBinaryDigits()
Returns
Type | Description |
---|---|
IParser<Byte[]> | An IConfigurableParser{byte[]} implementation. |
Exceptions
Type | Condition |
---|---|
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()
Declaration
public static IConfigurableParser<EnumStringOptions> FromEnum()
Returns
Type | Description |
---|---|
IConfigurableParser<EnumStringOptions> | An IConfigurableParser{EnumStringOptions} implementation. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | |
ArgumentException | String cannot be empty or consist only of white-space characters -or- Type does not represents an enumeration. |
OverflowException | |
InvalidOperationException | String is not type SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, or UInt64, or String. |
FromGuid()
Declaration
public static IConfigurableParser<Guid, GuidStringOptions> FromGuid()
Returns
Type | Description |
---|---|
IConfigurableParser<Guid, GuidStringOptions> | An IConfigurableParser{Guid,GuidStringOptions} implementation. |
Exceptions
Type | Condition |
---|---|
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
| Improve this Doc View SourceFromHexadecimal()
Creates a parser that converts a String, represented in hexadecimal digits, to its equivalent byte[].
Declaration
public static IParser<byte[]> FromHexadecimal()
Returns
Type | Description |
---|---|
IParser<Byte[]> | An IConfigurableParser{byte[]} implementation. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | String cannot be null. |
ArgumentException | String must be hexadecimal. |
FromObject()
Declaration
public static IConfigurableParser<ObjectFormattingOptions> FromObject()
Returns
Type | Description |
---|---|
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
Type | Condition |
---|---|
NotSupportedException |
FromProtocolRelativeUri()
Creates a parser that converts a String, represented as a protocol relative URL, to its equivalent Uri.
Declaration
public static IConfigurableParser<Uri, ProtocolRelativeUriStringOptions> FromProtocolRelativeUri()
Returns
Type | Description |
---|---|
IConfigurableParser<Uri, ProtocolRelativeUriStringOptions> | An IConfigurableParser{Uri,UriStringOptions} implementation. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | String cannot be null. |
ArgumentException | String cannot be empty or consist only of white-space characters. |
FromUri()
Declaration
public static IConfigurableParser<Uri, UriStringOptions> FromUri()
Returns
Type | Description |
---|---|
IConfigurableParser<Uri, UriStringOptions> | An IConfigurableParser{Uri,UriStringOptions} implementation. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | String cannot be null. |
ArgumentException | String cannot be empty or consist only of white-space characters. |
FromUriScheme()
Declaration
public static IParser<UriScheme> FromUriScheme()
Returns
Type | Description |
---|---|
IParser<UriScheme> | An IConfigurableParser{UriScheme} implementation. |
Exceptions
Type | Condition |
---|---|
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[].
Declaration
public static IParser<byte[]> FromUrlEncodedBase64()
Returns
Type | Description |
---|---|
IParser<Byte[]> | An IConfigurableParser{byte[]} implementation. |
Exceptions
Type | Condition |
---|---|
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.
Declaration
public static IConfigurableParser<object, FormattingOptions<CultureInfo>> FromValueType()
Returns
Type | Description |
---|---|
IConfigurableParser<Object, FormattingOptions<CultureInfo>> | An IConfigurableParser{object,FormattingOptions{CultureInfo}} implementation. |