diff --git a/DeedyDesigner/Deedy.Activity/Helpers/ElementHelper.cs b/DeedyDesigner/Deedy.Activity/Helpers/ElementHelper.cs
index 4432ad4..187fbff 100644
--- a/DeedyDesigner/Deedy.Activity/Helpers/ElementHelper.cs
+++ b/DeedyDesigner/Deedy.Activity/Helpers/ElementHelper.cs
@@ -237,5 +237,58 @@ namespace Deedy.Activity
catch { document = string.Empty; }
return result;
}
+ ///
+ /// 尝试将一个字符串「档案」解析为「IElement」对象
+ ///
+ /// 要解析的「档案」
+ /// 解析后的对象
+ /// 如果解析失败则返回「False」
+ public static bool TryDecode(this string document, out TReturn element) where TReturn : IElement
+ {
+#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
+ TReturn instance = default;
+#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
+ bool result = false;
+ try
+ {
+ if (XamlReader.Parse(document) is TReturn @return)
+ {
+ instance = @return;
+ result = true;
+ }
+ }
+ catch { }
+#pragma warning disable CS8601 // 引用类型赋值可能为 null。
+ element = instance;
+#pragma warning restore CS8601 // 引用类型赋值可能为 null。
+ return result;
+ }
+ ///
+ /// 尝试将一个字符串「档案」解析为「IElement」对象
+ ///
+ /// 要解析的「档案」
+ /// 解析后的对象
+ /// 如果解析失败则返回「False」
+ public static bool TryDecode(this string document,[AllowNull] out IElement element)
+ {
+
+#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
+ IElement instance = null;
+#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
+ bool result = false;
+ try
+ {
+ if (XamlReader.Parse(document) is IElement @return)
+ {
+ instance = @return;
+ result = true;
+ }
+ }
+ catch { }
+#pragma warning disable CS8601 // 引用类型赋值可能为 null。
+ element = instance;
+#pragma warning restore CS8601 // 引用类型赋值可能为 null。
+ return result;
+ }
}
}