本文整理匯總了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);
}