ReflectionExtensions
Assembly: ServiceStack.Text.dll
View Source
public static class ReflectionExtensions
Fields
DataMember
View Source
public const string DataMember = "DataMemberAttribute"
Methods
GetTypeCode(Type)
View Source
public static TypeCode GetTypeCode(this Type type)
Returns
System.TypeCode
Parameters
Type | Name |
---|---|
System.Type | type |
IsInstanceOf(Type, Type)
View Source
public static bool IsInstanceOf(this Type type, Type thisOrBaseType)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | type |
System.Type | thisOrBaseType |
HasGenericType(Type)
View Source
public static bool HasGenericType(this Type type)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | type |
FirstGenericType(Type)
View Source
public static Type FirstGenericType(this Type type)
Returns
System.Type
Parameters
Type | Name |
---|---|
System.Type | type |
GetTypeWithGenericTypeDefinitionOfAny(Type, Type[])
View Source
public static Type GetTypeWithGenericTypeDefinitionOfAny(this Type type, params Type[] genericTypeDefinitions)
Returns
System.Type
Parameters
Type | Name |
---|---|
System.Type | type |
System.Type[] | genericTypeDefinitions |
IsOrHasGenericInterfaceTypeOf(Type, Type)
View Source
public static bool IsOrHasGenericInterfaceTypeOf(this Type type, Type genericTypeDefinition)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | type |
System.Type | genericTypeDefinition |
GetTypeWithGenericTypeDefinitionOf(Type, Type)
View Source
public static Type GetTypeWithGenericTypeDefinitionOf(this Type type, Type genericTypeDefinition)
Returns
System.Type
Parameters
Type | Name |
---|---|
System.Type | type |
System.Type | genericTypeDefinition |
FirstGenericArg(Type)
View Source
public static Type FirstGenericArg(this Type type)
Returns
System.Type
Parameters
Type | Name |
---|---|
System.Type | type |
GetTypeWithInterfaceOf(Type, Type)
View Source
public static Type GetTypeWithInterfaceOf(this Type type, Type interfaceType)
Returns
System.Type
Parameters
Type | Name |
---|---|
System.Type | type |
System.Type | interfaceType |
HasInterface(Type, Type)
View Source
public static bool HasInterface(this Type type, Type interfaceType)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | type |
System.Type | interfaceType |
HasAnyInterface(Type, Type[])
View Source
public static bool HasAnyInterface(this Type type, Type[] interfaceTypes)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | type |
System.Type[] | interfaceTypes |
AllHaveInterfacesOfType(Type, Type[])
View Source
public static bool AllHaveInterfacesOfType(this Type assignableFromType, params Type[] types)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | assignableFromType |
System.Type[] | types |
IsNullableType(Type)
View Source
public static bool IsNullableType(this Type type)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | type |
GetUnderlyingTypeCode(Type)
View Source
public static TypeCode GetUnderlyingTypeCode(this Type type)
Returns
System.TypeCode
Parameters
Type | Name |
---|---|
System.Type | type |
IsNumericType(Type)
View Source
public static bool IsNumericType(this Type type)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | type |
IsIntegerType(Type)
View Source
public static bool IsIntegerType(this Type type)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | type |
IsRealNumberType(Type)
View Source
public static bool IsRealNumberType(this Type type)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | type |
GetTypeWithGenericInterfaceOf(Type, Type)
View Source
public static Type GetTypeWithGenericInterfaceOf(this Type type, Type genericInterfaceType)
Returns
System.Type
Parameters
Type | Name |
---|---|
System.Type | type |
System.Type | genericInterfaceType |
HasAnyTypeDefinitionsOf(Type, Type[])
View Source
public static bool HasAnyTypeDefinitionsOf(this Type genericType, params Type[] theseGenericTypes)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type | genericType |
System.Type[] | theseGenericTypes |
GetGenericArgumentsIfBothHaveSameGenericDefinitionTypeAndArguments(Type, Type, Type)
View Source
public static Type[] GetGenericArgumentsIfBothHaveSameGenericDefinitionTypeAndArguments(this Type assignableFromType, Type typeA, Type typeB)
Returns
System.Type[]
Parameters
Type | Name |
---|---|
System.Type | assignableFromType |
System.Type | typeA |
System.Type | typeB |
GetGenericArgumentsIfBothHaveConvertibleGenericDefinitionTypeAndArguments(Type, Type, Type)
View Source
public static TypePair GetGenericArgumentsIfBothHaveConvertibleGenericDefinitionTypeAndArguments(this Type assignableFromType, Type typeA, Type typeB)
Returns
ServiceStack.Text.Support.TypePair
Parameters
Type | Name |
---|---|
System.Type | assignableFromType |
System.Type | typeA |
System.Type | typeB |
AreAllStringOrValueTypes(Type[])
View Source
public static bool AreAllStringOrValueTypes(params Type[] types)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Type[] | types |
GetConstructorMethod(Type)
View Source
public static EmptyCtorDelegate GetConstructorMethod(Type type)
Returns
ServiceStack.EmptyCtorDelegate
Parameters
Type | Name |
---|---|
System.Type | type |
GetConstructorMethod(String)
View Source
public static EmptyCtorDelegate GetConstructorMethod(string typeName)
Returns
ServiceStack.EmptyCtorDelegate
Parameters
Type | Name |
---|---|
System.String | typeName |
GetConstructorMethodToCache(Type)
View Source
public static EmptyCtorDelegate GetConstructorMethodToCache(Type type)
Returns
ServiceStack.EmptyCtorDelegate
Parameters
Type | Name |
---|---|
System.Type | type |
CreateInstance<T>()
View Source
public static object CreateInstance<T>()
Returns
System.Object
Type Parameters
T
New<T>(Type)
Creates a new instance of type. First looks at JsConfig.ModelFactory before falling back to CreateInstance
View Source
public static T New<T>(this Type type)
Returns
<T>
Parameters
Type | Name |
---|---|
System.Type | type |
Type Parameters
T
New(Type)
Creates a new instance of type. First looks at JsConfig.ModelFactory before falling back to CreateInstance
View Source
public static object New(this Type type)
Returns
System.Object
Parameters
Type | Name |
---|---|
System.Type | type |
CreateInstance(Type)
Creates a new instance from the default constructor of type
View Source
public static object CreateInstance(this Type type)
Returns
System.Object
Parameters
Type | Name |
---|---|
System.Type | type |
CreateInstance<T>(Type)
View Source
public static T CreateInstance<T>(this Type type)
Returns
<T>
Parameters
Type | Name |
---|---|
System.Type | type |
Type Parameters
T
CreateInstance(String)
View Source
public static object CreateInstance(string typeName)
Returns
System.Object
Parameters
Type | Name |
---|---|
System.String | typeName |
GetModule(Type)
View Source
public static Module GetModule(this Type type)
Returns
System.Reflection.Module
Parameters
Type | Name |
---|---|
System.Type | type |
GetAllProperties(Type)
View Source
public static PropertyInfo[] GetAllProperties(this Type type)
Returns
System.Reflection.PropertyInfo[]
Parameters
Type | Name |
---|---|
System.Type | type |
GetPublicProperties(Type)
View Source
public static PropertyInfo[] GetPublicProperties(this Type type)
Returns
System.Reflection.PropertyInfo[]
Parameters
Type | Name |
---|---|
System.Type | type |
GetAllSerializableProperties(Type)
Includes unfiltered serializable properties suitable for caching. Need to exclude JsConfig.ShouldExcludePropertyType() if serializing at runtime
View Source
public static PropertyInfo[] GetAllSerializableProperties(this Type type)
Returns
System.Reflection.PropertyInfo[]
Parameters
Type | Name |
---|---|
System.Type | type |
GetSerializableProperties(Type)
View Source
public static PropertyInfo[] GetSerializableProperties(this Type type)
Returns
System.Reflection.PropertyInfo[]
Parameters
Type | Name |
---|---|
System.Type | type |
OnlySerializableProperties(PropertyInfo[], Type)
View Source
public static PropertyInfo[] OnlySerializableProperties(this PropertyInfo[] properties, Type type = null)
Returns
System.Reflection.PropertyInfo[]
Parameters
Type | Name |
---|---|
System.Reflection.PropertyInfo[] | properties |
System.Type | type |
GetOnDeserializing<T>()
View Source
public static Func<object, string, object, object> GetOnDeserializing<T>()
Returns
System.Func<System.Object,System.String,System.Object,System.Object>
Type Parameters
T
GetSerializableFields(Type)
View Source
public static FieldInfo[] GetSerializableFields(this Type type)
Returns
System.Reflection.FieldInfo[]
Parameters
Type | Name |
---|---|
System.Type | type |
GetDataContract(Type)
View Source
public static DataContractAttribute GetDataContract(this Type type)
Returns
System.Runtime.Serialization.DataContractAttribute
Parameters
Type | Name |
---|---|
System.Type | type |
GetDataMember(PropertyInfo)
View Source
public static DataMemberAttribute GetDataMember(this PropertyInfo pi)
Returns
System.Runtime.Serialization.DataMemberAttribute
Parameters
Type | Name |
---|---|
System.Reflection.PropertyInfo | pi |
GetDataMember(FieldInfo)
View Source
public static DataMemberAttribute GetDataMember(this FieldInfo pi)
Returns
System.Runtime.Serialization.DataMemberAttribute
Parameters
Type | Name |
---|---|
System.Reflection.FieldInfo | pi |
GetDataMemberName(PropertyInfo)
View Source
public static string GetDataMemberName(this PropertyInfo pi)
Returns
System.String
Parameters
Type | Name |
---|---|
System.Reflection.PropertyInfo | pi |
GetDataMemberName(FieldInfo)
View Source
public static string GetDataMemberName(this FieldInfo fi)
Returns
System.String
Parameters
Type | Name |
---|---|
System.Reflection.FieldInfo | fi |