Documentation

Code model

Attribute

Represents an attribute, not the attribute class, but the declared attribute usage on for instance a class.
Attributes are implicitly convertible to string, a conversion will return the name of the attribute.

Properties
Property Description Returns
FullName The full original name of the attribute including namespace and containing class names.
e.g. App.Attributes.RouteAttribute
string
Name The name of the attribute excluding the "Attribute"-suffix.
e.g. Route
string
name The name of the attribute excluding the "Attribute"-suffix, camel cased.
e.g. route
string
Parent The parent context of the attribute. Item
Value The value of the attribute as string. string

AttributeCollection

Represents a collection of attributes.


Class

Represents a C# class.
Classes are implicitly convertible to string, a conversion will return the name of the class.

Properties
Property Description Returns
Attributes All attributes declared on the class. AttributeCollection
BaseClass The base class of the class.
Returns null if the class inherits from System.Object.
Class
Constants All public constants defined in the class. ConstantCollection
ContainingClass The containing class of the class if it's nested. Class
Fields All public fields defined in the class. FieldCollection
FullName The full original name of the class including namespace, type parameters and containing class names.
e.g. App.Models.CustomerModel
string
Interfaces All interfaces implemented by the class. InterfaceCollection
IsGeneric Determines if the class is generic. bool
Methods All public methods defined in the class. MethodCollection
Name The name of the class excluding type parameters.
e.g. CustomerModel
string
name The name of the class excluding type parameters, camel cased.
e.g. customerModel
string
Namespace The namespace of the class.
e.g. App.Models
string
NestedClasses All public classes defined in the class. ClassCollection
NestedEnums All public enums defined in the class. EnumCollection
NestedInterfaces All public interfaces defined in the class. InterfaceCollection
Parent The parent context of the class. Item
Properties All public properties defined in the class. PropertyCollection
TypeArguments All generic type arguments of the class.
TypeArguments are the specified arguments for the TypeParametes on a generic class e.g. <string>.
(In Visual Studio 2013 TypeParameters and TypeArguments are the same)
TypeParameterCollection
TypeParameters All generic type parameters of the class.
TypeParameters are the type placeholders of a generic class e.g. <T>.
(In Visual Studio 2013 TypeParameters and TypeArguments are the same)
TypeParameterCollection

ClassCollection

Represents a collection of classes.


Constant

Represents a constant.
Constants are implicitly convertible to string, a conversion will return the name of the constant.

Properties
Property Description Returns
Attributes All attributes declared on the constant. AttributeCollection
FullName The full original name of the constant including namespace, type parameters and containing class names.
e.g. App.Models.CustomerModel.TempPath
string
Name The name of the constant.
e.g. TempPath
string
name The name of the constant, camel cased.
e.g. tempPath
string
Parent The parent context of the constant. Item
Type The type of the constant. Type

ConstantCollection

Represents a collection of constants.


Enum

Represents a C# enum.
Enums are implicitly convertible to string, a conversion will return the name of the enum.

Properties
Property Description Returns
Attributes All attributes declared on the enum. AttributeCollection
ContainingClass The containing class of the enum if it's nested. Class
IsFlags Determines if the enum is decorated with the Flags attribute. bool
FullName The full original name of the enum including namespace, type parameters and containing class names.
e.g. App.Enums.AddressType
string
Name The name of the enum.
e.g. AddressType
string
name The name of the enum, camel cased.
e.g. addressType
string
Namespace The namespace of the enum.
e.g. App.Enums
string
Parent The parent context of the enum. Item
Values All values defined in the enum. EnumValueCollection

EnumCollection

Represents a collection of enums.


EnumValue

Represents an enum value.
EnumValues are implicitly convertible to string, a conversion will return the name of the enum value.

Properties
Property Description Returns
Attributes All attributes declared on the enum value. AttributeCollection
FullName The full original name of the enum including namespace, type parameters and containing class names.
e.g. App.Enums.AddressType.Shipping
string
Name The name of the enum.
e.g. Shipping
string
name The name of the enum, camel cased.
e.g. shipping
string
Value The numeric value of the enum value. int

EnumValueCollection

Represents a collection of enum values.


Field

Represents a field.
Fields are implicitly convertible to string, a conversion will return the name of the field.

Properties
Property Description Returns
Attributes All attributes declared on the field. AttributeCollection
FullName The full original name of the field including namespace, type parameters and containing class names.
e.g. App.Models.CustomerModel.ShippingAddress
string
Name The name of the field.
e.g. ShippingAddress
string
name The name of the field, camel cased.
e.g. shippingAddress
string
Parent The parent context of the field. Item
Type The type of the field. Type

FieldCollection

Represents a collection of fields.


File

Represents a C# code file.
File is the root context in the Typewriter code model.

Properties
Property Description Returns
FullName The full path of the file.
e.g. C:\Dev\App\Models\CustomerModel.cs
string
Name The name of the file.
e.g. CustomerModel.cs
string
Classes All public classes defined in the file. ClassCollection
Enums All public enums defined in the file. EnumCollection
Interfaces All public interfaces defined in the file. InterfaceCollection

Interface

Represents a C# interface.
Interfaces are implicitly convertible to string, a conversion will return the name of the interface.

Properties
Property Description Returns
Attributes All attributes declared on the interface. AttributeCollection
ContainingClass The containing class of the interface if it's nested. Class
FullName The full original name of the interface including namespace, type parameters and containing class names.
e.g. App.Models.ICustomerModel
string
Interfaces All interfaces implemented by the interface. InterfaceCollection
IsGeneric Determines if the interface is generic. bool
Methods All methods defined in the interface. MethodCollection
Name The name of the interface excluding type parameters.
e.g. ICustomerModel
string
name The name of the interface excluding type parameters, camel cased.
e.g. iCustomerModel
string
Namespace The namespace of the interface.
e.g. App.Models
string
Parent The parent context of the interface. Item
Properties All properties defined in the interface. PropertyCollection
TypeArguments All generic type arguments of the interface.
TypeArguments are the specified arguments for the TypeParametes on a generic interface e.g. <string>.
(In Visual Studio 2013 TypeParameters and TypeArguments are the same)
TypeParameterCollection
TypeParameters All generic type parameters of the interface.
TypeParameters are the type placeholders of a generic interface e.g. <T>.
(In Visual Studio 2013 TypeParameters and TypeArguments are the same)
TypeParameterCollection

InterfaceCollection

Represents a collection of interfaces.


Method

Represents a method.
Methods are implicitly convertible to string, a conversion will return the name of the method.

Properties
Property Description Returns
Attributes All attributes declared on the method. AttributeCollection
FullName The full original name of the method including namespace, type parameters and containing class names.
e.g. App.Models.CustomerModel.GetName
string
IsGeneric Determines if the method is generic. bool
Name The name of the method excluding type parameters.
e.g. GetName
string
name The name of the method excluding type parameters, camel cased.
e.g. getName
string
Parameters All parameters of method. ParameterCollection
Parent The parent context of the method. Item
Type The return type of the method. Type
TypeParameters All generic type parameters of the method.
TypeParameters are the type placeholders of a generic method e.g. <T>.
TypeParameterCollection

MethodCollection

Represents a collection of methods.


Parameter

Represents a method parameter.
Parameters are implicitly convertible to string, a conversion will return the name of the parameter.

Properties
Property Description Returns
Attributes All attributes declared on the parameter. AttributeCollection
FullName The full original name of the parameter including namespace, type parameters and containing class names.
e.g. App.Models.CustomerModel.GetName.id
string
Name The name of the parameter.
e.g. id
string
name The name of the parameter, camel cased.
e.g. id
string
Parent The parent context of the parameter. Item
Type The type of the parameter. Type

ParameterCollection

Represents a collection of parameters.


Property

Represents a property.
Properties are implicitly convertible to string, a conversion will return the name of the property.

Properties
Property Description Returns
Attributes All attributes declared on the property. AttributeCollection
FullName The full original name of the property including namespace, type parameters and containing class names.
e.g. App.Models.CustomerModel.Orders
string
HasGetter Determines if the property has a getter bool
HasSetter Determines if the property has a setter bool
Name The name of the property.
e.g. Orders
string
name The name of the property, camel cased.
e.g. orders
string
Parent The parent context of the property. Item
Type The type of the property. Type

PropertyCollection

Represents a collection of properties.


Type

Represents a type.
Types are implicitly convertible to string, a conversion will return the name of the type.

Properties
Property Description Returns
Attributes All attributes declared on the type. AttributeCollection
BaseClass The base class of the type. Class
Constants All constants defined in the type. ConstantCollection
ContainingClass The containing class of the type if it's nested. Class
Default The default value of the type.
e.g. strings returns null, integers returns 0 and IEnumerable<CustomerModel> returns []
string
Fields All fields defined in the type. FieldCollection
FullName The full original name of the type including namespace, type parameters and containing class names.
e.g. System.Int32
string
Interfaces All interfaces implemented by the type.
(In Visual Studio 2013 Interfaces are not available on Types)
InterfaceCollection
IsDate Determines if the type is a DateTime or DateTimeOffset. bool
IsEnum Determines if the type is an enum. bool
IsEnumerable Determines if the type is enumerable. bool
IsGeneric Determines if the type is generic. bool
IsGuid Determines if the type is a Guid. (Type.Name returns string for Guids) bool
IsNullable Determines if the type is nullable. bool
IsPrimitive Determines if the type is primitive. bool
IsTimeSpan Determines if the type is a TimeSpan. (Type.Name returns string for TimeSpans) bool
Methods All methods defined in the type. MethodCollection
Name The name of the type converted to a TypeScript firendly representation including type arguments.
e.g. number
string
name The name of the type converted to a TypeScript firendly representation including type arguments, camel cased.
e.g. number
string
Namespace The namespace of the type.
e.g. System
string
NestedClasses All classes defined in the type. ClassCollection
NestedEnums All enums defined in the type. EnumCollection
NestedInterfaces All interfaces defined in the type. InterfaceCollection
OriginalName The original name of the type as it was specified in C#.
e.g. int
string
Parent The parent context of the type. Item
Properties All properties defined in the type. PropertyCollection
TypeArguments All generic type parameters of the type. TypeArguments are the specified arguments for the TypeParametes on a generic type e.g. <string>.
(In Visual Studio 2013 TypeParameters and TypeArguments are the same)
TypeCollection
TypeParameters All generic type parameters of the type.
TypeParameters are the type placeholders of a generic type e.g. <T>.
(In Visual Studio 2013 TypeParameters and TypeArguments are the same)
TypeParameterCollection

TypeCollection

Represents a collection of types. Calling ToString() on a TypeCollection will return a string with the names of all Types in the collection surrounded by "<" and ">" e.g. <string, number>. If the collection is empty it will return an emty string.


TypeParameter

Represents a generic type parameter on a class, interface or method.
TypeParameters are implicitly convertible to string, a conversion will return the name of the type parameter.

Properties
Property Description Returns
Name The name of the type parameter.
e.g. T
string
name The name of the type parameter, camel cased.
e.g. t
string
Parent The parent context of the type parameter. Item

TypeParameterCollection

Represents a collection of type parameters. Calling ToString() on a TypeParameterCollection will return a string with the names of all TypeParameters in the collection surrounded by "<" and ">" e.g. <T1, T2>. If the collection is empty it will return an emty string.


Extensions

Typewriter.Extensions.WebApi

Extension methods for working with ASP.NET Web API Controllers

Methods
Method Description Returns
HttpMethod Returns the http method from a Web API action.
The http method is extracted from Http* or AcceptVerbs attribute or by naming convension if no attributes are specified.
string
RequestData Creates an object literal containing the parameters that should be sent in the request body of a Web API request. If no parameters are required the literal "null" is returned. string
Route Returns the route for the Web API action based on route attributes (or "api/{controller}/{id?}" if no attributes are present). string
Url Returns the url for the Web API action based on route attributes (or "api/{controller}/{id?}" if no attributes are present). Route parameters are converted to TypeScript string interpolation syntax by prefixing all parameters with $ e.g. ${id}. Optional parameters are added as QueryString parameters for GET and HEAD requests. string