/
smwwiki
/
OneScript_fork
Обзор
Документация
Войти
/
smwwiki
/
OneScript_fork
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/OneScript.Core/Contexts/AnnotationHolder.cs
39 строк
1 KB
EvilBeaver
Поправил мелкие замечания сонара
24 апр 2024, 13:50
24 апр 2024, 13:50
ebfc286
Код
Авторство
О чём код?
/*---------------------------------------------------------- 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; using System.Linq; using System.Reflection; namespace OneScript.Contexts { public class AnnotationHolder : ICustomAttributeProvider { private readonly object[] _annotations; public AnnotationHolder(object[] annotations) { _annotations = annotations; } public object[] GetCustomAttributes(bool inherit) { return _annotations ?? Array.Empty<object>(); } public object[] GetCustomAttributes(Type attributeType, bool inherit) { return GetCustomAttributes(true).Where(x => attributeType.IsAssignableFrom(attributeType)).ToArray(); } public bool IsDefined(Type attributeType, bool inherit) { return _annotations != default && _annotations.Any(x => x.GetType() == attributeType); } } }