/
smwwiki
/
OneScript_fork
Обзор
Документация
Войти
/
smwwiki
/
OneScript_fork
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/ScriptEngine/Machine/Contexts/DynamicPropertiesAccessor.cs
89 строк
2 KB
EvilBeaver
Выделена отдельная папка для инфраструктуры исключений
24 июл 2023, 22:46
24 июл 2023, 22:46
d1c2e94
Код
Авторство
О чём код?
/*---------------------------------------------------------- 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.Collections.Generic; using OneScript.Exceptions; namespace ScriptEngine.Machine.Contexts { public abstract class DynamicPropertiesAccessor : PropertyNameIndexAccessor { private readonly DynamicPropertiesHolder _propHolder; public DynamicPropertiesAccessor() { _propHolder = new DynamicPropertiesHolder(); } protected int RegisterProperty(string name) { return _propHolder.RegisterProperty(name); } protected void RemoveProperty(string name) { _propHolder.RemoveProperty(name); } protected void ClearProperties() { _propHolder.ClearProperties(); } protected string GetPropertyName(int idx) { return _propHolder.GetPropertyName(idx); } protected virtual IEnumerable<KeyValuePair<string, int>> GetDynamicProperties() { return _propHolder.GetProperties(); } #region IRuntimeContextInstance Members public override bool IsIndexed { get { return true; } } public override int GetPropCount() { return _propHolder.Count; } public override string GetPropName(int propNum) { return GetPropertyName(propNum); } public override int GetPropertyNumber(string name) { try { return _propHolder.GetPropertyNumber(name); } catch (KeyNotFoundException) { throw PropertyAccessException.PropNotFoundException(name); } } public override bool IsPropReadable(int propNum) { return true; } public override bool IsPropWritable(int propNum) { return true; } #endregion } }