/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
v2.0.0
src/ScriptEngine/ScriptSourceFactory.cs
49 строк
1 KB
EvilBeaver
fixes #1540 Предупреждение о неявных импортах
01 дек 2025, 12:27
01 дек 2025, 12:27
9ef7b18
Код
Авторство
О чём код?
/*---------------------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ----------------------------------------------------------*/ using System.Text; using OneScript.Sources; namespace ScriptEngine { public class ScriptSourceFactory { public ScriptSourceFactory() { ReaderEncoding = Encoding.UTF8; } public SourceCode FromString(string code) { return SourceCodeBuilder.Create() .FromString(code) .Build(); } public SourceCode FromFile(string path) { return SourceCodeBuilder .Create() .FromFile(path, ReaderEncoding) .Build(); } /// <summary> /// Создаёт SourceCode из файла с указанием пакета-владельца. /// </summary> public SourceCode FromFile(string path, string ownerPackageId) { return SourceCodeBuilder .Create() .FromFile(path, ReaderEncoding) .WithOwnerPackage(ownerPackageId) .Build(); } public Encoding ReaderEncoding { get; set; } } }