public SetSource ( |
||
sourceContext | ||
Результат | void |
// GetScannerInstance is used by IsValidNamespaceName and IsValidIdentifier to validate names. // We return an instance of the scanner only if there is no whitespace in the name text, since // we do not want to allow, say, "not. valid" to be a valid namespace name even though that // would produce a valid sequence of tokens. private JSScanner GetScannerInstance(string name){ // make sure there's no whitespace in the name (values copied from documentation on String.Trim()) char[] anyWhiteSpace = { (char)0x0009, (char)0x000A, (char)0x000B, (char)0x000C, (char)0x000D, (char)0x0020, (char)0x00A0, (char)0x2000, (char)0x2001, (char)0x2002, (char)0x2003, (char)0x2004, (char)0x2005, (char)0x2006, (char)0x2007, (char)0x2008, (char)0x2009, (char)0x200A, (char)0x200B, (char)0x3000, (char)0xFEFF }; if (name == null || name.IndexOfAny(anyWhiteSpace) > -1) return null; // Create a code item whose source is the given text VsaItem item = new VsaStaticCode(this, "itemName", VsaItemFlag.None); Context context = new Context(new DocumentContext(item), name); context.errorReported = -1; JSScanner scanner = new JSScanner(); //Use this constructor to avoid allocating a Globals instance scanner.SetSource(context); return scanner; }
private JSScanner GetScannerInstance(string name) { char[] anyOf = new char[] { '\t', '\n', '\v', '\f', '\r', ' ', '\x00a0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', ' ', '' }; if ((name == null) || (name.IndexOfAny(anyOf) > -1)) { return null; } VsaItem sourceItem = new VsaStaticCode(this, "itemName", JSVsaItemFlag.None); Context sourceContext = new Context(new DocumentContext(sourceItem), name) { errorReported = -1 }; JSScanner scanner = new JSScanner(); scanner.SetSource(sourceContext); return scanner; }