Skip to content

Commit

Permalink
#85 added and improved method snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
waldo1001 committed May 29, 2019
1 parent 15227e3 commit 62d417f
Showing 1 changed file with 60 additions and 7 deletions.
67 changes: 60 additions & 7 deletions snippets/DesignPatterns.json
@@ -1,35 +1,88 @@
{
"Snippet (CRS): Method Codeunit": {
"description": "Snippet (CRS): Method Codeunit",
"prefix": "tcodeunit (CRS: Method)",
"body": [
"codeunit ${1:Id} \"${2:FullMethodName} Meth\"",
"{",
"\tprocedure ${3:ShortMethodName}(var ${4:VarName}: Record ${5:TableName}; HideDialog: Boolean);",
"\tvar",
"\t\tHandled: Boolean;",
"\tbegin",
"\t\tif not Confirm${3:ShortMethodName}(${4:VarName}, HideDialog) then exit;",
"\t\tOnBefore${3:ShortMethodName}(${4:VarName}, Handled);",
"\t\tDo${3:ShortMethodName}(${4:VarName}, Handled);",
"\t\tOnAfter${3:ShortMethodName}(${4:VarName});",
"\t\tAcknowledge${3:ShortMethodName}(${4:VarName}, HideDialog)",
"\tend;",
"",
"\tlocal procedure Do${3:ShortMethodName}(var ${4:VarName}: Record ${5:TableName}; var Handled: Boolean);",
"\tbegin",
"\t\tif Handled then",
"\t\t\texit;",
"\t\t",
"\t\t${0}",
"\tend;",
"",
"\tlocal procedure Confirm${3:ShortMethodName}(var ${4:VarName}: Record ${5:TableName}; HideDialog: Boolean): Boolean",
"\tvar",
"\t\tConfirmQst: label 'Are You Sure?';",
"\tbegin",
"\t\tif Not GuiAllowed or HideDialog then exit(true);",
"\t\texit(Confirm(ConfirmQst));",
"\tend;",
"",
"\tlocal procedure Acknowledge${3:ShortMethodName}(var ${4:VarName}: Record ${5:TableName}; HideDialog: Boolean)",
"\tvar",
"\t\tAcknowledgeMsg: label 'You successfully executed \"${2:FullMethodName}\"';",
"\tbegin",
"\t\tif Not GuiAllowed or HideDialog then exit;",
"\t\tMessage(AcknowledgeMsg);",
"\tend;",
"",
"\t[IntegrationEvent(false, false)]",
"\tlocal procedure OnBefore${3:ShortMethodName}(var ${4:VarName}: Record ${5:TableName}; var Handled: Boolean);",
"\tbegin",
"\tend;",
"",
"\t[IntegrationEvent(false, false)]",
"\tlocal procedure OnAfter${3:ShortMethodName}(var ${4:VarName}: Record ${5:TableName});",
"\tbegin",
"\tend;",
"}"
]
},
"Snippet (CRS): Method Codeunit (No UI)": {
"description": "Snippet (CRS): Method Codeunit (No UI)",
"prefix": "tcodeunit (CRS: Method - No UI)",
"body": [
"codeunit ${1:id} \"${2:Name} Meth\"",
"{",
"\tprocedure ${3:MethodName}();",
"\tprocedure ${3:MethodName}(var ${4:VarName}: Record ${5:TableName});",
"\tvar",
"\t\tHandled : Boolean;",
"\tbegin",
"\t\tOnBefore${3:MethodName}(Handled);",
"\t\tOnBefore${3:MethodName}(${4:VarName}, Handled);",
"",
"\t\tDo${3:MethodName}(Handled);",
"\t\tDo${3:MethodName}(${4:VarName}, Handled);",
"",
"\t\tOnAfter${3:MethodName}();",
"\t\tOnAfter${3:MethodName}(${4:VarName});",
"\tend;",
"",
"\tlocal procedure Do${3:MethodName}(var Handled: Boolean);",
"\tlocal procedure Do${3:MethodName}(var ${4:VarName}: Record ${5:TableName}; var Handled: Boolean);",
"\tbegin",
"\t\tif Handled then",
"\t\t\texit;",
"",
"\tend;",
"",
"\t[IntegrationEvent(false, false)]",
"\tlocal procedure OnBefore${3:MethodName}(var Handled : Boolean);",
"\tlocal procedure OnBefore${3:MethodName}(var ${4:VarName}: Record ${5:TableName}; var Handled : Boolean);",
"\tbegin",
"\tend;",
"",
"\t[IntegrationEvent(false, false)]",
"\tlocal procedure OnAfter${3:MethodName}();",
"\tlocal procedure OnAfter${3:MethodName}(var ${4:VarName}: Record ${5:TableName});",
"\tbegin",
"\tend;",
"}"
Expand Down

0 comments on commit 62d417f

Please sign in to comment.