/
TON618OFF
/
Unity-Project-RTU
Обзор
Документация
Войти
/
TON618OFF
/
Unity-Project-RTU
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Library/PackageCache/com.unity.visualscripting@1.9.4/Runtime/VisualScripting.Flow/Framework/Collections/Dictionaries/RemoveDictionaryItem.cs
77 строк
2 KB
TON618OFF
release
03 окт 2024, 22:20
03 окт 2024, 22:20
7c70e9f
Код
Авторство
О чём код?
using System.Collections; namespace Unity.VisualScripting { /// <summary> /// Removes a dictionary item with a specified key. /// </summary> [UnitCategory("Collections/Dictionaries")] [UnitSurtitle("Dictionary")] [UnitShortTitle("Remove Item")] [UnitOrder(3)] public sealed class RemoveDictionaryItem : Unit { /// <summary> /// The entry point for the node. /// </summary> [DoNotSerialize] [PortLabelHidden] public ControlInput enter { get; private set; } /// <summary> /// The dictionary. /// </summary> [DoNotSerialize] [PortLabel("Dictionary")] [PortLabelHidden] public ValueInput dictionaryInput { get; private set; } /// <summary> /// The dictionary without the removed item. /// Note that the input dictionary is modified directly and then returned. /// </summary> [DoNotSerialize] [PortLabel("Dictionary")] [PortLabelHidden] public ValueOutput dictionaryOutput { get; private set; } /// <summary> /// The key of the item to remove. /// </summary> [DoNotSerialize] public ValueInput key { get; private set; } /// <summary> /// The action to execute once the item has been removed. /// </summary> [DoNotSerialize] [PortLabelHidden] public ControlOutput exit { get; private set; } protected override void Definition() { enter = ControlInput(nameof(enter), Remove); dictionaryInput = ValueInput<IDictionary>(nameof(dictionaryInput)); dictionaryOutput = ValueOutput<IDictionary>(nameof(dictionaryOutput)); key = ValueInput<object>(nameof(key)); exit = ControlOutput(nameof(exit)); Requirement(dictionaryInput, enter); Requirement(key, enter); Assignment(enter, dictionaryOutput); Succession(enter, exit); } public ControlOutput Remove(Flow flow) { var dictionary = flow.GetValue<IDictionary>(dictionaryInput); var key = flow.GetValue<object>(this.key); flow.SetValue(dictionaryOutput, dictionary); dictionary.Remove(key); return exit; } } }