/* * SPDX-License-Identifier: AGPL-3.0-or-later * Copyright (C) 2025 Sergej Görzen * This file is part of xAPI4Unity. */ #if UNITY_EDITOR using System.Collections.Generic; namespace xAPI4Unity.Editor.Parser.Definitions { /// /// An xAPI context /// internal class xAPIContext { /// /// Name of the context /// public readonly string Name; public readonly string Description; /// /// Activities in the context /// public xAPIDefinitionsList Activities { get; set; } = new xAPIDefinitionsList(); /// /// Verbs in the context /// public xAPIDefinitionsList Verbs { get; set; } = new xAPIDefinitionsList(); /// /// Extensions in the context /// public IDictionary> Extensions { get; set; } = new Dictionary>(); /// /// Extension types in the context /// public IEnumerable ExtensionTypes => Extensions.Keys; /// /// Creates an xAPIContext /// /// Name of the context /// public xAPIContext(string name, string description = "") { Name = name; Description = description; } /// /// Adds an activity to the context /// /// Activity /// True, if it was successfully added, false, if not public bool AddActivity(xAPIActivity activity) { return Activities.AddDefinition(activity); } /// /// Adds sub activities to the context /// /// Name /// Activities /// Number of added activities public bool AddSubActivity(string name, xAPIActivity activity) { return Activities.AddSubDefinition(name, activity); } /// /// Adds a verb to the context /// /// Verb /// True, if it was successfully added, false, if not public bool AddVerb(xAPIVerb verb) { return Verbs.AddDefinition(verb); } /// /// Adds sub verbs to the context /// /// Name /// Verbs /// Number of added verbs public bool AddSubVerb(string name, xAPIVerb verb) { return Verbs.AddSubDefinition(name, verb); } /// /// Adds an extension to the context /// /// Extension /// True, if it was successfully added, false, if not public bool AddExtension(string type, xAPIExtension extension) { if (!Extensions.ContainsKey(type)) { Extensions.Add(type, new xAPIDefinitionsList()); } return Extensions[type].AddDefinition(extension); } /// /// Adds sub extensions to the context /// /// Extension type /// Name /// Extensions /// Number of added extensions public bool AddSubExtension(string type, string name, xAPIExtension extension) { if (!Extensions.ContainsKey(type)) { Extensions.Add(type, new xAPIDefinitionsList()); } return Extensions[type].AddSubDefinition(name, extension); } } } #endif