/// <summary>
        /// Renders a dialog step
        /// </summary>
        /// <param name="data">Dialog Step Data</param>
        /// <param name="flexFieldObject">Flex Field to which the dialog belongs</param>
        /// <returns>Dialog Step Render Result</returns>
        public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, FlexFieldObject flexFieldObject)
        {
            ActionNode actionNode = data.Action;

            if (actionNode == null)
            {
                return(null);
            }

            IActionRenderer actionRenderer = GetActionRenderForNode(actionNode);

            ExportDialogDataChild nextStep = null;

            if (data.Children != null)
            {
                if (actionRenderer != null)
                {
                    nextStep = actionRenderer.GetNextStep(data.Children);
                }
                else
                {
                    nextStep = data.Children.FirstOrDefault();
                }
            }

            string actionContent = await BuildActionContent(actionRenderer, actionNode, data, flexFieldObject);

            ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleAction);

            ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult();

            renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ActionContent).Replace(template.Code, actionContent);
            renderResult.StepCode = ReplaceBaseStepPlaceholders(renderResult.StepCode, data, nextStep != null ? nextStep.Child : null);

            return(renderResult);
        }
        /// <summary>
        /// Fills the placeholders
        /// </summary>
        /// <param name="template">Template to use</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="parsedData">Parsed config data</param>
        /// <param name="valueObject">Value object to use</param>
        /// <param name="actionOperator">Action operator to use</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="curStep">Current step that is rendered</param>
        /// <param name="nextStep">Next step that is being rendered</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <param name="stepRenderer">Action Step renderer</param>
        /// <returns>Filled placeholders</returns>
        protected override async Task <string> FillPlaceholders(ExportTemplate template, ExportPlaceholderErrorCollection errorCollection, ValueFieldActionData parsedData, IFlexFieldExportable valueObject, string actionOperator,
                                                                FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            FlexField exportField = DialogFlexFieldUtil.GetFlexField(valueObject, parsedData.FieldId);

            if (exportField == null)
            {
                errorCollection.AddErrorFlexField(parsedData.FieldName, valueObject.Name);
                return(string.Empty);
            }

            string actionCode = template.Code;

            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ValueName).Replace(actionCode, m => {
                return(DialogFlexFieldUtil.GetFieldName(exportField, parsedData.FieldName, errorCollection));
            });
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(actionCode, actionOperator);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsSetTo_Start, Placeholder_OperatorIsSetTo_End, parsedData.Operator == "=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotSetTo_Start, Placeholder_OperatorIsNotSetTo_End, parsedData.Operator != "=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsAdd_Start, Placeholder_OperatorIsAdd_End, parsedData.Operator == "+=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotAdd_Start, Placeholder_OperatorIsNotAdd_End, parsedData.Operator != "+=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsSubstract_Start, Placeholder_OperatorIsSubstract_End, parsedData.Operator == "-=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotSubstract_Start, Placeholder_OperatorIsNotSubstract_End, parsedData.Operator != "-=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsMultiply_Start, Placeholder_OperatorIsMultiply_End, parsedData.Operator == "*=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotMultiply_Start, Placeholder_OperatorIsNotMultiply_End, parsedData.Operator != "*=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsDivide_Start, Placeholder_OperatorIsDivide_End, parsedData.Operator == "/=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotDivide_Start, Placeholder_OperatorIsNotDivide_End, parsedData.Operator != "/=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_ValueIsString_Start, Placeholder_ValueIsString_End, exportField.FieldType != ExportConstants.FlexFieldType_Number);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_ValueIsNumber_Start, Placeholder_ValueIsNumber_End, exportField.FieldType == ExportConstants.FlexFieldType_Number);
            actionCode = ExportUtil.RenderPlaceholderIfFuncTrue(actionCode, Placeholder_ValueNameEquals_Start, Placeholder_ValueNameEquals_End, m => {
                string searchedFieldName = m.Groups[1].Value;
                searchedFieldName        = searchedFieldName.ToLowerInvariant();
                string fieldName         = string.Empty;
                if (!string.IsNullOrEmpty(exportField.Name))
                {
                    fieldName = exportField.Name.ToLowerInvariant();
                }
                return(fieldName == searchedFieldName);
            });
            actionCode = ExportUtil.RenderPlaceholderIfFuncTrue(actionCode, Placeholder_ValueNameNotEquals_Start, Placeholder_ValueNameNotEquals_End, m => {
                string searchedFieldName = m.Groups[1].Value;
                searchedFieldName        = searchedFieldName.ToLowerInvariant();
                string fieldName         = string.Empty;
                if (!string.IsNullOrEmpty(exportField.Name))
                {
                    fieldName = exportField.Name.ToLowerInvariant();
                }
                return(fieldName != searchedFieldName);
            });
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ValueChange).Replace(actionCode, m => {
                if (exportField.FieldType != ExportConstants.FlexFieldType_Number)
                {
                    return(ExportUtil.EscapeCharacters(parsedData.ValueChange, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));
                }

                return(parsedData.ValueChange);
            });

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, GetFlexFieldExportObjectType());

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = await _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData);

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
 /// <summary>
 /// Replaces the node id
 /// </summary>
 /// <param name="code">Code to update</param>
 /// <param name="curStep">Cur Step</param>
 /// <returns>Updated</returns>
 public string ReplaceNodeId(string code, ExportDialogData curStep)
 {
     code = ExportUtil.BuildPlaceholderRegex(Placeholder_NodeId).Replace(code, curStep.NodeIndex.ToString());
     return(code);
 }
        /// <summary>
        /// Fills the Flex Field Placeholders
        /// </summary>
        /// <param name="code">Code to fill</param>
        /// <param name="flexFieldObject">Flex Field Object</param>
        /// <param name="objectType">Object Type</param>
        /// <param name="data">Export Data</param>
        /// <returns>Filled Code</returns>
        private async Task <string> FillFlexFieldPlaceholders(string code, IFlexFieldExportable flexFieldObject, string objectType, ExportObjectData data)
        {
            GoNorthProject project = await _exportCachedDbAccess.GetUserProject();

            ExportSettings exportSettings = await _exportCachedDbAccess.GetExportSettings(project.Id);

            HashSet <string> usedFields = new HashSet <string>();

            code = ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_Name)).Replace(code, flexFieldObject.Name);
            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_Field_Value_Equals_Start), BuildFinalPlaceholder(Placeholder_Field_Value_Equals_End), m => {
                string fieldName = m.Groups[1].Value;
                FlexField field  = FindFlexField(flexFieldObject, fieldName);
                if (field == null)
                {
                    return(false);
                }
                return(m.Groups[2].Value == field.Value);
            });
            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_Field_Value_NotEquals_Start), BuildFinalPlaceholder(Placeholder_Field_Value_NotEquals_End), m => {
                string fieldName = m.Groups[1].Value;
                FlexField field  = FindFlexField(flexFieldObject, fieldName);
                if (field == null)
                {
                    return(true);
                }
                return(m.Groups[2].Value != field.Value);
            });
            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_FlexField_HasField_Start), BuildFinalPlaceholder(Placeholder_FlexField_HasField_End), m => {
                string fieldName = m.Groups[1].Value;
                FlexField field  = FindFlexField(flexFieldObject, fieldName);
                return(field != null);
            });
            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_FlexField_NotHasField_Start), BuildFinalPlaceholder(Placeholder_FlexField_NotHasField_End), m => {
                string fieldName = m.Groups[1].Value;
                FlexField field  = FindFlexField(flexFieldObject, fieldName);
                return(field == null);
            });
            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_FlexField_FieldIsBlank_Start), BuildFinalPlaceholder(Placeholder_FlexField_FieldIsBlank_End), m => {
                string fieldName = m.Groups[1].Value;
                FlexField field  = FindFlexField(flexFieldObject, fieldName);
                if (field == null)
                {
                    return(true);
                }

                return(string.IsNullOrEmpty(field.Value));
            });
            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_FlexField_FieldIsNotBlank_Start), BuildFinalPlaceholder(Placeholder_FlexField_FieldIsNotBlank_End), m => {
                string fieldName = m.Groups[1].Value;
                FlexField field  = FindFlexField(flexFieldObject, fieldName);
                if (field == null)
                {
                    return(false);
                }

                return(!string.IsNullOrEmpty(field.Value));
            });
            code = await ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_Name_LangKey)).ReplaceAsync(code, async m => {
                // Run in function to only create language key if required
                string key = await _languageKeyGenerator.GetFlexFieldNameKey(flexFieldObject.Id, flexFieldObject.Name, objectType);
                return(key);
            });

            code = ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_Field_Value)).Replace(code, m => {
                string fieldName = m.Groups[1].Value;
                FlexField field  = FindFlexField(flexFieldObject, fieldName);
                if (field != null)
                {
                    usedFields.Add(field.Id);
                    return(EscapedFieldValue(field, exportSettings));
                }

                _errorCollection.AddErrorFlexField(fieldName, flexFieldObject.Name);
                return("<<" + flexFieldObject.Name + "[" + fieldName + "] MISSING>>");
            });
            code = ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_Field_LangKey)).Replace(code, m => {
                string fieldName = m.Groups[1].Value;
                FlexField field  = FindFlexField(flexFieldObject, fieldName);
                if (field != null && (field.FieldType == ExportConstants.FlexFieldType_String || field.FieldType == ExportConstants.FlexFieldType_Option))
                {
                    usedFields.Add(field.Id);
                    return(BuildFlexFieldLangKey(flexFieldObject, field, objectType));
                }

                _errorCollection.AddErrorFlexField(fieldName, flexFieldObject.Name);
                return("<<" + flexFieldObject.Name + "[" + fieldName + "] MISSING>>");
            });

            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_HasUnusedFields_Start), BuildFinalPlaceholder(Placeholder_HasUnusedFields_End), m => {
                return(flexFieldObject.Fields.Where(f => !usedFields.Contains(f.Id)).Any());
            });
            code = ExportUtil.BuildRangePlaceholderRegex(BuildFinalPlaceholder(Placeholder_UnusedFields_Start), BuildFinalPlaceholder(Placeholder_UnusedFields_End)).Replace(code, m => {
                List <FlexField> fieldsToUse = flexFieldObject.Fields.Where(f => !usedFields.Contains(f.Id)).ToList();
                return(BuildFlexFieldList(m.Groups[1].Value, fieldsToUse, flexFieldObject, exportSettings, objectType));
            });
            code = ExportUtil.BuildRangePlaceholderRegex(BuildFinalPlaceholder(Placeholder_AllFields_Start), BuildFinalPlaceholder(Placeholder_AllFields_End)).Replace(code, m => {
                return(BuildFlexFieldList(m.Groups[1].Value, flexFieldObject.Fields, flexFieldObject, exportSettings, objectType));
            });
            code = ExportUtil.BuildRangePlaceholderRegex(Placeholder_FlexFieldList_Start, Placeholder_FlexFieldList_End).Replace(code, m => {
                return(BuildFlexFieldList(m.Groups[1].Value, flexFieldObject.Fields, flexFieldObject, exportSettings, objectType));
            });
            code = await ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_UnusedFields), ExportConstants.ListIndentPrefix).ReplaceAsync(code, async m => {
                return(await RenderAttributeList(project, FilterInvalidFlexFields(flexFieldObject.Fields.Where(f => !usedFields.Contains(f.Id)).ToList()), data, m.Groups[1].Value));
            });

            code = await ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_AllFields), ExportConstants.ListIndentPrefix).ReplaceAsync(code, async m => {
                return(await RenderAttributeList(project, FilterInvalidFlexFields(flexFieldObject.Fields), data, m.Groups[1].Value));
            });


            return(code);
        }
        /// <summary>
        /// Builds a condition element from parsed data
        /// </summary>
        /// <param name="template">Export template to use</param>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="project">Project</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Condition string</returns>
        public override async Task <string> BuildConditionElementFromParsedData(ExportTemplate template, ValueFieldConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            IFlexFieldExportable valueObject = await GetValueObject(parsedData, flexFieldObject, errorCollection);

            if (valueObject == null)
            {
                return(string.Empty);
            }

            FlexField exportField = DialogFlexFieldUtil.GetFlexField(valueObject, parsedData.FieldId);

            if (exportField == null)
            {
                errorCollection.AddErrorFlexField(parsedData.FieldName, valueObject.Name);
                return(string.Empty);
            }

            string conditionCode = template.Code;

            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_IsOperatorPrimitiveStart, Placeholder_IsOperatorPrimitiveEnd, ConditionRenderingUtil.IsConditionOperatorPrimitiveOperator(parsedData.Operator));
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_IsOperatorNonPrimitiveStart, Placeholder_IsOperatorNonPrimitiveEnd, !ConditionRenderingUtil.IsConditionOperatorPrimitiveOperator(parsedData.Operator));
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ValueName).Replace(conditionCode, m => {
                return(DialogFlexFieldUtil.GetFieldName(exportField, parsedData.FieldName, errorCollection));
            });
            string operatorCode = await ConditionRenderingUtil.GetCompareOperatorFromTemplate(_defaultTemplateProvider, project, parsedData.Operator, errorCollection);

            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(conditionCode, operatorCode);
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_ValueIsString_Start, Placeholder_ValueIsString_End, exportField.FieldType != ExportConstants.FlexFieldType_Number);
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_ValueIsNumber_Start, Placeholder_ValueIsNumber_End, exportField.FieldType == ExportConstants.FlexFieldType_Number);
            conditionCode = ExportUtil.RenderPlaceholderIfFuncTrue(conditionCode, Placeholder_ValueNameEquals_Start, Placeholder_ValueNameEquals_End, m => {
                string searchedFieldName = m.Groups[1].Value;
                searchedFieldName        = searchedFieldName.ToLowerInvariant();
                string fieldName         = string.Empty;
                if (!string.IsNullOrEmpty(exportField.Name))
                {
                    fieldName = exportField.Name.ToLowerInvariant();
                }
                return(fieldName == searchedFieldName);
            });
            conditionCode = ExportUtil.RenderPlaceholderIfFuncTrue(conditionCode, Placeholder_ValueNameNotEquals_Start, Placeholder_ValueNameNotEquals_End, m => {
                string searchedFieldName = m.Groups[1].Value;
                searchedFieldName        = searchedFieldName.ToLowerInvariant();
                string fieldName         = string.Empty;
                if (!string.IsNullOrEmpty(exportField.Name))
                {
                    fieldName = exportField.Name.ToLowerInvariant();
                }
                return(fieldName != searchedFieldName);
            });
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_CompareValue).Replace(conditionCode, m => {
                if (exportField.FieldType != ExportConstants.FlexFieldType_Number)
                {
                    return(ExportUtil.EscapeCharacters(parsedData.CompareValue, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));
                }

                return(parsedData.CompareValue);
            });

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, GetFlexFieldExportObjectType());

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            conditionCode = await _flexFieldPlaceholderResolver.FillPlaceholders(conditionCode, flexFieldExportData);

            return(conditionCode);
        }
        /// <summary>
        /// Fills the export snippet placeholders
        /// </summary>
        /// <param name="code">Code to fill</param>
        /// <param name="exportObject">Export object</param>
        /// <param name="flexFieldObject">Flex field object</param>
        /// <returns>Updated code</returns>
        private async Task <string> FillExportSnippetPlaceholders(string code, IExportSnippetExportable exportObject, FlexFieldObject flexFieldObject)
        {
            HashSet <string>           usedExportSnippets = new HashSet <string>();
            List <ObjectExportSnippet> exportSnippets     = await _cachedDbAccess.GetObjectExportSnippetsByObject(exportObject.Id);

            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasAnyCodeSnippet_Start, Placeholder_HasAnyCodeSnippet_End, exportSnippets.Count > 0);
            code = ExportUtil.RenderPlaceholderIfTrue(code, Placeholder_HasNotAnyCodeSnippet_Start, Placeholder_HasNotAnyCodeSnippet_End, exportSnippets.Count == 0);
            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, Placeholder_HasCodeSnippet_Start, Placeholder_HasCodeSnippet_End, (m) =>
            {
                string snippetName = m.Groups[1].Value;
                snippetName        = snippetName.ToLowerInvariant();

                return(exportSnippets.Any(e => e.SnippetName.ToLowerInvariant() == snippetName));
            });
            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, Placeholder_HasNotCodeSnippet_Start, Placeholder_HasNotCodeSnippet_End, (m) =>
            {
                string snippetName = m.Groups[1].Value;
                snippetName        = snippetName.ToLowerInvariant();

                return(!exportSnippets.Any(e => e.SnippetName.ToLowerInvariant() == snippetName));
            });

            code = ExportUtil.BuildPlaceholderRegex(ExportConstants.ExportSnippetRegex, ExportConstants.ListIndentPrefix).Replace(code, (m) =>
            {
                string snippetName = m.Groups[2].Value;
                snippetName        = snippetName.ToLowerInvariant();

                if (!usedExportSnippets.Contains(snippetName))
                {
                    usedExportSnippets.Add(snippetName);
                }

                return(ExportCodeSnippetContent(exportSnippets.FirstOrDefault(e => e.SnippetName.ToLowerInvariant() == snippetName), flexFieldObject, m.Groups[1].Value));
            });

            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, Placeholder_ExportSnippet_HasCodeSnippet_Additional_Functions_Start, Placeholder_ExportSnippet_HasCodeSnippet_Additional_Functions_End, (m) =>
            {
                string snippetName = m.Groups[1].Value;
                snippetName        = snippetName.ToLowerInvariant();

                return(HasCodeSnippetAdditionalFunctions(exportSnippets.FirstOrDefault(e => e.SnippetName.ToLowerInvariant() == snippetName), flexFieldObject));
            });
            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, Placeholder_ExportSnippet_HasCodeSnippet_NoAdditional_Functions_Start, Placeholder_ExportSnippet_HasCodeSnippet_NoAdditional_Functions_End, (m) =>
            {
                string snippetName = m.Groups[1].Value;
                snippetName        = snippetName.ToLowerInvariant();

                return(!HasCodeSnippetAdditionalFunctions(exportSnippets.FirstOrDefault(e => e.SnippetName.ToLowerInvariant() == snippetName), flexFieldObject));
            });
            code = ExportUtil.RenderPlaceholderIfFuncTrue(code, Placeholder_ExportSnippet_HasCodeSnippet_NoAdditional_Functions_Start, Placeholder_ExportSnippet_HasCodeSnippet_NoAdditional_Functions_End, (m) =>
            {
                string snippetName = m.Groups[1].Value;
                snippetName        = snippetName.ToLowerInvariant();

                return(HasCodeSnippetAdditionalFunctions(exportSnippets.FirstOrDefault(e => e.SnippetName.ToLowerInvariant() == snippetName), flexFieldObject));
            });
            code = ExportUtil.BuildPlaceholderRegex(Placeholder_ExportSnippet_AdditionalFuntions, ExportConstants.ListIndentPrefix).Replace(code, (m) =>
            {
                string snippetName = m.Groups[2].Value;
                snippetName        = snippetName.ToLowerInvariant();

                return(ExportCodeSnippetAdditionalFunctions(exportSnippets.FirstOrDefault(e => e.SnippetName.ToLowerInvariant() == snippetName), flexFieldObject, m.Groups[1].Value));
            });

            ValidateAllExportSnippetsUsed(usedExportSnippets, exportSnippets);

            return(code);
        }