OpenTAP 9.27
API Reference
Public Member Functions | Static Public Member Functions | Properties | Events | List of all members
OpenTap.TypeData Class Reference

Representation of a C#/dotnet type including its inheritance hierarchy. Part of the object model used in the PluginManager More...

Inheritance diagram for OpenTap.TypeData:
OpenTap.ITypeData OpenTap.IReflectionData

Public Member Functions

Type Load ()
 Returns the System.Type corresponding to this. If the assembly in which this type is defined has not yet been loaded, this call will load it.
 
string GetBestName ()
 Returns the DisplayAttribute.Name if the type has a DisplayAttribute, otherwise the FullName without namespace More...
 
override string ToString ()
 Creates a string value of this.
 
object CreateInstance (object[] arguments)
 Creates a new object instance of this type. Accessing this property causes the underlying Assembly to be loaded if it is not already.
 
IMemberData GetMember (string name)
 Gets a member by name. Causes the underlying Assembly to be loaded if it is not already.
 
IEnumerable< IMemberDataGetMembers ()
 Gets all the members of this type. Causes the underlying Assembly to be loaded if it is not already.
 
override bool Equals (object obj)
 Compares two TypeDatas by comparing their inner Type instances. More...
 
override int GetHashCode ()
 Calculates the hash code based on the .NET Type instance. More...
 

Static Public Member Functions

static ITypeData GetTypeData (object obj)
 Get the type info of an object.
 
static IEnumerable< ITypeDataGetDerivedTypes (ITypeData baseType)
 Get all known types that derive from a given type. More...
 
static ITypeDataSource GetTypeDataSource (ITypeData typeData)
 Gets the type data source for an ITypeData. For most types this will return the AssemblyData, but for types for which an ITypeDataSourceProvider exists it will return that instead. The base AssemblyData will often be associated to one of the typedatas base classes. More...
 
static IEnumerable< ITypeDataGetDerivedTypes< BaseType > ()
 Get all known types that derive from a given type. More...
 
static IDisposable WithTypeDataCache ()
 Creates a type data cache. Note this should be used with 'using{}' so that it gets removed afterwards. More...
 
static ITypeData GetTypeData (string name)
 Gets the type info from a string.
 
static ITypeData GetTypeData (Type _)
 This throws an exception due to the ambiguousness of TypeData.FromType vs TypeData.GetTypeData. To get TypeData representing a type use TypeData.FromType. Otherwise cast 'type' to an 'object' first.
 
static TypeData FromType (Type type)
 Creates a new TypeData object to represent a dotnet type.
 

Properties

string Name [get]
 Gets the fully qualified name of the type, including its namespace but not its assembly.
 
TypeAttributes TypeAttributes [get]
 Gets the TypeAttributes for this type. This can be used to check if the type is abstract, nested, an interface, etc.
 
AssemblyData Assembly [get]
 Gets the Assembly that defines this type.
 
DisplayAttribute Display [get]
 Gets.the DisplayAttribute for this type. Null if the type does not have a DisplayAttribute
 
IEnumerable< TypeDataPluginTypes [get]
 Gets a list of plugin types (i.e. types that directly implement ITapPlugin) that this type inherits from/implements
 
IEnumerable< TypeDataDerivedTypes [get]
 Gets a list of types that has this type as a base type (including interfaces)
 
bool IsBrowsable [get]
 False if the type has a System.ComponentModel.BrowsableAttribute with Browsable = false.
 
IEnumerable< object > Attributes [get]
 The attributes of this type. Accessing this property causes the underlying Assembly to be loaded if it is not already.
 
Type Type [get]
 Gets the System.Type that this represents. Same as calling Load(). Accessing this property causes the underlying Assembly to be loaded if it is not already.
 
bool IsValueType [get]
 gets if the type is a value-type. (see Type.IsValueType)
 
ITypeData??? BaseType [get]
 The base type of this type. Will return null if there is no base type. If there is no direct base, but instead an interface, that will be returned.
 
bool CanCreateInstance [get]
 returns true if an instance possibly can be created. Accessing this property causes the underlying Assembly to be loaded if it is not already.
 
- Properties inherited from OpenTap.ITypeData
ITypeData BaseType [get]
 The base type of this type.
 
bool CanCreateInstance [get]
 Gets if CreateInstance will work for this type. For examples, for interfaces and abstract classes it will not work.
 
- Properties inherited from OpenTap.IReflectionData
IEnumerable< object > Attributes [get]
 The attributes of it.
 
string Name [get]
 The name of it.
 

Events

static EventHandler< TypeDataCacheInvalidatedEventArgsTypeCacheInvalidated
 Invoked when new types has been discovered in an asynchronous fashion.
 

Detailed Description

Representation of a C#/dotnet type including its inheritance hierarchy. Part of the object model used in the PluginManager

Member Function Documentation

◆ Equals()

override bool OpenTap.TypeData.Equals ( object  obj)
inline

Compares two TypeDatas by comparing their inner Type instances.

Parameters
objShould be a TypeData
Returns
true if the two Type properties are equals.

◆ GetBestName()

string OpenTap.TypeData.GetBestName ( )
inline

Returns the DisplayAttribute.Name if the type has a DisplayAttribute, otherwise the FullName without namespace

Returns

◆ GetDerivedTypes()

static IEnumerable< ITypeData > OpenTap.TypeData.GetDerivedTypes ( ITypeData  baseType)
inlinestatic

Get all known types that derive from a given type.

Parameters
baseTypeBase type that all returned types descends to.
Returns
All known types that descends to the given base type.

◆ GetDerivedTypes&lt; BaseType &gt;()

static IEnumerable< ITypeData > OpenTap.TypeData.GetDerivedTypes< BaseType > ( )
inlinestatic

Get all known types that derive from a given type.

Template Parameters
BaseTypeBase type that all returned types descends to.
Returns
All known types that descends to the given base type.

◆ GetHashCode()

override int OpenTap.TypeData.GetHashCode ( )
inline

Calculates the hash code based on the .NET Type instance.

Returns

◆ GetTypeDataSource()

static ITypeDataSource OpenTap.TypeData.GetTypeDataSource ( ITypeData  typeData)
inlinestatic

Gets the type data source for an ITypeData. For most types this will return the AssemblyData, but for types for which an ITypeDataSourceProvider exists it will return that instead. The base AssemblyData will often be associated to one of the typedatas base classes.

Parameters
typeData
Returns

◆ WithTypeDataCache()

static IDisposable OpenTap.TypeData.WithTypeDataCache ( )
static

Creates a type data cache. Note this should be used with 'using{}' so that it gets removed afterwards.

Returns
A disposable object removing the cache.

OpenTAP 9.27 API built Wed Nov 27 2024 13:14:46