SharePoint: CSOM break folder permissions

Consider a scenario where you need to break permissions of a folder using client object model (CSOM) in SharePoint. The code below creates a folder in the document library, breaks its permissions and gives a particular user Contribute permissions on it. The main thing to note here is that, in CSOM Folder does not     have BreakRoleInheritance or Item method. It has a property named ListItemAllFields. This is used to break permissions as shown: 
using (var clientContext = new ClientContext("http://sitename"))
    Web web = clientContext.Web;
    List list = web.Lists.GetByTitle("Documents");
    Folder newFolder = list.RootFolder.Folders.Add("FolderName");
    newFolder.ListItemAllFields.BreakRoleInheritance(false, true);
    var role = new RoleDefinitionBindingCollection(clientContext);
    User user = web.EnsureUser("contoso\\adamb");
    newFolder.ListItemAllFields.RoleAssignments.Add(user, role);
profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts