From 009907eb27097c08a53f51b1339367e0eeae00d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vercaemst?= Date: Mon, 30 Sep 2024 12:54:25 +0200 Subject: [PATCH] Update snippets.js --- src/contextSnippets/snippets.js | 61 +++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/src/contextSnippets/snippets.js b/src/contextSnippets/snippets.js index 27d7194..efc88f0 100644 --- a/src/contextSnippets/snippets.js +++ b/src/contextSnippets/snippets.js @@ -913,5 +913,62 @@ exports.simpleFunctionSnippets = { "//#endregion MainFunction And Publishers", "//#endregion ${1:MethodName}" ] - } -} \ No newline at end of file + }, + "Snippet: Data Codeunit": { + "prefix": "rdatacodeunit (ALTB)", + "body": [ + "codeunit ${1:Id} \"${2:Feature} Data\"", + "{", + "\tAccess = Public;", + "\tEventSubscriberInstance = Manual;", + "", + "\tinternal procedure Set${3:Value}(New${3:Value}: ${4:DataType})", + "\tbegin", + "\t\tCurr${3:Value} := New${3:Value};", + "\tend;", + "", + "\t/// ", + "\t/// Get the ${3:Value} for the current transaction", + "\t/// ", + "\t/// ${3:Value}", + "\tprocedure Get${3:Value}() ${3:Value}: ${4:DataType}", + "\tbegin", + "\t\tOnGet${3:Value}(${3:Value});", + "\tend;", + "", + "\t[IntegrationEvent(false, false)]", + "\tlocal procedure OnGet${3:Value}(var ${3:Value}: ${4:DataType})", + "\tbegin", + "\tend;", + "", + "\t[EventSubscriber(ObjectType::Codeunit, Codeunit::\"${2} Data\", OnGet${3:Value}, '', false, false)]", + "\tlocal procedure \"${2/(.*)/${0:/pascalcase}/}Data_OnGet${3:Value}\"(var ${3:Value}: ${4:DataType})", + "\tbegin", + "\t\t${3:Value} := Curr${3:Value};", + "\tend;", + "", + "\tvar", + "\t\tCurr${3:Value}: ${4:DataType};", + "", + "\t// 1. Start transaction", + "\t//", + "\t//\tvar", + "\t//\t\t${2/(.*)/${0:/pascalcase}/}Data: codeunit \"${2} Data\";", + "\t//\tbegin", + "\t//\t\tBindSubscription(DocumentLayoutData);", + "\t//\t\t${2/(.*)/${0:/pascalcase}/}Data.Set${3:Value}(${3:Value})", + "\t//\tend;", + "\t//", + "\t// 2. Inside transaction", + "", + "\t//\tvar", + "\t//\t\t${2/(.*)/${0:/pascalcase}/}Data: codeunit \"${2} Data\";", + "\t//\t\t${3:Value}: ${4:DataType};", + "\t//\tbegin", + "\t//\t\t${2/(.*)/${0:/pascalcase}/}Data.Get${3:Value}(${3:Value})", + "\t//\tend;", + "}" + ], + "description": "Data Codeunit" + } +}