public void GetVersions(FileVariable fv)
        {
            // {{entity_field_list[[{{tab}}{{tab}}{{tab}}<v-><data_type:int,is_dto_field:true|int code>,<data_type : DateTime|DateTime code>, <default|default code><-v>{{nl}}]]}}
            fv.Versions = new List <TemplateVersion>();
            // see if there are multiple versions of the template
            // (old) var verMatch = Regex.Match(fv.InnerTemplate, "<v->.+<-v>");
            var verMatch = Regex.Match(fv.InnerTemplate, "<v->(.|\n)+<-v>");

            if (verMatch.Success)
            {
                var versions = Regex.Matches(fv.InnerTemplate, @"< *( *\w+ *: *\w+ *,?|default)* *\| *([^>])+ *>");
                if (versions.Count > 0)
                {
                    // parse each type
                    foreach (var version in versions)
                    {
                        TemplateVersion ver = new TemplateVersion();
                        // get the parameters first
                        var parameters = Regex.Matches(version.ToString(), @"(\w+ *: *\w+ *)");
                        if (parameters.Count > 0)
                        {
                            foreach (var p in parameters)
                            {
                                string[] parts = p.ToString().Split(':');
                                //ver.Parameters.Add(parts[0].Trim(), parts[1].Trim());
                            }
                        }
                        else
                        {
                            // this must be the default version
                            ver.IsDefault = true;
                        }

                        // get the template
                        ver.Template = getInBetween(version.ToString(), "|", ">");
                        fv.Versions.Add(ver);
                    }
                }

                // replace the versions with a tag
                fv.InnerTemplate = fv.InnerTemplate.Replace(verMatch.ToString(), "{{template_versions}}");
            }
        }
        public string GetEntityFields(GenerateCodeOptions opt, CustomVariable variable)
        {
            string code = "";

            foreach (var field in opt.Entity.Fields)
            {
                string template = variable.Template;
                // add tabs if necessary
                if (variable.Tabs > 0)
                {
                    template = Repeat("\t", variable.Tabs) + template;
                }

                // make sure it meets the criteria
                if (!variable.IsSearchField || field.IsSearchField)
                {
                    bool shouldInclude = true;
                    // see if this variable has variables
                    if (variable.Versions != null && variable.Versions.Count > 0)
                    {
                        // figure out this field matches a version
                        TemplateVersion fieldVersion = null;
                        shouldInclude = false;
                        foreach (var version in variable.Versions)
                        {
                            if ((string.IsNullOrEmpty(version.DataType) || field.DataType == version.DataType) &&
                                (!version.IsContainsSearch || field.IsContainsSearch))
                            {
                                fieldVersion = version;
                                break;
                            }
                        }

                        if (fieldVersion != null)
                        {
                            template      = !string.IsNullOrEmpty(template) ? template.Replace("{{version}}", fieldVersion.Template) : fieldVersion.Template;
                            shouldInclude = true;
                        }
                        else
                        {
                            // see if there is a default version
                            var defList = variable.Versions.Where(v => v.IsDefault).ToList();
                            if (defList.Count > 0)
                            {
                                // use the default version
                                template      = !string.IsNullOrEmpty(template) ? template.Replace("{{version}}", defList[0].Template) : defList[0].Template;
                                shouldInclude = true;
                            }
                        }
                    }

                    if (shouldInclude)
                    {
                        // see if we need to add a seperator
                        if (!string.IsNullOrEmpty(code) && !string.IsNullOrEmpty(variable.Seperator))
                        {
                            code += variable.Seperator;
                        }

                        var innerVars = GetVariables(template);
                        template = ReplaceIfExists(innerVars, Tags.Entity.EntityFieldName, field.FieldName, template);

                        // see if the data type should be nullable
                        string dataType = field.DataType;
                        if (variable.Nullable)
                        {
                            dataType = GetNullableDataType(field.DataType);
                        }

                        template = ReplaceIfExists(innerVars, Tags.Entity.EntityFieldDataType, dataType, template);
                        code    += template;
                    }
                }
            }

            // replace any basic values the template might have
            code = GenerateCodeFromTemplate(opt, code);
            return(code);
        }