Init(args)
Scripting Reference
Loading...
Searching...
No Matches
Sisus.Init.AnyGeneric< T > Struct Template Reference

Description

Represents a value of generic type T that can be assigned through Unity's inspector as well as serialized by its serializer.

Any<T> does not support serializing generic types - with the exception of List<T>

  • so this type should be used for that purpose instead, in custom initializer and such.

If T is a service type then this object represents the shared instance of that service.

If a class derives from Object and implements IValueProvider<T> then AnyGeneric<T> can wrap an instance of this class and return its IValueProvider<T>.Value when Value is called.

If a class derives from Object and implements IValueByTypeProvider then AnyGeneric<T> can wrap an instance of this class and use IValueByTypeProvider.TryGetFor to resolve the value to return when Value is called.

Template Parameters
TType of the value that this object wraps.

Can be an interface type, a class type or a value type.

Inheritance diagram for Sisus.Init.AnyGeneric< T >:

Public Member Functions

 AnyGeneric (T value)
 Initializes a new instance of the AnyGeneric struct with the given underlying value.
 
 AnyGeneric (Object value)
 Initializes a new instance of the AnyGeneric struct with the given underlying value.
 
GetValue ([DisallowNull] ScriptableObject client, Context context=Context.MainThread)
 Gets the current value of this object.
 
GetValue ([AllowNull] Component client, Context context=Context.MainThread)
 Gets the current value of this object.
 
GetValueOrDefault ([DisallowNull] object client, Context context=Context.MainThread)
 Gets the value of the current AnyGeneric<T> object if it has one.
 
async Task< T > GetValueAsync (Component client=null, Context context=Context.MainThread)
 Gets the value of the current AnyGeneric<T> object if it has one.
 
bool GetHasValue ([AllowNull] Component client, Context context=Context.MainThread)
 Gets a value indicating whether the current AnyGeneric<T> object has a non-null value when retrieved by the client in question in the given context .
 
bool TryGetValue (out T value)
 Gets the current value of the AnyGeneric<T> object if it has one.
 
bool TryGetValue (Component client, Context context, out T result)
 Gets the value of the current AnyGeneric<T> object if it has one.
 
bool TryGetValue (Component client, out T value)
 Gets the value of the current AnyGeneric<T> object if it has one.
 
override bool Equals (object obj)
 Determines whether the specified object is equal to the current object.
 
bool Equals (T other)
 Determines whether the specified object is equal to the value of the current object.
 
bool Equals (AnyGeneric< T > other)
 Determines whether the specified object is equal to the current object.
 
bool Equals (Object other, Context context=Context.MainThread)
 Determines whether the specified object is equal to the value of the current object.
 
override string ToString ()
 Returns a string that represents the underlying object.
 
override int GetHashCode ()
 Returns the hash code for this AnyGeneric<T> object.
 

Static Public Member Functions

static AnyGeneric< T > FromValue (T value)
 Creates a new instance of the AnyGeneric struct with the given underlying value.
 
static AnyGeneric< T > FromObject ([AllowNull] Object value)
 Creates a new instance of the AnyGeneric struct with the given underlying value.
 
static bool IsCreatableFrom ([AllowNull] Object fromReference, Component forClient)
 Returns a value indicating whether it is possible to create an instance of the AnyGeneric struct with the underlying value of fromReference .
 
static implicit operator T (AnyGeneric< T > instance)
 Defines an implicit conversion of AnyGeneric<T> to the T object that it wraps.
 
static implicit operator AnyGeneric< T > (T value)
 Defines an explicit conversion of T to an AnyGeneric<T> object.
 

Properties

bool HasValue [get]
 Gets a value indicating whether the current AnyGeneric<T> object has a non-null underlying type.
 
ValueOrDefault [get]
 Gets the value of the current AnyGeneric<T> object if it has been assigned a valid underlying value; otherwise, the default value of T.
 
Value [get]
 Gets the value of the current AnyGeneric<T> object if it has been assigned a valid underlying value; otherwise, the default value of T.