Esempio n. 1
0
        internal static string GetSourceFileRaw(string location, bool useCsharpCode = false)
        {
            string file;

            location = location.TrimEx();
            if (location.ContainsAny("http://", "https://"))
            {
                Cli.PrintLnC($"{location} Downloading...", ConsoleColor.White);

                file = JsonTools.GetStringAsync(location).Result;
            }
            else
            {
                if (!useCsharpCode && !location.EndsWith(".xr"))
                {
                    throw new KernelException("extension (.xr) mandatory");
                }

                file = File.ReadAllText(location);
            }

            var(valid, message) = IsValidSource(file);

            if (!valid)
            {
                throw new KernelException(message);
            }

            return(file);
        }