/
smwwiki
/
OneScript_fork
Обзор
Документация
Войти
/
smwwiki
/
OneScript_fork
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/StandaloneRunner/InternalTemplate.cs
61 строка
2 KB
EvilBeaver
Merge branch 'develop' into native
28 июл 2021, 11:40
28 июл 2021, 11:40
e4ad696
Код
Авторство
О чём код?
/*---------------------------------------------------------- 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.IO; using OneScript.StandardLibrary.Binary; using ScriptEngine.HostedScript; namespace StandaloneRunner { public class InternalTemplate : ITemplate { private string _tempFileName; private BinaryDataContext _data; public InternalTemplate(byte[] data, TemplateKind kind) { Kind = kind; _data = new BinaryDataContext(data); } public void Dispose() { if (_tempFileName != null) { try { File.Delete(_tempFileName); } catch {// now errors on exit } } } public string GetFilename() { if (_tempFileName == null) { _tempFileName = Path.GetTempFileName(); using (var fs = new FileStream(_tempFileName, FileMode.OpenOrCreate)) { _data.CopyTo(fs); } } return _tempFileName; } public BinaryDataContext GetBinaryData() { return _data; } public TemplateKind Kind { get; } } }