Class ListFavoringConstructorQuery

Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll

Selects public constructors ordered so that any constructor with arguments matching IList%601 are selected before any other public constructor.

public class ListFavoringConstructorQuery : IMethodQuery

Inheritance

objectListFavoringConstructorQuery

Implements

IMethodQuery

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Remarks

The main target of this IMethodQuery implementation is to pick IList%7b%600%7d) before any other constructor. This can be used to populate a Collection instance with a list of items.

Constructors

ListFavoringConstructorQuery()

public ListFavoringConstructorQuery()

Methods

SelectMethods(Type)

Selects the constructors for the supplied type.

public IEnumerable<IMethod> SelectMethods(Type type)

Parameters

type Type

The type.

Returns

IEnumerable<IMethod>

All public constructors for type, giving priority to any constructor with one or more IList%601 arguments.

Remarks

Given several constructors, this implementation will favor those constructors with arguments that matches `IList%601`, where T is the item type of type, if it's generic. Constructors with most matching arguments are returned before constructors with less matching arguments.

Any other constructors are returned with the most modest constructors first.

See Also

ListFavoringConstructorQuery