Skip to content

OptionsModelChild

public sealed class OptionsModelChild

Namespace: RhoMicro.BindSight.Models

Inheritance:

Models a direct or indirect property or generic argument of a registered options type.

OptionsModelChild(PropertyInfo, OptionsModel, OptionsModelChild, EnrichmentFactory)
Section titled “OptionsModelChild(PropertyInfo, OptionsModel, OptionsModelChild, EnrichmentFactory)”
public OptionsModelChild(PropertyInfo property, OptionsModel model, OptionsModelChild? parent, EnrichmentFactory enrichmentFactory)

Initializes a new instance.

NameTypeDescription
enrichmentFactoryEnrichmentFactoryThe factory used to create enrichments to the new model instance.
modelOptionsModelThe model containing the root to this property.
parentOptionsModelChildThe parent to this child.
propertyPropertyInfoThe property to model.
OptionsModelChild(Type, OptionsModel, OptionsModelChild, EnrichmentFactory)
Section titled “OptionsModelChild(Type, OptionsModel, OptionsModelChild, EnrichmentFactory)”
public OptionsModelChild(Type genericArgumentType, OptionsModel model, OptionsModelChild? parent, EnrichmentFactory enrichmentFactory)

Initializes a new instance.

NameTypeDescription
enrichmentFactoryEnrichmentFactoryThe factory used to create enrichments to the new model instance.
genericArgumentTypeTypeThe generic argument type to model.
modelOptionsModelThe model containing the root to this property.
parentOptionsModelChildThe parent to this child.
OptionsModelChild(ConcurrentDictionary<Type, object>, EnrichmentFactory, PropertyInfo, Type, OptionsModelChild, OptionsModel)
Section titled “OptionsModelChild(ConcurrentDictionary<Type, object>, EnrichmentFactory, PropertyInfo, Type, OptionsModelChild, OptionsModel)”
private OptionsModelChild(ConcurrentDictionary<Type, object> enrichments, EnrichmentFactory enrichmentFactory, PropertyInfo? property, Type? genericArgumentType, OptionsModelChild? parent, OptionsModel model)
public PropertyInfo? Property { get; }

Gets the property info modelled by this instance, if it is modelling one; otherwise, null.

public Type? GenericArgumentType { get; }

Gets the generic type argument modelled by this instance, if it is modelling one; otherwise, null.

public OptionsModelChild? Parent { get; }

Gets the parent containing this model if it is contained in one; otherwise, null.

public OptionsModel Model { get; }

Gets the options model containing the root defining this child.

public Type ModelledType { get; }

Gets the type of the modelled property or the modelled type.

public TAttribute? GetFirstCustomAttribute<TAttribute>([bool inherit = false]) where TAttribute : Attribute

Gets the first found custom attribute of type TAttributeon either OptionsModelChild.Property or OptionsModelChild.GenericArgumentType, depending on which is being modelled by this instance.

NameDescriptionConstraints
TThe type of attribute to search for.
TAttributeThe type of attribute to look for.Attribute
NameTypeDescription
elementThe member to inspect.
inheritBooleantrue to inspect the ancestors of element; otherwise, false.

The first found attribute of type TAttribute, if one could be found; otherwise, null.

####### TypeLoadException

A custom attribute type cannot be loaded.####### AmbiguousMatchException

More than one of the requested attributes was found.####### NotSupportedException

element is not a constructor, method, property, event, type, or field.####### ArgumentNullException

element is null.

public ImmutableArray<TAttribute> GetCustomAttributes<TAttribute>([bool inherit = false]) where TAttribute : Attribute

Gets all custom attribute of type TAttributeon either OptionsModelChild.Property or OptionsModelChild.GenericArgumentType, depending on which is being modelled by this instance.

NameDescriptionConstraints
TThe type of attribute to search for.
TAttributeThe type of attribute to look for.Attribute
NameTypeDescription
elementThe member to inspect.
inheritBooleantrue to inspect the ancestors of element; otherwise, false.

All attributes of type TAttribute, if one could be found; otherwise, null.

####### TypeLoadException

A custom attribute type cannot be loaded.####### AmbiguousMatchException

More than one of the requested attributes was found.####### NotSupportedException

element is not a constructor, method, property, event, type, or field.####### ArgumentNullException

element is null.

public TEnrichment GetEnrichment<TEnrichment>() where TEnrichment : notnull, IOptionsModelChildEnrichment<TEnrichment>

Gets an instance of the specified enrichment type. If an instance of the enrichment type is already attached to this instance, it is returned; otherwise, a new instance of the enrichment will be created and attached to this instance.

NameDescriptionConstraints
TEnrichmentThe type of enrichment to get.notnull, IOptionsModelChildEnrichment<TEnrichment>

The instance of TEnrichment attached to this instance.

public OptionsModelChild WithEnrichment<TEnrichment>(TEnrichment enrichment) where TEnrichment : IOptionsModelChildEnrichment<TEnrichment>

Gets a copy of this instance with the specified type of enrichment replaced.

NameDescriptionConstraints
TEnrichmentThe type of enrichment to attach to the returned copy.IOptionsModelChildEnrichment<TEnrichment>
NameTypeDescription
enrichmentTEnrichmentThe enrichment to attach to the returned copy.

A copy of this instance with the TEnrichment replaced by enrichment.

public override int GetHashCode()

Serves as the default hash function.

A hash code for the current object.

public override bool Equals(object? obj)

Determines whether the specified object is equal to the current object.

NameTypeDescription
objObjectThe object to compare with the current object.

true if the specified object is equal to the current object; otherwise, false.

public bool Equals(OptionsModelChild? other)