Class ParameterBuilder
Utility for building parameters when invoking a command method.
Inheritance
Implements
Namespace: TehGM.Wolfringo.Commands.Parsing
Assembly: Wolfringo.Commands.dll
Syntax
public class ParameterBuilder : IParameterBuilder
Methods
| Improve this Doc View SourceBuildParamsAsync(IEnumerable<ParameterInfo>, ParameterBuilderValues, CancellationToken)
Builds parameters.
Declaration
public async Task<ParameterBuildingResult> BuildParamsAsync(IEnumerable<ParameterInfo> parameters, ParameterBuilderValues values, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Reflection.ParameterInfo> | parameters | Collection of parameters to be built. |
| ParameterBuilderValues | values | Values to use when building params. |
| System.Threading.CancellationToken | cancellationToken | Cancellation token used to cancel building |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<ParameterBuildingResult> | Result of the parameters building. |
IsParamAssignable(ParameterInfo, Object)
Checks if parameter can be assigned from given object.
Declaration
protected static bool IsParamAssignable(ParameterInfo parameter, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Reflection.ParameterInfo | parameter | The parameter info. |
| System.Object | value | The object to check. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if object can be assigned to given param; otherwise false. |
Remarks
This check does null check in addition to reflection type check.
This method is intended to be internal helper reducing code repetition.
IsParamAssignable(Type, Object)
Checks if parameter can be assigned from given object.
Declaration
protected static bool IsParamAssignable(Type type, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | Type of the parameter. |
| System.Object | value | The object to check. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if object can be assigned to given param; otherwise false. |
Remarks
This check does null check in addition to reflection type check.
This method is intended to be internal helper reducing code repetition.
TryConvertArgument(ParameterInfo, Int32, ParameterBuilderValues, out Object, out Exception)
Attempts to convert argument to parameter type.
Declaration
protected static bool TryConvertArgument(ParameterInfo parameter, int argIndex, ParameterBuilderValues values, out object result, out Exception error)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Reflection.ParameterInfo | parameter | Parameter to convert argument to. |
| System.Int32 | argIndex | Index of argument. |
| ParameterBuilderValues | values | Builder values. Must contain Args and ArgumentConverterProvider. |
| System.Object | result | Result of the conversion. Null if conversion failed. |
| System.Exception | error | Exception that occured when converting. Null if there was no exception. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if converting was successful; otherwise false. |
TryFindAdditional(Type, IEnumerable<Object>, out Object)
Attempts to find an object of specific type from enumerable of objects.
Declaration
protected static bool TryFindAdditional(Type type, IEnumerable<object> additionals, out object result)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | Type of object to find. |
| System.Collections.Generic.IEnumerable<System.Object> | additionals | Enumerable of objects to find from. |
| System.Object | result | Found object. Null if not found. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if object was found successfully; otherwise false. |
TryGetAttribute<T>(ParameterInfo, out T)
Attempts to get an attribute present on the parameter.
Declaration
protected static bool TryGetAttribute<T>(ParameterInfo parameter, out T result)
where T : Attribute
Parameters
| Type | Name | Description |
|---|---|---|
| System.Reflection.ParameterInfo | parameter | |
| T | result |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Type Parameters
| Name | Description |
|---|---|
| T |
TryGetGenericLogger(Type, IServiceProvider, out Object)
Attempts to create a generic ILogger>T<.
Declaration
public static bool TryGetGenericLogger(Type type, IServiceProvider services, out object result)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | Parameter type to create the logger for. |
| System.IServiceProvider | services | Service provider to get logger factory from. |
| System.Object | result | Created logger. Null if failed to create. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if successfully created the logger. Otherwise false. |
TryGetService(Type, IServiceProvider, out Object)
Attempts to find a service of type from service provider.
Declaration
public static bool TryGetService(Type type, IServiceProvider services, out object result)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | Type of service to find. |
| System.IServiceProvider | services | Service provider to get service from. |
| System.Object | result | Found service. Null if not found. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if service was found successfully; otherwise false. |