typelite


Fluent module name change


The name can be changed like shown in the tutorial:
TypeScript.Definitions()
.ForLoadedAssemblies()
.WithFormatter((type, f) => "I" + ((TypeLite.TsModels.TsClass)type).Name)
How can the module name be changed using fluent formatter?
Right now it isn't possible to globally change the module name using fluent configuration.
However you can change the module name on per class basis:
TypeScript.Definitions().For<MyClass>().ToModule("ModuleName")
As of TypeLite version 1.4.0 the following works fine to change module name:
<# var ts = TypeScript.Definitions()
.WithModuleNameFormatter((module) => "my.module.name");#>
Or you can also play with what's already set as module name to have more control like this:
<# var ts = TypeScript.Definitions()
.WithModuleNameFormatter((module) => "I" + ((TypeLite.TsModels.TsModule)module).Name);#>
There is now an oveload of TypeScriptFluent.WithFormatter that takes TsModuleNameFormatter delegate, so that you can transform module names. For example this code converts module name to the last part of your namespace (MyCompany.Business.Module1 -> Module1):
<#
var ts = TypeScript.Definitions()
.WithFormatter((TsModuleNameFormatter)FormatModuleName)
#>
<#+
string FormatModuleName(string module) {
var parts = module.Split(new []{'.'});
var newModule = parts[parts.Length - 1];
return newModule;
}
#>
Update:
In latest version of TypeLite 1.1.2.0 the API has changed slightly, so the previous example will look like this:
<#
var ts = TypeScript.Definitions().WithModuleNameFormatter((TsModuleNameFormatter)FormatModuleName)
#>
<#+
string FormatModuleName(TsModel module) {
var parts = module.Name.Split(new []{'.'});
var newName = parts[parts.Length - 1];
return newName;
}
#>

Related Links

Typelite “Cannot load file or assembly” Autofac
TypeLite fresh install doesn't work
How to change TypeLite Output Directory
How to setup TypeLite to build types in other projects
Variant type and non, with same name
Ignoring types with fluent configuration in Typelite
IMemberIdentifier missing from TypeLite.TsModels namespace
Typelite Converts All Classes
Fluent module name change
TypeLite generate external modules?
Typelite: Why is Dictionary<string, object> mapped to KeyValuePair and not to any or [index:string]:any

Categories

HOME
knockout.js
typelite
gaming
jms
consul
gallery
openflow
azure-mobile-services
hspi
jodatime
google-cloud-logging
clr
spring-shell
libgit2
pst
kamailio
sipp
dragula
plyr
ruby-daemons
annotation-processing
react-bootstrap-table
materialize
nic
memory-fences
series
sql-execution-plan
advanced-filter
ms-media-foundation
restful-architecture
java-stream
autoencoder
dreamfactory
jfxtras
nppexec
runtimeexception
sbjson
ejml
distributed-caching
oracle-bmcs
vesta
code-push
intellij-lombok-plugin
sonarqube5.2
nusoap
openstack-glance
skip-lists
watir-webdriver
deedle
kendo-editor
rcharts
ltrace
hmmlearn
oracle-fusion-apps
yui3
deviare
okio
visual-studio-monaco
android-4.2-jelly-bean
right-to-left
strpos
uibinder
textblock
teamviewer
gwt-syncproxy
openmrs
wikimedia-commons
teensy
diawi
ui4j
linuxbrew
juniper-network-connect
bjam
bootstrap-wysiwyg
clarion
gflags
shell-extensions
phonegap-facebook-plugin
comctl32
global-scope
rpg
hyperloglog
reference-counting
tabletools
lsa
mute
libxml-js
aero
itunes-sdk
system-requirements
stretch
cakeyframeanimation
asio
haiku
firefly-mv
nosetests
fragment-identifier
webresponse
downgrade
solandra
aspbutton
oracle-pro-c
projectpier
source-code-protection
inversion

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App