GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — scriptcs/src/ScriptCs.Core/UsingLineProcessor.cs at dev · scriptcs/scriptcs Expand file tree/ Copy pathUsingLineProcessor.csMore file actions 47 lines (38 loc) · 1.35 KB / Copy pathUsingLineProcessor.csFile metadata and controls47 lines (38 loc) · 1.35 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 using ScriptCs.Contracts; namespace ScriptCs { public interface IUsingLineProcessor : ILineProcessor { } public class UsingLineProcessor : IUsingLineProcessor { private const string UsingString = "using "; public bool ProcessLine(IFileParser parser, FileParserContext context, string line, bool isBeforeCode) { Guard.AgainstNullArgument("context", context); if (!IsUsingLine(line)) { return false; } // for using static, we will not extract the import into the context, but rather let it be treated as code if (line.Contains(" static ")) { return false; } var @namespace = GetNamespace(line); if (!context.Namespaces.Contains(@namespace)) { context.Namespaces.Add(@namespace); } return true; } private static bool IsUsingLine(string line) => line.Trim(' ').StartsWith(UsingString) && !line.Contains("{") && line.Contains(";") && !line.Contains("="); private static string GetNamespace(string line) { return line.Trim(' ') .Replace(UsingString, string.Empty) .Replace("\"", string.Empty) .Replace(";", string.Empty); } } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |