C# Client Library
A C# Client Library for the AnalyzeRe REST API
AnalyzeRe.Utilities.TypeResolver Class Reference

Utility for resolving types given only the types name (Useful for parsing ambiguous JSON objects). More...

Static Public Member Functions

static List< Type > GetAllInstantiableSubtypes (Type type)
 Attempts to create a list of types in the current application domain's assemblies derived from the given type. Limitations include: More...
 
static List< Type > GetAPITypes ()
 Returns a list of all APIType types in the current domain assemblies. More...
 
static List< Type > GetAppDomainTypes ()
 Returns a list of all types in the current domain assemblies. More...
 
static Type GetEnumerableType (Type type)
 If the specified type implements IEnumerable<T>, returns the generic type argument. Elements returned fro an enumeration of this type are guaranteed to be convertible this type. More...
 
static Type GetGenericCovariantBase (Type T)
 Returns the most strongly typed covariant base type which is assignable from the specified type T. More...
 
static string GetTypeNameForAPIType (Type type)
 Gets the type name from the overriding type alias attribute or class name based using the supplied type. More...
 
static bool ImplementsInterface (this Type type, Type interfaceType)
 Returns true if the specified type implements the interface. More...
 
static Type MakeGenericTypeFast (this Type generic_base, Type type_parameter)
 Invokes a call to MakeGenericType with a backing cache. More...
 
static Type ResolveBaseTypeByCollectionName (string collection)
 Get the base type of object referenced by the supplied server URL. More...
 
static Type ResolveBaseTypeByURL (string href)
 Get the base type of object referenced by the supplied server URL. More...
 
static bool ResolveTypeByName (string typeName, out Type resolvedType, Type requiredBaseType=null)
 Clever method that checks all assemblies in the application being compiled for the type referenced by name. Useful if the a user expects to get JSON back for an object type that isn't described in this library. Also useful for not needing to constantly update the JSON converter when new types / derived types are added. More...
 

Detailed Description

Utility for resolving types given only the types name (Useful for parsing ambiguous JSON objects).

Definition at line 13 of file TypeResolver.cs.

Member Function Documentation

static List<Type> AnalyzeRe.Utilities.TypeResolver.GetAllInstantiableSubtypes ( Type  type)
inlinestatic

Attempts to create a list of types in the current application domain's assemblies derived from the given type. Limitations include:

  • The inability to get sub-types for a generic type with more than 1 type parameter.
  • The inability to get more than one sub-type for a generic type whose type parameter is itself a generic type.

Definition at line 219 of file TypeResolver.cs.

static List<Type> AnalyzeRe.Utilities.TypeResolver.GetAPITypes ( )
inlinestatic

Returns a list of all APIType types in the current domain assemblies.

Returns
A list of all APIType types in the current domain assemblies.

Definition at line 62 of file TypeResolver.cs.

static List<Type> AnalyzeRe.Utilities.TypeResolver.GetAppDomainTypes ( )
inlinestatic

Returns a list of all types in the current domain assemblies.

Returns
A list of all types in the current domain assemblies.

Definition at line 23 of file TypeResolver.cs.

static Type AnalyzeRe.Utilities.TypeResolver.GetEnumerableType ( Type  type)
inlinestatic

If the specified type implements IEnumerable<T>, returns the generic type argument. Elements returned fro an enumeration of this type are guaranteed to be convertible this type.

Definition at line 358 of file TypeResolver.cs.

static Type AnalyzeRe.Utilities.TypeResolver.GetGenericCovariantBase ( Type  T)
inlinestatic

Returns the most strongly typed covariant base type which is assignable from the specified type T.

Parameters
TThe type to get the covariant base type for.
Returns
The most strongly typed covariant base type which is assignable from the specified type T

Definition at line 288 of file TypeResolver.cs.

static string AnalyzeRe.Utilities.TypeResolver.GetTypeNameForAPIType ( Type  type)
inlinestatic

Gets the type name from the overriding type alias attribute or class name based using the supplied type.

Parameters
typeThe type of the APIType class.
Returns
The type name to be used for API communication.
Exceptions
ArgumentNullExceptiontype is null.

Definition at line 92 of file TypeResolver.cs.

static bool AnalyzeRe.Utilities.TypeResolver.ImplementsInterface ( this Type  type,
Type  interfaceType 
)
inlinestatic

Returns true if the specified type implements the interface.

Definition at line 371 of file TypeResolver.cs.

static Type AnalyzeRe.Utilities.TypeResolver.MakeGenericTypeFast ( this Type  generic_base,
Type  type_parameter 
)
inlinestatic

Invokes a call to MakeGenericType with a backing cache.

Parameters
generic_baseThe generic base type, e.g.
typeof(Collection{})
type_parameterThe type parameter to use in creating the generic type.
Returns
The generic type with the specified type parameter.

Definition at line 343 of file TypeResolver.cs.

static Type AnalyzeRe.Utilities.TypeResolver.ResolveBaseTypeByCollectionName ( string  collection)
inlinestatic

Get the base type of object referenced by the supplied server URL.

Parameters
collectionThe collection endpoint to get the base type of.
Returns
The base type of object for the specified URL.

Definition at line 170 of file TypeResolver.cs.

static Type AnalyzeRe.Utilities.TypeResolver.ResolveBaseTypeByURL ( string  href)
inlinestatic

Get the base type of object referenced by the supplied server URL.

Parameters
hrefThe URL supplied by the server.
Returns
The base type of object for the specified URL.

Definition at line 162 of file TypeResolver.cs.

static bool AnalyzeRe.Utilities.TypeResolver.ResolveTypeByName ( string  typeName,
out Type  resolvedType,
Type  requiredBaseType = null 
)
inlinestatic

Clever method that checks all assemblies in the application being compiled for the type referenced by name. Useful if the a user expects to get JSON back for an object type that isn't described in this library. Also useful for not needing to constantly update the JSON converter when new types / derived types are added.

Parameters
typeNameThe short name (as opposed to the fully qualified name) of the type to search for.
requiredBaseType(Optional) A base type which the discovered type must derive from. (Useful if there are type name conflicts or if searching for a type that can be downcast to a base type reference).
resolvedTypeThe type in this application domain that matches the parameter.
Returns
True if the corresponding type was found, False if none was found.

Definition at line 121 of file TypeResolver.cs.


The documentation for this class was generated from the following file: