Data model - Added data model visualization view model

Debugger - Split debugger into different tabs
Debugger - Added data model debugger
This commit is contained in:
SpoinkyNL committed 2020-06-29 00:22:16 +02:00
1 parent 291a343428
commit 796c0dc671
33 files changed
+565 -236

No files matched your search

@@ -1,4 +1,5 @@
using Artemis.Core.Plugins.Abstract.DataModels;
using System;
using Artemis.Core.Plugins.Abstract.DataModels;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
namespace Artemis.Core.Plugins.Abstract
@@ -16,6 +17,20 @@ namespace Artemis.Core.Plugins.Abstract
get => (T) InternalDataModel;
internal set => InternalDataModel = value;
}
internal override void InternalEnablePlugin()
{
DataModel = Activator.CreateInstance<T>();
DataModel.PluginInfo = PluginInfo;
DataModel.DataModelDescription = GetDataModelDescription();
base.InternalEnablePlugin();
}
internal override void InternalDisablePlugin()
{
DataModel = null;
base.InternalDisablePlugin();
}
}
/// <summary>
@@ -8,11 +8,13 @@ namespace Artemis.Core.Plugins.Abstract.DataModels
/// <summary>
/// Gets the plugin info this data model belongs to
/// </summary>
[DataModelIgnore]
public PluginInfo PluginInfo { get; internal set; }
/// <summary>
/// Gets the <see cref="DataModelPropertyAttribute" /> describing this data model
/// </summary>
[DataModelIgnore]
public DataModelPropertyAttribute DataModelDescription { get; internal set; }
}
}
+13 -8
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract.DataModels;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
@@ -44,9 +45,18 @@ namespace Artemis.Core.Plugins.Abstract
return new DataModelPropertyAttribute {Name = PluginInfo.Name, Description = PluginInfo.Description};
}
internal override DataModelPropertyAttribute InternalGetDataModelDescription()
internal override void InternalEnablePlugin()
{
return GetDataModelDescription();
DataModel = Activator.CreateInstance<T>();
DataModel.PluginInfo = PluginInfo;
DataModel.DataModelDescription = GetDataModelDescription();
base.InternalEnablePlugin();
}
internal override void InternalDisablePlugin()
{
DataModel = null;
base.InternalDisablePlugin();
}
}
@@ -91,10 +101,5 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary>
/// <returns></returns>
public abstract IEnumerable<ModuleViewModel> GetViewModels();
internal virtual DataModelPropertyAttribute InternalGetDataModelDescription()
{
return null;
}
}
}
+35 -11
View File
@@ -1,6 +1,8 @@
using System;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.Models;
using Castle.Core.Internal;
namespace Artemis.Core.Plugins.Abstract
{
@@ -9,7 +11,7 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary>
public abstract class Plugin : IDisposable
{
public PluginInfo PluginInfo { get; internal set; }
public PluginInfo PluginInfo { get; internal set; }
/// <summary>
/// Gets whether the plugin is enabled
@@ -47,26 +49,39 @@ namespace Artemis.Core.Plugins.Abstract
return null;
}
internal void SetEnabled(bool enable)
internal void SetEnabled(bool enable, bool isAutoEnable = false)
{
if (enable && !Enabled)
{
Enabled = true;
PluginInfo.Enabled = true;
// If enable failed, put it back in a disabled state
try
{
EnablePlugin();
if (isAutoEnable && PluginInfo.GetLockFileCreated())
{
// Don't wrap existing lock exceptions, simply rethrow them
if (PluginInfo.LoadException is ArtemisPluginLockException)
throw PluginInfo.LoadException;
throw new ArtemisPluginLockException(PluginInfo.LoadException);
}
Enabled = true;
PluginInfo.Enabled = true;
PluginInfo.CreateLockFile();
InternalEnablePlugin();
OnPluginEnabled();
PluginInfo.LoadException = null;
}
catch
// If enable failed, put it back in a disabled state
catch (Exception e)
{
Enabled = false;
PluginInfo.Enabled = false;
PluginInfo.LoadException = e;
throw;
}
OnPluginEnabled();
PluginInfo.DeleteLockFile();
}
else if (!enable && Enabled)
{
@@ -74,12 +89,21 @@ namespace Artemis.Core.Plugins.Abstract
PluginInfo.Enabled = false;
// Even if disable failed, still leave it in a disabled state to avoid more issues
DisablePlugin();
InternalDisablePlugin();
OnPluginDisabled();
}
}
internal virtual void InternalEnablePlugin()
{
EnablePlugin();
}
internal virtual void InternalDisablePlugin()
{
DisablePlugin();
}
#region Events
public event EventHandler PluginEnabled;
@@ -4,6 +4,7 @@ using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract.DataModels;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Artemis.Core.Plugins.Models;
using SkiaSharp;
namespace Artemis.Core.Plugins.Abstract
@@ -18,7 +19,7 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary>
public T DataModel
{
get => (T)InternalDataModel;
get => (T) InternalDataModel;
internal set => InternalDataModel = value;
}
@@ -42,12 +43,21 @@ namespace Artemis.Core.Plugins.Abstract
/// <returns></returns>
public virtual DataModelPropertyAttribute GetDataModelDescription()
{
return new DataModelPropertyAttribute { Name = PluginInfo.Name, Description = PluginInfo.Description };
return new DataModelPropertyAttribute {Name = PluginInfo.Name, Description = PluginInfo.Description};
}
internal override void InternalEnablePlugin()
{
DataModel = Activator.CreateInstance<T>();
DataModel.PluginInfo = PluginInfo;
DataModel.DataModelDescription = GetDataModelDescription();
base.InternalEnablePlugin();
}
internal override DataModelPropertyAttribute InternalGetDataModelDescription()
internal override void InternalDisablePlugin()
{
return GetDataModelDescription();
DataModel = null;
base.InternalDisablePlugin();
}
}
@@ -0,0 +1,18 @@
using System;
namespace Artemis.Core.Plugins.Exceptions
{
public class ArtemisPluginLockException : Exception
{
public ArtemisPluginLockException(Exception innerException) : base(CreateExceptionMessage(innerException), innerException)
{
}
private static string CreateExceptionMessage(Exception innerException)
{
return innerException != null
? "Found a lock file, skipping load, see inner exception for last known exception."
: "Found a lock file, skipping load.";
}
}
}
+27 -11
View File
@@ -12,16 +12,17 @@ namespace Artemis.Core.Plugins.Models
[JsonObject(MemberSerialization.OptIn)]
public class PluginInfo : PropertyChangedBase
{
private Guid _guid;
private string _name;
private string _description;
private string _icon;
private Version _version;
private string _main;
private DirectoryInfo _directory;
private Plugin _instance;
private bool _enabled;
private Guid _guid;
private string _icon;
private Plugin _instance;
private bool _lastEnableSuccessful;
private Exception _loadException;
private string _main;
private string _name;
private Version _version;
internal PluginInfo()
{
@@ -117,12 +118,12 @@ namespace Artemis.Core.Plugins.Models
}
/// <summary>
/// Indicates whether the last time the plugin loaded, it loaded correctly
/// Gets the exception thrown while loading
/// </summary>
public bool LastEnableSuccessful
public Exception LoadException
{
get => _lastEnableSuccessful;
internal set => SetAndNotify(ref _lastEnableSuccessful, value);
get => _loadException;
internal set => SetAndNotify(ref _loadException, value);
}
/// <summary>
@@ -149,7 +150,22 @@ namespace Artemis.Core.Plugins.Models
{
PluginEntity.Id = Guid;
PluginEntity.IsEnabled = Enabled;
PluginEntity.LastEnableSuccessful = LastEnableSuccessful;
}
internal void CreateLockFile()
{
File.Create(Path.Combine(Directory.FullName, "artemis.lock")).Close();
}
internal void DeleteLockFile()
{
if (GetLockFileCreated())
File.Delete(Path.Combine(Directory.FullName, "artemis.lock"));
}
internal bool GetLockFileCreated()
{
return File.Exists(Path.Combine(Directory.FullName, "artemis.lock"));
}
}
}