Version 3.3.0.1

ValueResolverContext struct

Namespace: Sirenix.OdinInspector.Editor.ValueResolvers
Assembly: Sirenix.OdinInspector.Editor
public struct ValueResolverContext
This struct contains all of a ValueResolver's configurations and values it needs to function. For performance and simplicity reasons, this is a single very large struct that lives on a ValueResolver instance and is passed around by ref to anything that needs it.

Fields

ErrorMessage
The error message, if a valid value resolution wasn't found, or if creation of the value resolver failed because ResolvedString was invalid, or if value resolution was run but threw an exception. (In this last case, ErrorMessageIsDueToException will be true.)
public string ErrorMessage
ErrorMessageIsDueToException
This will be true if ErrorMessage is not null and the message was caused by an exception thrown by code invoked during an actual value resolution.
public bool ErrorMessageIsDueToException
FallbackValue
This is the fallback value that the value resolver will return if there is an error or failed resolution for any reason.
public object FallbackValue
HasFallbackValue
Whether there is a fallback value. This boolean exists because then null is also a valid fallback value. This boolean will always be true if an overload is used that takes a fallback value parameter.
public bool HasFallbackValue
LogExceptions
Whether exceptions thrown during value resolution should be logged to the console.
public bool LogExceptions
NamedValues
The named values that are available to the value resolver. Use this field only to get and set named values - once the ValueResolver has been created, new named values will have no effect.
public NamedValues NamedValues
Property
The property that *provides* the context for the value resolution. This is the instance that was passed to the resolver when it was created. Note that this is different from ContextProperty, which is based on this value, but almost always isn't the same InspectorProperty instance.
public InspectorProperty Property

Properties

ContextProperty
The property that *is* the context for the value resolution. This is not the instance that was passed to the resolver when it was created, but this value is based on that instance. This is the property that provides the actual context - for example, if Property is for a member of a type - or for an element in a collection contained by a member - this value will be the parent property for the type that contains that member. Only if Property is the tree's root property is ContextProperty the same as Property.
public InspectorProperty ContextProperty { get; }
IsResolved
Whether this context has been resolved.
public bool IsResolved { get; }
ParentType
The type that is the parent of the value resolution, ie, the type that is the context. This is the same as ContextProperty.ValueEntry.TypeOfValue.
public Type ParentType { get; }
ResolvedString
The string that is resolved to get a value.
public string ResolvedString { get; set; }
ResultType
The type of value that the resolver is resolving.
public Type ResultType { get; set; }
SyncRefParametersWithNamedValues
Whether the value resolver should sync ref parameters of invoked methods with named values. If this is true, then if a ref or out parameter value is changed during value resolution, the named value associated with that parameter will also be changed to the same value.
public bool SyncRefParametersWithNamedValues { get; set; }

Methods

AddDefaultContextValues()
Adds the default named values of "property" and "value" to the context's named values. This method is usually automatically invoked when a resolver is created, so there is no need to invoke it manually.
public void AddDefaultContextValues()
CreateDefault(InspectorProperty, Type, String, NamedValue[])
public static ValueResolverContext CreateDefault(InspectorProperty property, Type resultType, string resolvedString, params NamedValue[] namedValues)
Parameters
InspectorProperty property

System.Type resultType

System.String resolvedString

NamedValue[] namedValues

CreateDefault<T>(InspectorProperty, String, T, NamedValue[])
public static ValueResolverContext CreateDefault<T>(InspectorProperty property, string resolvedString, T fallbackValue, params NamedValue[] namedValues)
Parameters
InspectorProperty property

System.String resolvedString

T fallbackValue

NamedValue[] namedValues

Type Parameters
T

CreateDefault<T>(InspectorProperty, String, NamedValue[])
public static ValueResolverContext CreateDefault<T>(InspectorProperty property, string resolvedString, params NamedValue[] namedValues)
Parameters
InspectorProperty property

System.String resolvedString

NamedValue[] namedValues

Type Parameters
T

GetParentValue(Int32)
Gets the parent value which provides the context of the resolver.
public object GetParentValue(int selectionIndex)
Parameters
System.Int32 selectionIndex

The selection index of the parent value to get.

Returns
System.Object

MarkResolved()
public void MarkResolved()
SetParentValue(Int32, Object)
Sets the parent value which provides the context of the resolver.
public void SetParentValue(int selectionIndex, object value)
Parameters
System.Int32 selectionIndex

The selection index of the parent value to set.

System.Object value

The value to set.