Wolfringo Wolfringo
Wolfringo Wolfringo
Wolfringo (c) 2020 TehGM
DocFX, DiscordFX theme.
Search Results for

    Class ParameterBuilder

    Utility for building parameters when invoking a command method.

    Inheritance
    System.Object
    ParameterBuilder
    Implements
    IParameterBuilder
    Namespace: TehGM.Wolfringo.Commands.Parsing
    Assembly: Wolfringo.Commands.dll
    Syntax
    public class ParameterBuilder : IParameterBuilder

    Methods

    | Improve this Doc View Source

    BuildParamsAsync(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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    Implements

    IParameterBuilder