Working with the document registration number

Script for adding a registration number to the document name.
For the script to work, add the assemblies:
EleWise.ELMA.Documents
EleWise.ELMA.Documents.Docflow
Namespace:
using EleWise.ELMA.Documents.Models;
Script text:
//write the data from the document record card to the RegCard variable:
var regCard = ((IDocumentExt)context.Doc).RegistrationCard.FirstOrDefault();
if (regCard != null)   
//write the registration number to the Name attribute of the document:                                
{
    context.Doc.Name=regCard.RegNumber;
}