コード例 #1
0
ファイル: Context.cs プロジェクト: tobiasschulz/php-dotnet
        public void RequireFile(Scope scope, params NormalizedPath [] possible_paths)
        {
            CodeScriptFile file = null;

            foreach (NormalizedPath possible_path in possible_paths)
            {
                if (file != null)
                {
                    break;
                }

                foreach (var d in RootDirectories)
                {
                    file = d.Files.FirstOrDefault(f => f.FullPath == possible_path);
                    if (file != null)
                    {
                        break;
                    }
                }

                if (file == null)
                {
                    foreach (var d in RootDirectories)
                    {
                        NormalizedPath relative_combined = Path.GetFullPath(Path.Combine(d.Path.Original, possible_path.Original));
                        file = d.Files.FirstOrDefault(f => f.FullPath == relative_combined);
                        if (file != null)
                        {
                            break;
                        }
                    }
                }
            }

            if (file == null)
            {
                throw new InterpreterException($"File {possible_paths.Join ("|")} could not be found. Root directories are: {RootDirectories.Join (", ")}.\n{scope.StackTrace}");
            }

            if (IncludedFiles.Contains(file))
            {
                Log.Debug($"File already included: {file}");
                return;
            }
            IncludedFiles.Add(file);

            file.GetContent().Run(scope, Options);
        }
コード例 #2
0
ファイル: Context.cs プロジェクト: tobiasschulz/php-dotnet
        public void RunFile(NormalizedPath value)
        {
            CodeScriptFile file = null;

            foreach (var d in RootDirectories)
            {
                file = d.Files.FirstOrDefault(f => f.FullPath == value);
                if (file != null)
                {
                    break;
                }
            }

            if (file == null)
            {
                foreach (var d in RootDirectories)
                {
                    NormalizedPath relative_combined = Path.GetFullPath(Path.Combine(d.Path.Original, value.Original));
                    file = d.Files.FirstOrDefault(f => f.FullPath == relative_combined);
                    if (file != null)
                    {
                        break;
                    }
                }
            }

            if (file == null)
            {
                throw new InterpreterException($"File {value} could not be found. Root directories are: {RootDirectories.Join (", ")}");
            }

            if (IncludedFiles.Contains(file))
            {
                Log.Debug($"File already included: {file}");
                return;
            }
            IncludedFiles.Add(file);

            file.GetContent().Run(RootScope, Options);
        }