Class RuntimeTypeInfo
Provides optimized access to methods and properties at runtime.
Inheritance
Implements
Inherited Members
Namespace: Kephas.Runtime
Assembly: Kephas.Core.dll
Syntax
public class RuntimeTypeInfo : Expando, IRuntimeTypeInfo, ITypeInfo, IRuntimeElementInfo, IElementInfo, IExpando, IDynamicMetaObjectProvider, IIndexable, IAttributeProvider
  Constructors
| Improve this Doc View SourceRuntimeTypeInfo(Type)
Initializes a new instance of the RuntimeTypeInfo class.
Declaration
protected RuntimeTypeInfo(Type type)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | type | The type.  | 
      
Properties
| Improve this Doc View SourceAnnotations
Gets the element annotations.
Declaration
public IEnumerable<object> Annotations { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<System.Object> | The element annotations.  | 
      
BaseTypes
Gets the bases of this ITypeInfo. They include the real base and also the implemented interfaces.
Declaration
public IEnumerable<ITypeInfo> BaseTypes { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<ITypeInfo> | The bases.  | 
      
CreateRuntimeTypeInfo
Gets or sets the function for creating the runtime type information.
Declaration
public static Func<Type, IRuntimeTypeInfo> CreateRuntimeTypeInfo { get; set; }
  Property Value
| Type | Description | 
|---|---|
| System.Func<System.Type, IRuntimeTypeInfo> | The function for creating the runtime type information.  | 
      
DeclaringContainer
Gets the parent element declaring this element.
Declaration
public IElementInfo DeclaringContainer { get; }
  Property Value
| Type | Description | 
|---|---|
| IElementInfo | The declaring element.  | 
      
DefaultValue
Gets the default value of the type.
Declaration
public object DefaultValue { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Object | The default value.  | 
      
Fields
Gets the fields.
Declaration
public IDictionary<string, IRuntimeFieldInfo> Fields { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<System.String, IRuntimeFieldInfo> | The fields.  | 
      
FullName
Gets the full name of the element.
Declaration
public string FullName { get; }
  Property Value
| Type | Description | 
|---|---|
| System.String | The full name of the element.  | 
      
GenericTypeArguments
Gets a read-only list of ITypeInfo objects that represent the type arguments of a closed generic type.
Declaration
public IReadOnlyList<ITypeInfo> GenericTypeArguments { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IReadOnlyList<ITypeInfo> | The generic arguments.  | 
      
GenericTypeDefinition
Gets a ITypeInfo object that represents a generic type definition from which the current generic type can be constructed.
Declaration
public ITypeInfo GenericTypeDefinition { get; }
  Property Value
| Type | Description | 
|---|---|
| ITypeInfo | The generic type definition.  | 
      
GenericTypeParameters
Gets a read-only list of ITypeInfo objects that represent the type parameters of a generic type definition (open generic).
Declaration
public IReadOnlyList<ITypeInfo> GenericTypeParameters { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IReadOnlyList<ITypeInfo> | The generic arguments.  | 
      
Kind
Gets the runtime type kind.
Declaration
public RuntimeTypeKind Kind { get; }
  Property Value
| Type | Description | 
|---|---|
| RuntimeTypeKind | The runtime type kind.  | 
      
Members
Gets the members.
Declaration
public IDictionary<string, IRuntimeElementInfo> Members { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<System.String, IRuntimeElementInfo> | The members.  | 
      
Methods
Gets the runtime methods.
Declaration
public IDictionary<string, ICollection<IRuntimeMethodInfo>> Methods { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<System.String, System.Collections.Generic.ICollection<IRuntimeMethodInfo>> | The runtime methods.  | 
      
Name
Gets the name of the type.
Declaration
public string Name { get; }
  Property Value
| Type | Description | 
|---|---|
| System.String | The name of the type.  | 
      
Namespace
Gets the namespace of the type.
Declaration
public string Namespace { get; }
  Property Value
| Type | Description | 
|---|---|
| System.String | The namespace of the type.  | 
      
Properties
Gets the runtime properties.
Declaration
public IDictionary<string, IRuntimePropertyInfo> Properties { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<System.String, IRuntimePropertyInfo> | The runtime properties.  | 
      
QualifiedFullName
Gets the full name qualified with the module where it was defined.
Declaration
public string QualifiedFullName { get; }
  Property Value
| Type | Description | 
|---|---|
| System.String | The full name qualified with the module.  | 
      
Type
Gets the type.
Declaration
public Type Type { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Type | The type.  | 
      
TypeInfo
Gets the underlying TypeInfo.
Declaration
public TypeInfo TypeInfo { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Reflection.TypeInfo | The type.  | 
      
Methods
| Improve this Doc View SourceCreateFieldInfos(Type, Func<FieldInfo, Boolean>)
Creates the fields.
Declaration
protected virtual IDictionary<string, IRuntimeFieldInfo> CreateFieldInfos(Type type, Func<FieldInfo, bool> criteria = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | type | The type.  | 
      
| System.Func<System.Reflection.FieldInfo, System.Boolean> | criteria | Optional. The criteria.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<System.String, IRuntimeFieldInfo> | A dictionary of fields.  | 
      
CreateInstance(IEnumerable<Object>)
Creates an instance with the provided arguments (if any).
Declaration
public object CreateInstance(IEnumerable<object> args = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Object> | args | The arguments.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Object | The new instance.  | 
      
CreateMemberInfos(Action<IDictionary<String, IRuntimeElementInfo>>)
Creates the member infos.
Declaration
protected virtual IDictionary<string, IRuntimeElementInfo> CreateMemberInfos(Action<IDictionary<string, IRuntimeElementInfo>> membersConfig = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Action<System.Collections.Generic.IDictionary<System.String, IRuntimeElementInfo>> | membersConfig | Optional. The members configuration.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<System.String, IRuntimeElementInfo> | The new member infos.  | 
      
CreateMembers<TRuntimeMemberInfo, TMemberInfo>(Type, IEnumerable<TRuntimeMemberInfo>, Func<TRuntimeMemberInfo, Type>, Func<TRuntimeMemberInfo, Boolean>)
Creates the members.
Declaration
protected static IDictionary<string, TMemberInfo> CreateMembers<TRuntimeMemberInfo, TMemberInfo>(Type type, IEnumerable<TRuntimeMemberInfo> runtimeMembers, Func<TRuntimeMemberInfo, Type> memberTypeGetter, Func<TRuntimeMemberInfo, bool> criteria = null)
    where TRuntimeMemberInfo : MemberInfo
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | type | The type.  | 
      
| System.Collections.Generic.IEnumerable<TRuntimeMemberInfo> | runtimeMembers | The runtime members.  | 
      
| System.Func<TRuntimeMemberInfo, System.Type> | memberTypeGetter | The member type getter.  | 
      
| System.Func<TRuntimeMemberInfo, System.Boolean> | criteria | Optional. The criteria.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<System.String, TMemberInfo> | A dictionary of members.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| TRuntimeMemberInfo | Type of the runtime member.  | 
      
| TMemberInfo | Type of the member.  | 
      
CreatePropertyInfos(Type, Func<PropertyInfo, Boolean>)
Creates the properties.
Declaration
protected virtual IDictionary<string, IRuntimePropertyInfo> CreatePropertyInfos(Type type, Func<PropertyInfo, bool> criteria = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | type | The container type.  | 
      
| System.Func<System.Reflection.PropertyInfo, System.Boolean> | criteria | The criteria.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<System.String, IRuntimePropertyInfo> | A dictionary of properties.  | 
      
GetAttributes<TAttribute>()
Gets the attribute of the provided type.
Declaration
public IEnumerable<TAttribute> GetAttributes<TAttribute>()
    where TAttribute : Attribute
  Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<TAttribute> | The attribute of the provided type.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| TAttribute | Type of the attribute.  | 
      
GetMember(String, Boolean)
Gets a member by the provided name.
Declaration
public IElementInfo GetMember(string name, bool throwIfNotFound = true)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | name | The name.  | 
      
| System.Boolean | throwIfNotFound | True to throw if the requested member is not found.  | 
      
Returns
| Type | Description | 
|---|---|
| IElementInfo | The requested member, or   | 
      
GetThisTypeInfo()
Gets the IRuntimeTypeInfo of this expando object.
Declaration
protected override ITypeInfo GetThisTypeInfo()
  Returns
| Type | Description | 
|---|---|
| ITypeInfo | The IRuntimeTypeInfo of this expando object.  | 
      
Overrides
| Improve this Doc View SourceGetUnderlyingElementInfo()
Gets the underlying member information.
Declaration
public ICustomAttributeProvider GetUnderlyingElementInfo()
  Returns
| Type | Description | 
|---|---|
| System.Reflection.ICustomAttributeProvider | The underlying member information.  | 
      
GetValue(Object, String)
Gets the value of the property with the specified name.
Declaration
public object GetValue(object instance, string propertyName)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | instance | The instance.  | 
      
| System.String | propertyName | Name of the property.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Object | The value of the specified property.  | 
      
Remarks
If a property with the provided name is not found, an exception occurs.
Invoke(Object, String, IEnumerable<Object>)
Invokes the specified method on the provided instance.
Declaration
public object Invoke(object instance, string methodName, IEnumerable<object> args)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | instance | The instance.  | 
      
| System.String | methodName | Name of the method.  | 
      
| System.Collections.Generic.IEnumerable<System.Object> | args | The arguments.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Object | The invocation result.  | 
      
MakeGenericType(IEnumerable<ITypeInfo>, IContext)
Constructs a generic type baed on the provided type arguments.
Declaration
public ITypeInfo MakeGenericType(IEnumerable<ITypeInfo> typeArguments, IContext constructionContext = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<ITypeInfo> | typeArguments | The type arguments.  | 
      
| IContext | constructionContext | The construction context (optional).  | 
      
Returns
| Type | Description | 
|---|---|
| ITypeInfo | A constructed ITypeInfo.  | 
      
RegisterFactory(IRuntimeTypeInfoFactory)
Registers a factory used to create IRuntimeTypeInfo instances.
Declaration
public static void RegisterFactory(IRuntimeTypeInfoFactory factory)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IRuntimeTypeInfoFactory | factory | The factory.  | 
      
Remarks
Factories are called in the inverse order of their addition, meaning that the last added factory is invoked first. This is by design, so that the non-framework code has a change to override the default behavior.
SetValue(Object, String, Object)
Sets the value of the property with the specified name.
Declaration
public void SetValue(object instance, string propertyName, object value)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | instance | The instance.  | 
      
| System.String | propertyName | Name of the property.  | 
      
| System.Object | value | The value.  | 
      
Remarks
If a property with the provided name is not found, an exception occurs.
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
  Returns
| Type | Description | 
|---|---|
| System.String | A string that represents the current object.  | 
      
Overrides
TryGetValue(Object, String, out Object)
Gets the value of the property with the specified name.
Declaration
public bool TryGetValue(object instance, string propertyName, out object value)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | instance | The instance.  | 
      
| System.String | propertyName | Name of the property.  | 
      
| System.Object | value | The property value.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Boolean | A boolean value indicating whether the property is found.  | 
      
TryInvoke(Object, String, IEnumerable<Object>, out Object)
Tries to invokes the specified method on the provided instance.
Declaration
public bool TryInvoke(object instance, string methodName, IEnumerable<object> args, out object result)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | instance | The instance.  | 
      
| System.String | methodName | Name of the method.  | 
      
| System.Collections.Generic.IEnumerable<System.Object> | args | The arguments.  | 
      
| System.Object | result | The invocation result.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Boolean | A boolean value indicating whether the invocation was successful or not.  | 
      
TrySetValue(Object, String, Object)
Tries to set the value of the property with the specified name.
Declaration
public bool TrySetValue(object instance, string propertyName, object value)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | instance | The instance.  | 
      
| System.String | propertyName | Name of the property.  | 
      
| System.Object | value | The value.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
  | 
      
Remarks
If a property with the provided name is not found, the method just returns.
Explicit Interface Implementations
| Improve this Doc View SourceITypeInfo.Members
Gets the members.
Declaration
IEnumerable<IElementInfo> ITypeInfo.Members { get; }
  Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<IElementInfo> | The members.  | 
      
ITypeInfo.Properties
Gets the enumeration of properties.
Declaration
IEnumerable<IPropertyInfo> ITypeInfo.Properties { get; }
  Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<IPropertyInfo> |