Class MethodCtorInfo
A validated candidate for object instantiation, wrapping a A validated candidate for object instantiation, wrapping a ConstructorInfo or static MethodInfo.
public class MethodCtorInfo
- Inheritance
-
MethodCtorInfo
- Inherited Members
- Extension Methods
Constructors
MethodCtorInfo(MethodBase)
Initializes a new instance of MethodCtorInfo.
public MethodCtorInfo(MethodBase MethodBase)
Parameters
MethodBaseMethodBaseThe constructor or method to wrap.
Exceptions
- Exception
Thrown if validation fails.
MethodCtorInfo(MethodBase, ParamInfo[])
Initializes a new instance of MethodCtorInfo.
public MethodCtorInfo(MethodBase MethodBase, ParamInfo[] Parameters)
Parameters
MethodBaseMethodBaseThe constructor or method to wrap.
ParametersParamInfo[]The matchers for the method parameters.
Exceptions
- Exception
Thrown if validation fails.
MethodCtorInfo(MethodBase, ParamInfo[], AdditionalFlags)
Initializes a new instance of MethodCtorInfo with explicit member-completion control.
public MethodCtorInfo(MethodBase MethodBase, ParamInfo[] Parameters, MethodCtorInfo.AdditionalFlags Flags)
Parameters
MethodBaseMethodBaseThe constructor or method to wrap.
ParametersParamInfo[]The matchers for the method parameters.
FlagsMethodCtorInfo.AdditionalFlagsThe additional flags.
Fields
MethodBase
The constructor or static method used for instantiation.
public readonly MethodBase MethodBase
Field Value
Parameters
The matchers for each parameter in the method signature.
public readonly ParamInfo[] Parameters
Field Value
Properties
CanCompleteWithMembers
Gets whether properties and fields may be filled after construction.
public bool CanCompleteWithMembers { get; }
Property Value
Flags
Flags indicating additional info used in various situations
public MethodCtorInfo.AdditionalFlags Flags { get; set; }
Property Value
GroupKey
The first grouping rule tried for this construction. Returning no boundary allows the type rule or inference. null starts with the type rule. Attribute rules are read once.
public IGroupingRule? GroupKey { get; set; }
Property Value
ParametersAreReadable
Automatically registers the parameter types if they are not already registered.
public bool ParametersAreReadable { get; }
Property Value
RegistrationInitializer
Adjusts each construction path produced by TryNew(MethodBase, out MethodCtorInfo) before automatic registration can publish it. Return the received path after changing it or return a replacement. Configure this once during application startup. Direct construction does not invoke it.
public static Func<MethodCtorInfo, MethodCtorInfo>? RegistrationInitializer { get; set; }
Property Value
TargetType
Resolves the type that this method/constructor produces.
public Type TargetType { get; }
Property Value
Methods
GetOrderedInfos(Span<MethodCtorInfo>)
Orders construction candidates from the most specific to the least specific.
public static MethodCtorInfo[] GetOrderedInfos(Span<MethodCtorInfo> infos)
Parameters
infosSpan<MethodCtorInfo>
Returns
InsertInto(ref MethodCtorInfo[])
Adds or replaces this candidate in a list ordered from the most specific choice to the least specific.
public void InsertInto(ref MethodCtorInfo[] infos)
Parameters
infosMethodCtorInfo[]The candidate list to update.
IsMoreSpecific(MethodCtorInfo)
Determines if this candidate is more specific (takes precedence) than another. Precedence is based on parameter count and type assignment compatibility.
public bool IsMoreSpecific(MethodCtorInfo info)
Parameters
infoMethodCtorInfo
Returns
IsSameSignature(MethodCtorInfo)
Compares signatures to determine if two candidates are functionally identical.
public bool IsSameSignature(MethodCtorInfo b)
Parameters
Returns
ToString()
Provides a string representation of the method signature for debugging.
public override string ToString()
Returns
TryMakeParameters(MethodBase)
Automatically generates default matchers for all parameters of a method.
public static ParamInfo[]? TryMakeParameters(MethodBase methodBase)
Parameters
methodBaseMethodBase
Returns
- ParamInfo[]
An array of matchers, or null if any parameter is invalid.
TryNew(MethodBase, out MethodCtorInfo)
Attempts to create a new MethodCtorInfo, returning false if validation fails.
public static bool TryNew(MethodBase MethodBase, out MethodCtorInfo mci)
Parameters
MethodBaseMethodBasemciMethodCtorInfo
Returns
TryNew(MethodBase, ParamInfo[]?, AdditionalFlags, out MethodCtorInfo)
Attempts to create a new MethodCtorInfo with explicit member-completion control.
public static bool TryNew(MethodBase MethodBase, ParamInfo[]? Parameters, MethodCtorInfo.AdditionalFlags Flags, out MethodCtorInfo mci)
Parameters
MethodBaseMethodBaseParametersParamInfo[]FlagsMethodCtorInfo.AdditionalFlagsmciMethodCtorInfo
Returns
TryNew(MethodBase, ParamInfo[]?, out MethodCtorInfo)
Attempts to create a new MethodCtorInfo, returning false if validation fails.
public static bool TryNew(MethodBase MethodBase, ParamInfo[]? Parameters, out MethodCtorInfo mci)
Parameters
MethodBaseMethodBaseParametersParamInfo[]mciMethodCtorInfo
Returns
Validate(MethodBase, ParamInfo[]?)
Validates that the provided matchers are compatible with the method's parameters.
public static Exception? Validate(MethodBase methodBase, ParamInfo[]? parameters)
Parameters
methodBaseMethodBaseparametersParamInfo[]
Returns
ValidateMethodReturn(MethodInfo)
Validates the return type and generic constraints of a static factory method.
public static Exception? ValidateMethodReturn(MethodInfo method)
Parameters
methodMethodInfo