本文整理汇总了C#中ParseResult.Release方法的典型用法代码示例。如果您正苦于以下问题:C# ParseResult.Release方法的具体用法?C# ParseResult.Release怎么用?C# ParseResult.Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseResult
的用法示例。
在下文中一共展示了ParseResult.Release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CmdProc
/// <summary> This procedure is invoked to process the "subst" Tcl command.
/// See the user documentation for details on what it does.
///
/// </summary>
/// <param name="interp">the current interpreter.
/// </param>
/// <param name="argv">command arguments.
/// </param>
/// <exception cref=""> TclException if wrong # of args or invalid argument(s).
/// </exception>
public TCL.CompletionCode CmdProc(Interp interp, TclObject[] argv)
{
int currentObjIndex, len, i;
int objc = argv.Length - 1;
bool doBackslashes = true;
bool doCmds = true;
bool doVars = true;
StringBuilder result = new StringBuilder();
string s;
char c;
for (currentObjIndex = 1; currentObjIndex < objc; currentObjIndex++)
{
if (!argv[currentObjIndex].ToString().StartsWith("-"))
{
break;
}
int opt = TclIndex.Get(interp, argv[currentObjIndex], validCmds, "switch", 0);
switch (opt)
{
case OPT_NOBACKSLASHES:
doBackslashes = false;
break;
case OPT_NOCOMMANDS:
doCmds = false;
break;
case OPT_NOVARS:
doVars = false;
break;
default:
throw new TclException(interp, "SubstCmd.cmdProc: bad option " + opt + " index to cmds");
}
}
if (currentObjIndex != objc)
{
throw new TclNumArgsException(interp, currentObjIndex, argv, "?-nobackslashes? ?-nocommands? ?-novariables? string");
}
/*
* Scan through the string one character at a time, performing
* command, variable, and backslash substitutions.
*/
s = argv[currentObjIndex].ToString();
len = s.Length;
i = 0;
while (i < len)
{
c = s[i];
if ((c == '[') && doCmds)
{
ParseResult res;
try
{
interp._evalFlags = Parser.TCL_BRACKET_TERM;
interp.Eval(s.Substring(i + 1, (len) - (i + 1)));
TclObject interp_result = interp.GetResult();
interp_result.Preserve();
res = new ParseResult(interp_result, i + interp._termOffset);
}
catch (TclException e)
{
i = e.errIndex + 1;
throw;
}
i = res.nextIndex + 2;
result.Append(res.Value.ToString());
res.Release();
}
else if (c == '\r')
{
/*
* (ToDo) may not be portable on Mac
*/
i++;
}
else if ((c == '$') && doVars)
{
ParseResult vres = Parser.parseVar(interp, s.Substring(i, (len) - (i)));
//.........这里部分代码省略.........