Core - Fixed a lot of compiler warnings

Scripting - Added script renaming/deleting
This commit is contained in:
Robert committed 2021-06-21 19:34:34 +02:00
1 parent 4a69baebb7
commit 5367027471
36 files changed
+434 -96

No files matched your search

@@ -0,0 +1,64 @@
using System.Collections.ObjectModel;
using Artemis.Core.ScriptingProviders;
namespace Artemis.Core.Services
{
/// <summary>
/// A service that allows you to manage various types of <see cref="Script" /> instances
/// </summary>
public interface IScriptingService : IArtemisService
{
/// <summary>
/// Gets a list of all currently active global scripts
/// </summary>
ReadOnlyCollection<GlobalScript> GlobalScripts { get; }
/// <summary>
/// Creates a <see cref="GlobalScript" /> instance for the given <paramref name="scriptConfiguration" />
/// </summary>
/// <param name="scriptConfiguration">The script configuration of the script</param>
/// <returns>
/// If the <see cref="ScriptingProvider" /> was found an instance of the script; otherwise <see langword="null" />
/// .
/// </returns>
GlobalScript? CreateScriptInstance(ScriptConfiguration scriptConfiguration);
/// <summary>
/// Creates a <see cref="ProfileScript" /> instance for the given <paramref name="scriptConfiguration" />
/// </summary>
/// <param name="profile">The profile the script configuration is configured for</param>
/// <param name="scriptConfiguration">The script configuration of the script</param>
/// <returns>
/// If the <see cref="ScriptingProvider" /> was found an instance of the script; otherwise <see langword="null" />
/// .
/// </returns>
ProfileScript? CreateScriptInstance(Profile profile, ScriptConfiguration scriptConfiguration);
/// <summary>
/// Creates a <see cref="LayerScript" /> instance for the given <paramref name="scriptConfiguration" />
/// </summary>
/// <param name="layer">The layer the script configuration is configured fo</param>
/// <param name="scriptConfiguration">The script configuration of the script</param>
/// <returns>
/// If the <see cref="ScriptingProvider" /> was found an instance of the script; otherwise <see langword="null" />
/// .
/// </returns>
LayerScript? CreateScriptInstance(Layer layer, ScriptConfiguration scriptConfiguration);
/// <summary>
/// Creates a <see cref="PropertyScript" /> instance for the given <paramref name="scriptConfiguration" />
/// </summary>
/// <param name="layerProperty">The layer property the script configuration is configured fo</param>
/// <param name="scriptConfiguration">The script configuration of the script</param>
/// <returns>
/// If the <see cref="ScriptingProvider" /> was found an instance of the script; otherwise <see langword="null" />
/// .
/// </returns>
PropertyScript? CreateScriptInstance(ILayerProperty layerProperty, ScriptConfiguration scriptConfiguration);
/// <summary>
/// Deletes the provided global script by it's configuration
/// </summary>
void DeleteScript(ScriptConfiguration scriptConfiguration);
}
}
@@ -175,14 +175,10 @@ namespace Artemis.Core.Services
provider.InternalScripts.Add(script);
return script;
}
}
public interface IScriptingService : IArtemisService
{
ReadOnlyCollection<GlobalScript> GlobalScripts { get; }
GlobalScript? CreateScriptInstance(ScriptConfiguration scriptConfiguration);
ProfileScript? CreateScriptInstance(Profile profile, ScriptConfiguration scriptConfiguration);
LayerScript? CreateScriptInstance(Layer layer, ScriptConfiguration scriptConfiguration);
PropertyScript? CreateScriptInstance(ILayerProperty layerProperty, ScriptConfiguration scriptConfiguration);
/// <inheritdoc />
public void DeleteScript(ScriptConfiguration scriptConfiguration)
{
}
}
}
+3 -3
View File
@@ -12,9 +12,9 @@ namespace Artemis.Core.Services
_pluginSettings = new PluginSettings(Constants.CorePlugin, pluginRepository);
}
public PluginSetting<T> GetSetting<T>(string name, T defaultValue = default)
public PluginSetting<T> GetSetting<T>(string name, T? defaultValue = default)
{
return _pluginSettings.GetSetting(name, defaultValue!);
return _pluginSettings.GetSetting(name, defaultValue);
}
}
@@ -31,6 +31,6 @@ namespace Artemis.Core.Services
/// <param name="name">The name of the setting</param>
/// <param name="defaultValue">The default value to use if the setting does not exist yet</param>
/// <returns></returns>
PluginSetting<T> GetSetting<T>(string name, T defaultValue = default);
PluginSetting<T> GetSetting<T>(string name, T? defaultValue = default);
}
}
@@ -52,7 +52,9 @@ namespace Artemis.Core.Services
object? response = null;
try
{
T deserialized = JsonConvert.DeserializeObject<T>(await reader.ReadToEndAsync());
T? deserialized = JsonConvert.DeserializeObject<T>(await reader.ReadToEndAsync());
if (deserialized == null)
throw new JsonException("Deserialization returned null");
if (_requestHandler != null)
{