Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'UVtools.Core/Operations/Operation.cs')
-rw-r--r--UVtools.Core/Operations/Operation.cs28
1 files changed, 27 insertions, 1 deletions
diff --git a/UVtools.Core/Operations/Operation.cs b/UVtools.Core/Operations/Operation.cs
index cee3c13..ad35b05 100644
--- a/UVtools.Core/Operations/Operation.cs
+++ b/UVtools.Core/Operations/Operation.cs
@@ -10,6 +10,7 @@ using System;
using System.Drawing;
using System.IO;
using System.Linq;
+using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Emgu.CV;
@@ -320,7 +321,14 @@ namespace UVtools.Core.Operations
return string.IsNullOrWhiteSpace(message);
}
- public virtual string ValidateInternally() => null;
+ public virtual string ValidateInternally()
+ {
+ if (!ValidateSpawn(out var message))
+ {
+ return message;
+ }
+ return null;
+ }
/// <summary>
/// Validates the operation
@@ -604,6 +612,24 @@ namespace UVtools.Core.Operations
#region Static Methods
+ public static Operation Deserialize(string path)
+ {
+ if (!File.Exists(path)) return null;
+
+ var fileText = File.ReadAllText(path);
+ var match = Regex.Match(fileText, @"(?:<\/\s*Operation)([a-zA-Z0-9_]+)(?:\s*>)");
+ if (!match.Success) return null;
+ if (match.Groups.Count < 1) return null;
+ var operationName = match.Groups[1].Value;
+ var baseType = typeof(Operation).FullName;
+ if (string.IsNullOrWhiteSpace(baseType)) return null;
+ var classname = baseType + operationName + ", UVtools.Core";
+ var type = Type.GetType(classname);
+ if (type is null) return null;
+
+ return Deserialize(path, type);
+ }
+
public static Operation Deserialize(string path, Type type)
{
XmlSerializer serializer = new(type);