Sitefinity 4.0 Fluent API
Outline Introductory example Few words about Fluent API Fluent API vs. Native API Fluent API settings Named transactions and “using() { }” syntax Child facades Three random examples Future developments
Introductory example Create a news item
Few words about Fluent API “Fluent interface” – coined by Eric Evans and Martin Fowler Aims to provide for more readable code Method chaining and state Methods always return the instance that defines them (context) Context can be changed by returning different façade or terminated by returning void Resources: http://en.wikipedia.org/wiki/Fluent_interface
Fluent API vs. Native API Fluent API will NOT replace Native API – it’s an alternative In Sitefinity 4.0 Fluent API aims to cover 80% of most featured functionality For very complex operations, Native API (managers) ought to be used Fluent API is implemented as a façade over one or more managers
Fluent API settings Fluent API provides a way to set provider names and transaction name.
Named transactions and “using() { }” syntax Named transactions allow you to commit work made in multiple provides (e.g. generic content, events, pages) in a single call using() { } syntax provides a way to write code for different types and commit in a single call upon the exit of the using block
Child facades Child facades examples: Blog façade > Blog post façade Blog post façade > Comment facade Page façade > Control façade Done() method for exisiting the child facade
Three random examples Create a page Add dynamic field to NewsItem Create a completely new persistent type (e.g. like in forms module)
Future developments Cover all the managers with Fluent API facades Support for dynamic facades App.WorkWith<MyBlogFacade>() Code injection through Unity