Interface ITypeParser
Provides helpers to create IType type descriptor from Type or string with type name. Also provides helpers to parse namespace names.
public interface ITypeParser
- Extension Methods
Methods
Parse(string, bool)
Parse type from type name. Type name should be a full type name in following format:
- namespaces should be separated by dot:
ns1.ns2.type
- nested types should be separated by plus:
ns1.ns2.type+nestest_type1+nested_type2
- genric type arguments should be enclosed in <> and separated by comma:
ns.type<ns.type1, ns.type2<ns.type1>, ns.type3>
- open generic types allowed:
ns.type<,,>
- nullability (including reference types) should be indicated by ?:
ns.type<T1?>?
- type aliases, arrays and dynamic types not supported
- generic type arguments should be real types
IType Parse(string typeName, bool valueType)
Parameters
typeName
stringString with type name.
valueType
boolIndicate that parsed type is value type or reference type. Applied only to main type. Nested types (array elements and generic type arguments parsed as value types).
Returns
- IType
Parsed type descriptor.
Parse(Type)
IType Parse(Type type)
Parameters
type
TypeType to parse.
Returns
ParseNamespaceOrRegularTypeName(string, bool)
Parse (multi-part) namespace or type name (with namespace) into collection of identifiers for each namespace/type name element.
CodeIdentifier[] ParseNamespaceOrRegularTypeName(string name, bool generated)
Parameters
name
stringString with namespace or type name. Type name shouldn't contain anything except namespace and namespace (no array brackets, generic argument list). Name components should be separated by dot (.).
generated
boolWhen
true
,name
contains generated namespace/type name and could be modified on name conflict.
Returns
- CodeIdentifier[]
Namespace/type name elements.
Parse<T>()
Creates IType type descriptor from T
type.
IType Parse<T>()
Returns
Type Parameters
T
Type to parse.