API ReferenceSandbox.Internal

TypeLibraryclass

objectTypeLibrary
Namespace
Sandbox.Internal
Assembly
Sandbox.Reflection
Declaration
public class Sandbox.Internal.TypeLibrary

Methods50

Showing 50 methods

public T GetAttribute(System.Type t)PUBLIC

Get single attribute of type, from type

ParameterTypeDescription
tType
Returns:T

public System.Type[] GetGenericArguments(System.Type genericType)PUBLIC

Performs `System.Type.GetGenericArguments` with access control checks. Will throw if any arguments aren't in the whitelist.

ParameterTypeDescription
genericTypeTypeConstructed generic type to get the arguments of
Returns:Type[]

public System.Collections.Generic.IReadOnlyList`1<Sandbox.TypeDescription> GetGenericTypes(System.Type type, System.Type[] types)PUBLIC

Get a list of types that implement this generic type

ParameterTypeDescription
typeType
typesType[]
Returns:IReadOnlyList<TypeDescription>

public Sandbox.MemberDescription GetMemberByIdent(int ident)PUBLIC

Find a `Sandbox.MemberDescription` by its `Sandbox.MemberDescription.Identity`

ParameterTypeDescription
identint

public System.Collections.Generic.IReadOnlyList`1<System.ValueTuple`2<Sandbox.MethodDescription,T>> GetMethodsWithAttribute(bool onlyStatic = True)PUBLIC

Find all methods with given attribute, optionally non static

ParameterTypeDescription
onlyStatic = Truebool
Returns:IReadOnlyList<ValueTuple<MethodDescription,T>>

public Sandbox.PropertyDescription[] GetPropertyDescriptions(object obj, bool onlyOwn = False)PUBLIC

Get a list of properties on the target object. To do this we'll just call GetDescription( obj.GetType() ) and return .Properties. Will return an empty array if we can't access these properties.

ParameterTypeDescription
objobject
onlyOwn = Falsebool
Returns:PropertyDescription[]

public object GetPropertyValue(object target, string name)PUBLIC

Try to get a value from a property on an object

ParameterTypeDescription
targetobject
namestring
Returns:object

public Sandbox.TypeDescription GetTypeByIdent(int ident)PUBLIC

Find a TypeDescription by name

ParameterTypeDescription
identint
Returns:TypeDescription

public int GetTypeIdent(System.Type type)PUBLIC

Get hash of a type.

ParameterTypeDescription
typeType
Returns:int

public bool HasAttribute(System.Type type)PUBLIC

Return true if this type contains this attribute

ParameterTypeDescription
typeType
Returns:bool

public bool SetProperty(object target, string name, object value)PUBLIC

Set a named property on given object. Will perform extra magic for string inputs and try to convert to target property type.

ParameterTypeDescription
targetobjectThe target object to set a named property on.
namestringName of the property to set.
valueobjectValue for the property.
Returns:boolWhether the property was set or not.

On this page

Methodspublic System.Boolean CheckValidationAttributes(T obj, System.String[] errors)public System.Boolean CheckValidationAttributes(T obj)public System.Object Create(System.String name, System.Type targetType, System.Object[] args = null)public T Create(System.Int32 ident)public T Create(System.String name = null, System.Boolean complainOnMissing = True)public T Create(System.String name, System.Object[] args, System.Boolean complainOnMissing = True)public T Create(System.Type type, System.Object[] args = null)public Sandbox.SerializedProperty CreateProperty(System.String title, Sandbox.SerializedObject so, System.Attribute[] attributes = null, Sandbox.SerializedObject parent = null)public Sandbox.SerializedProperty CreateProperty(System.String title, System.Func`1<T> get, System.Action`1<T> set, System.Attribute[] attributes = null, Sandbox.SerializedObject parent = null)public System.Collections.Generic.IEnumerable`1<Sandbox.MethodDescription> FindStaticMethods(System.String methodName)public System.Collections.Generic.IEnumerable`1<Sandbox.MethodDescription> FindStaticMethods(System.String methodName)public T FromBytes(Sandbox.ByteStream bs)public T FromBytes(System.Byte[] data)public T FromBytes(System.ReadOnlySpan`1<System.Byte> data)public T GetAttribute(System.Type t)public System.Collections.Generic.IReadOnlyList`1<T> GetAttributes()public System.Collections.Generic.IReadOnlyList`1<T> GetAttributes(System.Type t)public Sandbox.EnumDescription GetEnumDescription(System.Type enumType)public Sandbox.EnumDescription.Entry GetEnumDescription(T enumValue)public System.Type[] GetGenericArguments(System.Type genericType)public System.Collections.Generic.IReadOnlyList`1<Sandbox.TypeDescription> GetGenericTypes(System.Type type, System.Type[] types)public System.Collections.Generic.IEnumerable`1<T> GetMemberAttributes()public System.Collections.Generic.IEnumerable`1<T> GetMemberAttributes(System.Boolean staticMembers)public Sandbox.MemberDescription GetMemberByIdent(System.Int32 ident)public System.Collections.Generic.IReadOnlyList`1<System.ValueTuple`2<Sandbox.MethodDescription,T>> GetMethodsWithAttribute(System.Boolean onlyStatic = True)public Sandbox.PropertyDescription[] GetPropertyDescriptions(System.Object obj, System.Boolean onlyOwn = False)public System.Object GetPropertyValue(System.Object target, System.String name)public Sandbox.SerializedObject GetSerializedObject(System.Func`1<System.Object> fetchTarget, Sandbox.TypeDescription typeDescription, Sandbox.SerializedProperty parent = null)public Sandbox.SerializedObject GetSerializedObject(System.Object target)public Sandbox.TypeDescription GetType(System.String name, System.Boolean exactFullName = False)public Sandbox.TypeDescription GetType(System.String name, System.Type baseType)public Sandbox.TypeDescription GetType(System.Type type, System.String name, System.Boolean preferAddonAssembly = False, System.Boolean exactFullName = False)public Sandbox.TypeDescription GetType(System.Type type)public Sandbox.TypeDescription GetType()public Sandbox.TypeDescription GetType(System.String name, System.Boolean preferAddonAssembly, System.Boolean exactFullName)public Sandbox.TypeDescription GetType(System.String name, System.Boolean preferAddonAssembly)public Sandbox.TypeDescription GetType(System.String name)public Sandbox.TypeDescription GetTypeByIdent(System.Int32 ident)public System.Int32 GetTypeIdent(System.Type type)public System.Collections.Generic.IEnumerable`1<Sandbox.TypeDescription> GetTypes()public System.Collections.Generic.IReadOnlyList`1<Sandbox.TypeDescription> GetTypes(System.Type type)public System.Collections.Generic.IReadOnlyList`1<Sandbox.TypeDescription> GetTypes()public System.Collections.Generic.IReadOnlyList`1<System.ValueTuple`2<Sandbox.TypeDescription,T>> GetTypesWithAttribute()public System.Collections.Generic.IReadOnlyList`1<System.ValueTuple`2<Sandbox.TypeDescription,T>> GetTypesWithAttribute(System.Boolean inherited)public System.Boolean HasAttribute(System.Type type)public System.Boolean SetProperty(System.Object target, System.String name, System.Object value)public System.Void ToBytes(T value, Sandbox.ByteStream bs)public System.Byte[] ToBytes(T value)public System.Boolean TryGetType(System.Type t, Sandbox.TypeDescription typeDescription)public System.Boolean TryGetType(Sandbox.TypeDescription typeDescription)Metadata