/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
v2.0.3-alpha
src/OneScript.Language/Sources/SourceCodeBuilder.cs
47 строк
1 KB
Andrey Ovsiankin
Новое АПИ входа в модуль. Заменено в тестах
22 июл 2021, 14:31
22 июл 2021, 14:31
3b770c0
Код
Авторство
О чём код?
/*---------------------------------------------------------- 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; // ReSharper disable once CheckNamespace namespace OneScript.Sources { public class SourceCodeBuilder { private ICodeSource _source; private string _moduleName; private SourceCodeBuilder() { } public SourceCodeBuilder FromSource(ICodeSource source) { _source = source; return this; } public SourceCodeBuilder WithName(string name) { _moduleName = name; return this; } public SourceCode Build() { if (_source == default) throw new InvalidOperationException("Source is not set"); if (_moduleName == default) _moduleName = _source.Location; return new SourceCode(_moduleName, _source); } public static SourceCodeBuilder Create() => new SourceCodeBuilder(); } }