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
-
ObjectParserFactory
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 System.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 System.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 System.String.
Returns
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 System.String.
Returns
- IParser<TResult>
An IParser<TResult> implementation.
Type Parameters
TResult
The type of the converted result.
FromBase64()
Creates a parser that converts a System.String, represented in base-64 digits, to its equivalent byte[].
public static IParser<byte[]> FromBase64()
Returns
- IParser<Byte[]>
An IConfigurableParser{byte[]} implementation.
Exceptions
- System.ArgumentNullException
System.String cannot be null.
- System.FormatException
System.String consist of illegal base-64 digits.
FromBinaryDigits()
Creates a parser that converts a System.String, represented in binary digits, to its equivalent byte[].
public static IParser<byte[]> FromBinaryDigits()
Returns
- IParser<Byte[]>
An IConfigurableParser{byte[]} implementation.
Exceptions
- System.ArgumentNullException
System.String cannot be null.
- ArgumentException
System.String cannot be empty or consist only of white-space characters.
- System.FormatException
System.String must consist only of binary digits.
FromEnum()
Creates a parser that converts a System.String to its equivalent System.Enum.
public static IConfigurableParser<EnumStringOptions> FromEnum()
Returns
- IConfigurableParser<EnumStringOptions>
An IConfigurableParser{EnumStringOptions} implementation.
Exceptions
- System.ArgumentNullException
System.String cannot be null -or- System.Type cannot be null.
- ArgumentException
System.String cannot be empty or consist only of white-space characters -or- System.Type does not represents an enumeration.
- System.OverflowException
System.String is outside the range of the underlying type of System.Type.
- System.InvalidOperationException
System.String is not type SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, or UInt64, or String.
FromGuid()
Creates a parser that converts a System.String to its equivalent System.Guid.
public static IConfigurableParser<Guid, GuidStringOptions> FromGuid()
Returns
- IConfigurableParser<Guid, GuidStringOptions>
An IConfigurableParser{Guid,GuidStringOptions} implementation.
Exceptions
- System.ArgumentNullException
System.String cannot be null.
- ArgumentException
System.String cannot be empty or consist only of white-space characters.
- System.FormatException
System.String was not recognized to be a GUID.
- See Also
-
System.Guid.Parse(System.String)System.Guid.ParseExact(System.String,System.String)
FromHexadecimal()
Creates a parser that converts a System.String, represented in hexadecimal digits, to its equivalent byte[].
public static IParser<byte[]> FromHexadecimal()
Returns
- IParser<Byte[]>
An IConfigurableParser{byte[]} implementation.
Exceptions
- System.ArgumentNullException
System.String cannot be null.
- ArgumentException
System.String must be hexadecimal.
FromObject()
Creates a parser that converts a System.String to an System.Object of a particular type.
public static IConfigurableParser<ObjectFormattingOptions> FromObject()
Returns
- IConfigurableParser<ObjectFormattingOptions>
An IConfigurableParser{ObjectFormattingOptions} implementation.
Remarks
If the underlying System.IFormatProvider of
Exceptions
- System.NotSupportedException
System.String cannot be converted to the specified System.Type.
FromProtocolRelativeUri()
Creates a parser that converts a System.String, represented as a protocol relative URL, to its equivalent System.Uri.
public static IConfigurableParser<Uri, ProtocolRelativeUriStringOptions> FromProtocolRelativeUri()
Returns
- IConfigurableParser<Uri, ProtocolRelativeUriStringOptions>
An IConfigurableParser{Uri,UriStringOptions} implementation.
Exceptions
- System.ArgumentNullException
System.String cannot be null.
- ArgumentException
System.String cannot be empty or consist only of white-space characters.
FromUri()
Creates a parser that converts a System.String, represented as an URL, to its equivalent System.Uri.
public static IConfigurableParser<Uri, UriStringOptions> FromUri()
Returns
- IConfigurableParser<Uri, UriStringOptions>
An IConfigurableParser{Uri,UriStringOptions} implementation.
Exceptions
- System.ArgumentNullException
System.String cannot be null.
- ArgumentException
System.String cannot be empty or consist only of white-space characters.
FromUriScheme()
Creates a parser that converts a System.String, represented as an URI scheme, to its equivalent UriScheme.
public static IParser<UriScheme> FromUriScheme()
Returns
Exceptions
- System.ArgumentNullException
System.String cannot be null.
- ArgumentException
System.String cannot be empty or consist only of white-space characters.
FromUrlEncodedBase64()
Creates a parser that converts a System.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
- System.ArgumentNullException
System.String cannot be null.
- ArgumentException
System.String cannot be empty or consist only of white-space characters.
- System.FormatException
System.String consist of illegal base-64 digits.
FromValueType()
Creates a parser that converts a System.String, represented as a simple input type, to its equivalent System.Boolean, System.Byte, System.Int32, System.Int64, System.Double, System.Single, System.DateTime or System.Guid.
public static IConfigurableParser<object, FormattingOptions> FromValueType()
Returns
- IConfigurableParser<Object, FormattingOptions>
An IConfigurableParser{object,FormattingOptions} implementation.