protected virtual void PreProcess(TagParameter tp, TagData td)
        {
            //先解析load标签
            var tagload = td.Context.GetTagParser("load");

            tagload.DoParse(tp, td);
        }
        /// <summary>
        /// 将源码编译成js代码
        /// </summary>
        /// <param name="source">源码</param>
        /// <param name="filename">文件名称</param>
        /// <param name="isCreateFile">是否产生编译后的js文件,如果产生文件,则文件产生的目录为运行时库所在的路径,默认为Host的根路径下的Compiled/Logic/</param>
        /// <param name="outfilepath">产生编译后的js文件的存放路径,只有在isCreateFile=true的时候有效</param>
        /// <returns></returns>
        public Dictionary <string, string> Compile(string filename, string source, bool isCreateFile)
        {
            var p = new TagParameter();
            var d = new TagData();

            p.RootPath       = _context.RootPath;
            p.CommonLibPath  = _context.CommonLibPath;
            p.RunTimeLibPath = _context.RunTimeLibPath;
            p.Text           = source;
            p.SetValue("__tags__", _context.AllTags);
            ModuleProxyManager.Call <HostLogicProxy, TagParameter, TagData>(p, d);
            Dictionary <string, string> contents = (Dictionary <string, string>)d.ExtentionObj.result;

            if (isCreateFile)
            {
                if (!Directory.Exists(p.RunTimeLibPath))
                {
                    Directory.CreateDirectory(p.RunTimeLibPath);
                }
                if (!Directory.Exists(p.RunTimeLibPath + HostJsConstants.LOGIC_PATH))
                {
                    Directory.CreateDirectory(p.RunTimeLibPath + HostJsConstants.LOGIC_PATH);
                }
                foreach (var item in contents)
                {
                    var path = p.RunTimeLibPath + HostJsConstants.LOGIC_PATH + filename + (item.Key != "" ? "." + item.Key : "") + ".hjs";

                    File.WriteAllText(path, item.Value, Encoding.UTF8);
                }
            }
            return(contents);
        }
Exemple #3
0
        public void DoParse(TagParameter p, TagData d)
        {
            tagdata.Value = d;
            foreach (var item in p.BindObject.Items)
            {
                tagdata.Value.Context.AddBindObject(item.Key, item.Value);
            }

            Regex          re         = null;
            Regex          rearg      = new Regex(regArgs);
            Regex          recontent  = new Regex(regcontent);
            FrameDLRObject args       = FrameDLRObject.CreateInstance();
            var            tmpcontent = d.ParsedText;

            if (IsNeedBrace)
            {
                re = new Regex(regstrwithbrace);
            }
            else
            {
                re = new Regex(regstrwithoutbrace);
            }

            if (re.IsMatch(tmpcontent))
            {
                foreach (Match s in re.Matches(tmpcontent))
                {
                    var      content   = s.Value;
                    string   argstr    = rearg.Match(content).Value;
                    string[] argsarray = argstr.Split(',');
                    for (int i = 0; i < argsarray.Length; i++)
                    {
                        if (i < this.ArgNames.Length)
                        {
                            args.SetValue(this.ArgNames[i], argsarray[i]);
                        }
                        else
                        {
                            args.SetValue("arg" + i, argsarray[i]);
                        }
                    }

                    var bracecontent = "";
                    if (IsNeedBrace)
                    {
                        if (recontent.IsMatch(content))
                        {
                            bracecontent = recontent.Match(content).Value;
                        }
                    }

                    tmpcontent = tmpcontent.Replace("#" + content, DoProcess(args, bracecontent));
                }
            }
            d.ParsedText = tmpcontent;
        }
Exemple #4
0
        public MsgTagKill(KillTagParameter param)
        {
            byte[] selectBuff = TagParameter.GetSelectBuff(param.SelectTagParam);
            msgBody = new byte[4 + selectBuff.Length];
            int num = 0;

            Array.Copy(selectBuff, 0, msgBody, num, selectBuff.Length);
            num += selectBuff.Length;
            Array.Copy(param.KillPassword, 0, msgBody, num, 4);
        }
 /// <summary>
 /// 初始化上下文,为后续处理加载对应的解析器,可重载
 /// </summary>
 /// <param name="tp"></param>
 /// <param name="td"></param>
 protected virtual void Init(TagParameter tp, TagData td)
 {
     //加载默认标签
     td.Context.AddTagParser(new LoadParser());
     td.Context.AddTagParser(new RefParser());
     td.Context.AddTagParser(new CopyParser());
     //加载自定义标签
     foreach (var item in _customized_taglist)
     {
         td.Context.AddTagParser((ITagParser)Activator.CreateInstance(item.TTag));
     }
 }
Exemple #6
0
 public void Log(string msg, TagParameter w1)
 {
     Log(string.Format("______________________________\r\n{0}:\r\n" +
                       "MemoryBank={1}\r\n" +
                       "Ptr={2}\r\n" +
                       "TagData={3}\r\n" +
                       "-----------------------------------",
                       msg,
                       w1.MemoryBank,
                       w1.Ptr,
                       ByteFormat.ToHex(w1.TagData, "", " ")));
 }
Exemple #7
0
        private static List <TagParameter> ParseTagParameters(ref ParsingContext context)
        {
            var parameters = new List <TagParameter>();

            context.Tokenizer.ExpectToken(TokenType.LeftParent);

            while (true)
            {
                var token = context.Tokenizer.NextToken();
                if (token.Type == TokenType.RightParent)
                {
                    return(parameters);
                }

                if (token.Type == TokenType.Identifier || token.Type == TokenType.String || token.Type == TokenType.Number)
                {
                    var tag = new TagParameter
                    {
                        Tag = token.Value,
                    };

                    var nextToken = context.Tokenizer.NextToken();
                    switch (nextToken.Type)
                    {
                    case TokenType.Equal:
                        token     = context.Tokenizer.NextToken();
                        tag.Value = token.Value;
                        if (tag.Value[0] == '\"' && tag.Value[tag.Value.Length - 1] == '\"')
                        {
                            tag.Value = tag.Value.Substring(1, tag.Value.Length - 2);
                        }
                        if (tag.Value.Contains("\\\""))
                        {
                            tag.Value = tag.Value.Replace("\\\"", "\"");
                        }
                        parameters.Add(tag);
                        break;

                    case TokenType.Whitespace:
                    case TokenType.Comma:
                        parameters.Add(tag);
                        break;

                    case TokenType.RightParent:
                        parameters.Add(tag);
                        return(parameters);

                    default: throw new Exception($"Expected right parent or next argument, but got {token.Type}.");
                    }
                }
            }
        }
Exemple #8
0
        public MsgTagLock(LockTagParameter param)
        {
            byte[] selectBuff = TagParameter.GetSelectBuff(param.SelectTagParam);
            msgBody = new byte[6 + selectBuff.Length];
            int num = 0;

            Array.Copy(selectBuff, 0, msgBody, num, selectBuff.Length);
            num += selectBuff.Length;
            Array.Copy(param.AccessPassword, 0, msgBody, num, 4);
            num         += 4;
            msgBody[num] = (byte)param.LockType;
            num++;
            msgBody[num] = (byte)param.LockBank;
        }
Exemple #9
0
        /// <summary>
        /// 增加素材分类
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public async Task <ReturnResult> AddTagAsync(String name, int weight)
        {
            ReturnResult result = new ReturnResult();
            TagParameter tag    = new TagParameter();

            tag.Weight = weight;
            tag.Name   = name;
            var fileEntity = Mapper.Map <Tag>(tag);
            await context.Tags.AddAsync(fileEntity);

            await context.SaveChangesAsync();

            result.IsSuccess = true;
            return(result);
        }
Exemple #10
0
        private void setWriteMsgBody()
        {
            List <byte> list = new List <byte>();

            list.Add((byte)(param.IsLoop ? 1 : 0));
            list.AddRange(param.AccessPassword);
            byte[] selectBuff = TagParameter.GetSelectBuff(param.SelectTagParam);
            list.AddRange(selectBuff);
            byte[]         array        = null;
            byte[]         array2       = null;
            byte[]         array3       = null;
            TagParameter[] writeDataAry = param.WriteDataAry;
            foreach (TagParameter tagParameter in writeDataAry)
            {
                switch (tagParameter.MemoryBank)
                {
                case MemoryBank.EPCMemory:
                    array = getWriteBuff(tagParameter);
                    break;

                case MemoryBank.UserMemory:
                    array2 = getWriteBuff(tagParameter);
                    break;

                case MemoryBank.ReservedMemory:
                    array3 = getWriteBuff(tagParameter);
                    break;
                }
            }
            if (array == null)
            {
                array = new byte[2];
            }
            if (array2 == null)
            {
                array2 = new byte[2];
            }
            if (array3 == null)
            {
                array3 = new byte[2];
            }
            list.AddRange(array);
            list.AddRange(array2);
            list.AddRange(array3);
            msgBody = list.ToArray();
        }
Exemple #11
0
        /// <summary>
        /// 自定义扩展:通过传入的参数来获取要加载后的文本
        /// </summary>
        /// <param name="tagstr">被解析后的标签串(含参数),格式为#load(xxx)</param>
        /// <returns></returns>
        protected string LoadTextFromArgs(string tagstr, TagParameter p, TagData d)
        {
            Regex reArgs   = new Regex(regArgs);
            var   filepath = reArgs.IsMatch(tagstr) ? reArgs.Match(tagstr).Value : "";

            filepath = filepath.Replace("~", p.RootPath).Replace("$Common", p.CommonLibPath).Replace("$RunTime", p.RunTimeLibPath)
                       .Replace("$View", p.RootPath + HostJsConstants.VIEW_PATH).Replace("$Logic", p.RootPath + HostJsConstants.LOGIC_PATH);
            if (File.Exists(filepath))
            {
                var content = File.ReadAllText(filepath, Encoding.UTF8);
                return(content);
            }
            else
            {
                return("");
            }
        }
Exemple #12
0
        private byte[] getWriteBuff(TagParameter param)
        {
            byte[] array = EVB.ConvertToEvb(param.Ptr);
            if (param.TagData.Length % 2 == 1)
            {
                byte[] array2 = new byte[param.TagData.Length + 1];
                Array.Copy(param.TagData, 0, array2, 0, array2.Length - 1);
                param.TagData = array2;
            }
            byte[] array3 = new byte[1 + array.Length + param.TagData.Length];
            int    num    = 0;

            Array.Copy(array, 0, array3, num, array.Length);
            num        += array.Length;
            array3[num] = (byte)(param.TagData.Length / 2);
            num++;
            Array.Copy(param.TagData, 0, array3, num, param.TagData.Length);
            return(array3);
        }
Exemple #13
0
        private string LoadProcess(string text, TagParameter p, TagData d)
        {
            var   processedtext = text;
            Regex re            = new Regex(regstr);

            Dictionary <string, string> tmpd = new Dictionary <string, string>();

            foreach (Match m in re.Matches(text))
            {
                if (!tmpd.ContainsKey(m.Value))
                {
                    var content = LoadTextFromArgs(m.Value, p, d);
                    processedtext = processedtext.Replace("#" + m.Value, LoadProcess(content, p, d));
                    tmpd.Add(m.Value, LoadProcess(content, p, d));
                }
            }

            return(processedtext);
        }
Exemple #14
0
        public void DoParse(TagParameter p, TagData d)
        {
            if (string.IsNullOrEmpty(d.ParsedText))
            {
                return;
            }

            var tmpcontent = d.ParsedText;
            //解析全文本,将里面符合标签规则的文本全部分离出来,以供相关程式使用
            Regex re             = new Regex(regstr);
            Regex reTagName_Args = new Regex(regTagName_args);
            Regex reTagName      = new Regex(regTagName);
            Regex reArgs         = new Regex(regTagArgs);


            List <TagEntity> lentity = new List <TagEntity>();

            //匹配所有标签
            foreach (Match rm in re.Matches(tmpcontent))
            {
                var uid = Guid.NewGuid().ToString();
                tmpcontent = tmpcontent.Replace(rm.Value, "<?tmp%" + uid + "%>");
                lentity.Add(new TagEntity(uid, rm.Value));
            }

            foreach (var t in lentity)
            {
                d.ParsedText = t.Content;
                var tagname_arg = reTagName_Args.IsMatch(t.Content) ? reTagName_Args.Match(t.Content).Value : "";
                if (tagname_arg != "")
                {
                    var tagname = reTagName.Match(tagname_arg).Value;
                    var parser  = d.Context.GetTagParser(tagname);
                    //解析标签
                    parser.DoParse(p, d);

                    tmpcontent = tmpcontent.Replace("<?tmp%" + t.UID + "%>", d.ParsedText);
                }
            }

            d.ParsedText = tmpcontent;
        }
        protected virtual void DoProcess(TagParameter tp, TagData td)
        {
            td.ParsedText = tp.Text;

            //进行预处理
            PreProcess(tp, td);
            var list            = td.Context.GetAllTagParsers().OrderBy(d => d.Priority);
            var pre_parsed_text = td.ParsedText;

            //嵌套标签支持
            do
            {
                pre_parsed_text = td.ParsedText;
                foreach (var parser in list)
                {
                    parser.DoParse(tp, td);
                }
            } while (td.ParsedText != pre_parsed_text);
            AferProcess(tp, td);
        }
Exemple #16
0
        /// <summary>
        /// 将源码编译成js代码
        /// </summary>
        /// <param name="filename">文件名称</param>
        /// <param name="source">源码</param>
        /// <param name="isCreateFile">是否产生编译后的文件,如果产生文件,则文件产生的目录为Host的根路径下的Compiled/View/</param>
        /// <param name="outfilepath">产生编译后的js文件的存放路径,只有在isCreateFile=true的时候有效</param>
        /// <returns></returns>
        public string Compile(string filename, string source, bool isCreateFile)
        {
            var rtn = "";
            var p   = new TagParameter();
            var d   = new TagData();

            p.RootPath       = _context.RootPath;
            p.CommonLibPath  = _context.CommonLibPath;
            p.RunTimeLibPath = _context.RunTimeLibPath;
            p.Text           = source;
            p.SetValue("__tags__", _context.AllTags);
            ModuleProxyManager.Call <HostViewProxy, TagParameter, TagData>(p, d);
            rtn = d.ParsedText;
            if (isCreateFile)
            {
                if (!Directory.Exists(p.RunTimeLibPath + HostJsConstants.VIEW_PATH))
                {
                    Directory.CreateDirectory(p.RunTimeLibPath + HostJsConstants.VIEW_PATH);
                }
                var path = p.RunTimeLibPath + HostJsConstants.VIEW_PATH + filename + ".hjs";
                File.WriteAllText(path, rtn, Encoding.UTF8);
            }
            return(rtn);
        }
Exemple #17
0
        /// <summary>
        /// 保存商品标签
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public async Task <ReturnResult> SaveAsync(TagParameter parameter)
        {
            ReturnResult result = new ReturnResult();
            var          tag    = Mapper.Map <Tag>(parameter);

            //验证标签名称
            tag.Name = tag.Name?.Trim();
            if (string.IsNullOrEmpty(tag.Name))
            {
                result.IsSuccess = false;
                result.Message   = "标签名称不能为空";
                return(result);
            }
            //新建保存标签
            if (tag.Id <= 0)
            {
                //验证标签名称是否重复
                var tmpTag = await context.ProTags.FirstOrDefaultAsync(c => c.Name == tag.Name && c.IsDel == false);

                if (tmpTag != null)
                {
                    result.IsSuccess = false;
                    result.Message   = "标签名称重复";
                    return(result);
                }
                //设置创建时间
                if (tag.CreateTime == DateTime.MinValue)
                {
                    tag.CreateTime = DateTime.Now;
                }
                //创建标签
                await context.ProTags.AddAsync(tag);

                await context.SaveChangesAsync();

                result.Id = tag.Id;
            }
            //编辑保存标签
            else
            {
                var oldTag = await context.ProTags.FirstOrDefaultAsync(c => c.Id == tag.Id);

                if (oldTag == null || oldTag.IsDel)
                {
                    result.IsSuccess = false;
                    result.Message   = "标签已被删除";
                    return(result);
                }
                //验证标签名称是否重复
                var tmpTag = await context.ProTags.FirstOrDefaultAsync(c => c.Name == tag.Name && c.IsDel == false);

                if (tmpTag != null && tmpTag.Id != oldTag.Id)
                {
                    result.IsSuccess = false;
                    result.Message   = "标签名称重复";
                    return(result);
                }
                //更新标签
                oldTag.Name  = tag.Name;
                oldTag.Style = tag.Style;
                await context.SaveChangesAsync();
            }
            return(result);
        }
Exemple #18
0
 /// <summary>
 /// 解析
 /// </summary>
 /// <param name="p"></param>
 /// <param name="d"></param>
 public void DoParse(TagParameter p, TagData d)
 {
     d.ParsedText = LoadProcess(p.Text, p, d);
 }
Exemple #19
0
 public MsgTagSelect(TagParameter param)
 {
     byte[] selectBuff = TagParameter.GetSelectBuff(param);
     msgBody = new byte[1 + selectBuff.Length];
     Array.Copy(selectBuff, 0, msgBody, 0, selectBuff.Length);
 }
        public static string CreateContents(string nameSpace, string className, string classDefaultInherit, List <TemplateObject> templateObjectList, string templateName)
        {
            StringBuilder result         = new StringBuilder();
            int           currentIndent  = 0;
            int           indentIncrease = 4;

            // Check if this is a special case like Core.cst where there is only one TagText
            // in the whole templateObjectList.
            if (templateObjectList.Count == 1 &&
                templateObjectList[0].TagType == typeof(TagText))
            {
                TagText tText = (TagText)templateObjectList[0].Object;

                // Check if a namespace is defined somewhere, then ignore this
                if (Regex.Matches(tText.Text, @"^namespace\s+\w+\s*$").Count == 0)
                {
                    // Find using statement and i3 the namespace should be inserted
                    MatchCollection mc = Regex.Matches(tText.Text, RegExConstants.RE_CS_USINGSTATEMENTS);

                    // Must be only one match
                    if (mc.Count == 1)
                    {
                        result.Append(mc[0].Groups[RegExConstants.RE_CS_USINGSTATEMENTS_USING].Value);

                        // Add namespace tag
                        result.AppendLine(TemplateCreateNamespacePart(nameSpace, currentIndent));

                        currentIndent += indentIncrease;

                        result.AppendLine(BreakLinesAndOutput(mc[0].Groups[RegExConstants.RE_CS_USINGSTATEMENTS_RESTOFFILE].Value, currentIndent));

                        currentIndent -= indentIncrease;

                        result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

                        return(result.ToString());
                    }
                }
            }

            // Create the using statements
            TagImport tagImport = GetTemplateObject <TagImport>(templateObjectList);

            bool usingSystem = false;
            bool usingSystemCollectionsGeneric = false;
            bool usingCodesmithEngine          = false;

            while (tagImport != null)
            {
                result.AppendLine(TemplateCreateUsingPart(tagImport, currentIndent));

                if (tagImport.Namespace.Equals("System", StringComparison.CurrentCultureIgnoreCase))
                {
                    usingSystem = true;
                }

                if (tagImport.Namespace.Equals("System.Collections.Generic", StringComparison.CurrentCultureIgnoreCase))
                {
                    usingSystemCollectionsGeneric = true;
                }

                if (tagImport.Namespace.Equals("CodeSmith.Engine", StringComparison.CurrentCultureIgnoreCase))
                {
                    usingCodesmithEngine = true;
                }

                tagImport = GetTemplateObject <TagImport>(templateObjectList);
            }

            // Add System and System.Collections.Generic

            if (!usingSystem)
            {
                result.AppendLine(TemplateCreateUsingPart(new TagImport("System"), currentIndent));
            }

            if (!usingSystemCollectionsGeneric)
            {
                result.AppendLine(TemplateCreateUsingPart(new TagImport("System.Collections.Generic"), currentIndent));
            }

            if (!usingCodesmithEngine)
            {
                result.AppendLine(TemplateCreateUsingPart(new TagImport("CodeSmith.Engine"), currentIndent));
            }

            result.AppendLine();

            // Create namespace tag
            result.AppendLine(TemplateCreateNamespacePart(nameSpace, currentIndent));

            currentIndent += indentIncrease;

            // Find the CodeTemplate object in list
            TagCodeTemplate tagCodeTemplate = GetTemplateObject <TagCodeTemplate>(templateObjectList);

            if (tagCodeTemplate != null &&
                tagCodeTemplate.Inherits != string.Empty)
            {
                result.AppendLine(TemplateCreateClassPart(className, tagCodeTemplate.Inherits, currentIndent));
            }
            else
            {
                result.AppendLine(TemplateCreateClassPart(className, classDefaultInherit, currentIndent));
            }

            currentIndent += indentIncrease;

            // Create the properties
            TagProperty tagProperty = GetTemplateObject <TagProperty>(templateObjectList);

            while (tagProperty != null)
            {
                result.AppendLine(TemplateCreateProperty(tagProperty.Name, tagProperty.Type, currentIndent));

                tagProperty = GetTemplateObject <TagProperty>(templateObjectList);
            }

            result.AppendLine();

            StringBuilder __text = new StringBuilder();

            result.AppendLine(string.Format("{0}public override string OriginalTemplateName {{ get {{ return @\"{1}\"; }} }}\r\n", GetIndent(currentIndent), templateName));

            string templateComment = @"Generated from template: " + templateName;

            // Override the Render function
            result.AppendLine(string.Format("{0}public override void Render()\r\n{0}{{\r\n{1}TagFile(@\"{2}\");", GetIndent(currentIndent), GetIndent(currentIndent + indentIncrease), templateComment));

            // Find all TagCSharp and TagText items and create the code from that
            for (int i = 0; i < templateObjectList.Count; i++)
            {
                TemplateObject obj = templateObjectList[i];

                if (obj.TagType == typeof(TagCSharp))
                {
                    result.Append(BreakLinesAndOutput(((TagCSharp)obj.Object).Code, currentIndent));
                }
                else if ((obj.TagType == typeof(TagText)) || (obj.TagType == typeof(TagParameter)))
                {
                    int lookAheadIndex = i + 1;

                    while (lookAheadIndex < templateObjectList.Count)
                    {
                        if ((templateObjectList[lookAheadIndex].TagType == typeof(TagText)) || (templateObjectList[lookAheadIndex].TagType == typeof(TagParameter)))
                        {
                            lookAheadIndex++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    // idx points to the next code fragment i.e. not Text or parameters

                    // create single string.format using the text and parameters
                    // advance i to skip ahead

                    // Do string replace " to "" and the other first ?? togr

                    string argumentList      = string.Empty;
                    int    stringFormatIndex = 0;

                    for (int i2 = i; i2 < lookAheadIndex; i2++)
                    {
                        argumentList = string.Concat(argumentList, string.Format("{{{0}}}", stringFormatIndex));
                        stringFormatIndex++;
                    }

                    StringBuilder code = new StringBuilder();
                    code.AppendLine(string.Format("__text.AppendFormat(\"{0}\\r\\n\"", argumentList));

                    for (int i3 = i; i3 < lookAheadIndex; i3++)
                    {
                        if (templateObjectList[i3].TagType == typeof(TagText))
                        {
                            TagText tText = (TagText)templateObjectList[i3].Object;

                            // Convert text. Change all " to ""
                            tText.Text = tText.Text.Replace("\"", "\"\"");

                            // Remove all consecutive \n and also all \n that is occuring alone not after a \r
                            tText.Text = Regex.Replace(tText.Text, "((?<=[^\r])\n)|(\n{2,})", string.Empty);
                            code.AppendLine(string.Format(",@\"{0}\"", tText.Text));
                        }
                        else
                        {
                            TagParameter tParam = (TagParameter)templateObjectList[i3].Object;
                            code.AppendLine(string.Format(",{0}", tParam.Parameter));
                        }
                    }

                    code.AppendLine(");");

                    result.Append(string.Format("{0}{1}", GetIndent(currentIndent), code.ToString()));
                    i = lookAheadIndex - 1;
                }
            }

            result.AppendLine(string.Format("{0}return;", GetIndent(currentIndent + indentIncrease)));

            result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

            currentIndent -= indentIncrease;

            result.AppendLine();

            // Add the script section the properties
            TagScript tagScript = GetTemplateObject <TagScript>(templateObjectList);

            while (tagScript != null)
            {
                result.AppendLine(tagScript.Text);

                tagScript = GetTemplateObject <TagScript>(templateObjectList);
            }

            result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

            currentIndent -= indentIncrease;

            result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

            return(result.ToString());
        }
    private void DrawCustomParameters()
    {
        GUILayout.BeginArea(new Rect(scroll.x, scroll.y + position.height - 500, 200, 500));
        GUILayout.FlexibleSpace();
        bool state = EditorPrefs.GetBool("Parameters", false);

        Rect rect  = GUILayoutUtility.GetRect(new GUIContent("Parameters"), "flow overlay header lower left", GUILayout.ExpandWidth(true));
        Rect rect2 = new Rect(rect.x + 175, rect.y + 2, 25, 25);

        if (GUI.Button(rect2, "", "label"))
        {
            GenericMenu        genericMenu = new GenericMenu();
            IEnumerable <Type> types       = AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => assembly.GetTypes()).Where(type => type.IsSubclassOf(typeof(NamedParameter)));
            foreach (Type type in types)
            {
                genericMenu.AddItem(new GUIContent(type.ToString().Split('.').Last().Replace("Parameter", "")), false, new GenericMenu.MenuFunction2(this.OnCreateParameter), type);
            }
            genericMenu.ShowAsContext();
        }

        if (GUI.Button(rect, "Parameters", "flow overlay header lower left"))
        {
            EditorPrefs.SetBool("Parameters", !state);
        }

        GUI.Label(rect2, iconToolbarPlus);

        if (state)
        {
            EditorGUIUtility.labelWidth = 80;
            GUILayout.BeginVertical((GUIStyle)"PopupCurveSwatchBackground", GUILayout.Width(199));
            int deleteIndex = -1;
            if (controller.parameters.Count > 0)
            {
                for (int i = 0; i < controller.parameters.Count; i++)
                {
                    NamedParameter parameter = controller.parameters[i];
                    GUILayout.BeginHorizontal();
                    parameter.Name = EditorGUILayout.TextField(parameter.Name);
                    if (parameter.GetType() == typeof(BoolParameter))
                    {
                        GUILayout.FlexibleSpace();
                        BoolParameter boolParam = parameter as BoolParameter;
                        boolParam.Value = EditorGUILayout.Toggle(boolParam.Value, GUILayout.Width(14));
                    }
                    else if (parameter.GetType() == typeof(TagParameter))
                    {
                        TagParameter tagParam = parameter as TagParameter;
                        tagParam.Value = EditorGUILayout.TagField(tagParam.Value, GUILayout.Width(80));
                    }
                    else
                    {
                        SerializedObject paramObject = new SerializedObject(parameter);
                        paramObject.Update();
                        EditorGUILayout.PropertyField(paramObject.FindProperty("value"), GUIContent.none, GUILayout.Width(80));
                        paramObject.ApplyModifiedProperties();
                    }
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button(iconToolbarMinus, "label"))
                    {
                        deleteIndex = i;
                    }
                    GUILayout.EndHorizontal();
                }
            }
            else
            {
                GUILayout.Label("List is Empty");
            }
            if (deleteIndex != -1)
            {
                DestroyImmediate(controller.parameters[deleteIndex], true);
                controller.parameters.RemoveAt(deleteIndex);
                AssetDatabase.SaveAssets();
            }
            GUILayout.EndVertical();
        }
        GUILayout.EndArea();
    }
 protected virtual void AferProcess(TagParameter tp, TagData td)
 {
 }