mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-08-21 10:52:56 +00:00
Simplify NoPlugin
This commit is contained in:
parent
51f34392ed
commit
8fc6cb326b
@ -5,6 +5,5 @@ namespace AIStudio.Tools.PluginSystem;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a plugin that could not be loaded.
|
/// Represents a plugin that could not be loaded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="state">The Lua state that the plugin was loaded into.</param>
|
|
||||||
/// <param name="parsingError">The error message that occurred while parsing the plugin.</param>
|
/// <param name="parsingError">The error message that occurred while parsing the plugin.</param>
|
||||||
public sealed class NoPlugin(LuaState state, string parsingError) : PluginBase(string.Empty, state, PluginType.NONE, parsingError);
|
public sealed class NoPlugin(string parsingError) : PluginBase(string.Empty, LuaState.Create(), PluginType.NONE, parsingError);
|
@ -100,23 +100,23 @@ public static class PluginFactory
|
|||||||
}
|
}
|
||||||
catch (LuaParseException e)
|
catch (LuaParseException e)
|
||||||
{
|
{
|
||||||
return new NoPlugin(state, $"Was not able to parse the plugin: {e.Message}");
|
return new NoPlugin($"Was not able to parse the plugin: {e.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.Environment["TYPE"].TryRead<string>(out var typeText))
|
if (!state.Environment["TYPE"].TryRead<string>(out var typeText))
|
||||||
return new NoPlugin(state, "TYPE does not exist or is not a valid string.");
|
return new NoPlugin("TYPE does not exist or is not a valid string.");
|
||||||
|
|
||||||
if (!Enum.TryParse<PluginType>(typeText, out var type))
|
if (!Enum.TryParse<PluginType>(typeText, out var type))
|
||||||
return new NoPlugin(state, $"TYPE is not a valid plugin type. Valid types are: {CommonTools.GetAllEnumValues<PluginType>()}");
|
return new NoPlugin($"TYPE is not a valid plugin type. Valid types are: {CommonTools.GetAllEnumValues<PluginType>()}");
|
||||||
|
|
||||||
if(type is PluginType.NONE)
|
if(type is PluginType.NONE)
|
||||||
return new NoPlugin(state, $"TYPE is not a valid plugin type. Valid types are: {CommonTools.GetAllEnumValues<PluginType>()}");
|
return new NoPlugin($"TYPE is not a valid plugin type. Valid types are: {CommonTools.GetAllEnumValues<PluginType>()}");
|
||||||
|
|
||||||
return type switch
|
return type switch
|
||||||
{
|
{
|
||||||
PluginType.LANGUAGE => new PluginLanguage(path, state, type),
|
PluginType.LANGUAGE => new PluginLanguage(path, state, type),
|
||||||
|
|
||||||
_ => new NoPlugin(state, "This plugin type is not supported yet. Please try again with a future version of AI Studio.")
|
_ => new NoPlugin("This plugin type is not supported yet. Please try again with a future version of AI Studio.")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user