本文整理汇总了C#中System.Script.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Script.Clear方法的具体用法?C# Script.Clear怎么用?C# Script.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Script
的用法示例。
在下文中一共展示了Script.Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNewScriptFromFile
public static async Task<Script> GetNewScriptFromFile()
{
FileOpenPicker picker = new FileOpenPicker();
picker.FileTypeFilter.Add(".mcr");
StorageFile scriptFile = await picker.PickSingleFileAsync();
try
{
Script script = new Script();
script.Clear();
char[] delimiterChars = { ' ', ',', '.', ':', '\t', '=', '/', '(', ')', '[', ']', '*', '+', '>', '<', '?', '!' };
IList<string> allLines = await FileIO.ReadLinesAsync(scriptFile);
bool atContents = false;
foreach (string line in allLines)
{
string[] words = line.Split(delimiterChars);
if (words.Length == 0) continue;
//__check for end of content section
if (words.Length == 1 && words[0] == "#End" && atContents) break;
//__check for start of content section
if (words.Contains("#BeginContents") && !atContents)
{
atContents = true;
continue;
}
if (!atContents)//__only interested in version number from header contents
{
if (words.Contains("#MajorVersion"))
{
if (words.Length > 1) script.Version = words[1];
}
if (words.Contains("#MinorVersion"))
{
if (words.Length > 1) script.Version += "." + words[1];
}
}
//__now done with header section, extract Variables & lines
}
script.Name = scriptFile.DisplayName;
return script;
}
catch (Exception e)
{
return null;
}
}
示例2: ParseScript
public virtual bool ParseScript(Script s)
{
s.Clear(); return ParseSpecialElement(s);
}