Ejemplo n.º 1
0
 /// <summary>
 /// Handler of mixed data SBE-Scripts
 /// Format: https://bitbucket.org/3F/vssolutionbuildevent/issue/22/#comment-12739932
 /// </summary>
 /// <param name="data">mixed data</param>
 /// <param name="allowMSBuild">Allows post-processing with MSBuild or not.
 /// Some components can require immediate processing with evaluation, before passing control to next level.
 /// </param>
 /// <returns>prepared and evaluated data</returns>
 public string parse(string data, bool allowMSBuild)
 {
     lock (_lock)
     {
         _depthLevel = 0;
         postMSBuild = allowMSBuild;
         StringHandler hString = new StringHandler();
         return(hString.recovery(parse(hString.protect(data), _depthLevel, hString)));
     }
 }
Ejemplo n.º 2
0
        /// <param name="data">Mixed data</param>
        /// <param name="level">Nesting level</param>
        /// <param name="hString">Handler of strings if exists</param>
        /// <returns>Prepared and evaluated data</returns>
        protected string parse(string data, int level, StringHandler hString = null)
        {
            if (level >= DEPTH_LIMIT)
            {
                _depthLevel = 0;
                throw new LimitException("Nesting level of '{0}' reached. Aborted.", DEPTH_LIMIT);
            }
            var rcon = RPattern.Container;

            return(rcon.Replace(data,
                                delegate(Match m)
            {
                string escape = m.Groups[1].Value;
                string raw = m.Groups[2].Value;

                if (escape.Length > 1)
                {
                    Log.Trace("SBEScripts-Container: escape `{0}`", (raw.Length > 40)? raw.Substring(0, 40) + "..." : raw);
                    return "#" + escapeMSBuildData(raw, true);
                }

                return selector((hString != null)? hString.recovery(raw) : raw);
            }));
        }