Kenric Nugteren před 1 rokem
rodič
revize
60ce33b9f1

+ 1 - 2
InABox.Core/LinkedProperties.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Linq.Expressions;
-using FluentResults;
 
 namespace InABox.Core
 {
@@ -49,7 +48,7 @@ namespace InABox.Core
         private static readonly Dictionary<Type, List<ILinkedProperty>> _LinkedProperties = new Dictionary<Type, List<ILinkedProperty>>();
         
         public static void Register<TLinkedEntity, TEntityLink, TType>(Expression<Func<TLinkedEntity,TEntityLink>> path, Expression<Func<TEntityLink, TType>> source,
-            Expression<Func<TLinkedEntity?, TType>> target, Func<TLinkedEntity?,TType, Result<TType>>? func = null)
+            Expression<Func<TLinkedEntity?, TType>> target, Func<TLinkedEntity?,TType, Result<TType, string>>? func = null)
             where TLinkedEntity : class
             where TEntityLink : class
         {

+ 3 - 5
InABox.Core/LinkedProperty.cs

@@ -33,7 +33,7 @@ namespace InABox.Core
         public String Source { get; }
         public String Target { get; }
 
-        private readonly Func<TLinkedEntity?, TType, Result<TType>>? _func;
+        private readonly Func<TLinkedEntity?, TType, Result<TType, string>>? _func;
         
         public override string ToString()
         {
@@ -43,7 +43,7 @@ namespace InABox.Core
         public LinkedProperty(Expression<Func<TLinkedEntity, TEntityLink>> path, 
             Expression<Func<TEntityLink?, TType>> source,
             Expression<Func<TLinkedEntity?, TType>> target,
-            Func<TLinkedEntity?,TType, Result<TType>>? func = null)
+            Func<TLinkedEntity?,TType, Result<TType, string>>? func = null)
         {
             Path = CoreUtils.GetFullPropertyName(path, ".");
             Source = CoreUtils.GetFullPropertyName(source, ".");
@@ -61,9 +61,7 @@ namespace InABox.Core
                 if (_func != null)
                 {
                     var result = _func(to as TLinkedEntity, value);
-                    if (!result.IsSuccess)
-                        return;
-                    value = result.Value;
+                    if (!result.Get(out value, out var _)) return;
                 }
                 CoreUtils.SetPropertyValue(to, Target, value);
             }