Table of Contents

Class ReflectionOptionPropertyProvider

Namespace
Ubiquity.CommandLineParsing
Assembly
Ubiquity.CommandlineParsing.dll

IOptionPropertyProvider that uses Reflection to find the properties to bind to.

public class ReflectionOptionPropertyProvider : IOptionPropertyProvider
Inheritance
ReflectionOptionPropertyProvider
Implements
Inherited Members
Extension Methods

Constructors

ReflectionOptionPropertyProvider()

Initializes a new instance of the ReflectionOptionPropertyProvider class.

public ReflectionOptionPropertyProvider()

ReflectionOptionPropertyProvider(StringComparer, bool, bool)

Initializes a new instance of the ReflectionOptionPropertyProvider class.

public ReflectionOptionPropertyProvider(StringComparer comparer, bool allowSlash, bool dashesDistinct)

Parameters

comparer StringComparer

String comparer to use when matching the properties with an option.

allowSlash bool

Flag to indicate if "/" is allowed for options.

dashesDistinct bool

Flag to indicate if the "-" and "--" represent distinct short and long namespaces.

Methods

GetPropertyForOption(object, CommandLineOption)

Gets an IOptionProperty for a given instance and option.

public IOptionProperty GetPropertyForOption(object instance, CommandLineOption option)

Parameters

instance object

Object instance the value is to bind to.

option CommandLineOption

Option to bind.

Returns

IOptionProperty

IOptionProperty for the property.

Remarks

This method may obtain the information needed by any means it deems necessary. The ReflectionOptionPropertyProvider uses reflection to lookup the property at runtime. It is conceivable to use some sort of compile time code generation to create type specific providers that would avoid run-time reflection for any scenarios where reflection is deemed to heavy weight. (There isn't any such implementation at this time, but it should be plausible).