/// <summary> /// 获取内容的代码 /// </summary> /// <param name="content"></param> /// <returns></returns> private string GetContentCode(string content) { CodeGeneration com = new CodeGeneration(content); Queue <ExpressionItem> queitem = com.ExpressionItems; CodeOutputer outputer = new CodeOutputer(); string str = outputer.GetCode(queitem); return(str); }
/// <summary> /// 处理Script标签 /// </summary> public string GetCode(string className) { //解释Model.cs信息 string strRef = @"(?isx)<[#]script\stype=""(?<type>[^""]+)"">(?<content>(.*?))</[#]script>"; MatchCollection matches = new Regex(strRef).Matches(_backCode); foreach (Match ma in matches) { if (ma.Groups["type"] == null) { continue; } string type = ma.Groups["type"].Value; string content = ma.Groups["content"].Value; CodeGeneration com = new CodeGeneration(content); Queue <ExpressionItem> queitem = com.ExpressionItems; if (type.Equals("linked", StringComparison.CurrentCultureIgnoreCase)) { LinkOutputer outputer = new LinkOutputer(); List <string> str = outputer.GetCode(queitem, _entityInfo); _man.Link.AddRange(str); } else if (type.Equals("using", StringComparison.CurrentCultureIgnoreCase)) { UsingOutputer outputer = new UsingOutputer(); string str = outputer.GetCode(queitem); _man.Using.Append(str); } else if (_content == null && type.Equals("code", StringComparison.CurrentCultureIgnoreCase)) { CodeOutputer outputer = new CodeOutputer(); string str = outputer.GetCode(queitem); _man.Code.Append(str); } else if (type.Equals("method", StringComparison.CurrentCultureIgnoreCase)) { MethodOutputer outputer = new MethodOutputer(); string str = outputer.GetCode(queitem); _man.Method.Append(str); } } //解释Model信息 if (_content != null) { _man.Code.Append(GetContentCode(_content)); } return(_man.ToCode(className)); }