From 62d417fce7c1daf2b5cec94a49b5401e308784e7 Mon Sep 17 00:00:00 2001 From: waldo1001 Date: Wed, 29 May 2019 12:24:04 +0200 Subject: [PATCH] #85 added and improved method snippet --- snippets/DesignPatterns.json | 67 ++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/snippets/DesignPatterns.json b/snippets/DesignPatterns.json index 619de54..97c8fc5 100644 --- a/snippets/DesignPatterns.json +++ b/snippets/DesignPatterns.json @@ -1,22 +1,75 @@ { + "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;", @@ -24,12 +77,12 @@ "\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;", "}"