Table of Contents

Class InjectAttribute

Namespace
Plugins.Saneject.Runtime.Attributes
Assembly
Saneject.Runtime.dll

Marks a field or method for dependency injection by Saneject.

[AttributeUsage(AttributeTargets.Method|AttributeTargets.Field)]
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]
public sealed class InjectAttribute : PropertyAttribute
Inheritance
object
Attribute
PropertyAttribute
InjectAttribute

Remarks

Apply this attribute to a field, an auto-property backing field via [field: Inject], or a method to declare an injection site. During injection, Saneject resolves matching bindings starting from the nearest scope at the same transform or above and falling back to parent scopes. Injected fields are displayed as read-only in Saneject-aware inspectors.

Constructors

InjectAttribute()

Marks the field or method for injection, using only type-based binding resolution.

public InjectAttribute()

Remarks

The dependency is resolved by matching the member's type against bindings in the scope hierarchy.

InjectAttribute(bool)

Marks the field or method for injection while optionally suppressing missing binding and missing dependency logs for the field.

public InjectAttribute(bool suppressMissingErrors)

Parameters

suppressMissingErrors bool

If true, suppresses error logs when no binding or dependency is found.

InjectAttribute(string)

Marks the field or method for injection using a specific binding ID.

public InjectAttribute(string id)

Parameters

id string

The binding ID to match against. Only bindings with the same ID will be used for resolution.

InjectAttribute(string, bool)

Marks the field or method for injection with an ID while optionally suppressing missing binding and missing dependency logs for the field.

public InjectAttribute(string id, bool suppressMissingErrors)

Parameters

id string

The binding ID to match against.

suppressMissingErrors bool

If true, suppresses error logs when no binding or dependency is found.

Properties

ID

Gets the binding ID used for dependency resolution, or null if only type-based resolution is used.

public string ID { get; }

Property Value

string

SuppressMissingErrors

Gets a value indicating whether missing binding and dependency errors are suppressed for this injection site.

public bool SuppressMissingErrors { get; }

Property Value

bool