|
@@ -12,7 +12,7 @@ namespace InABox.Core
|
|
|
String Path { get; }
|
|
|
String Source { get; }
|
|
|
String Target { get; }
|
|
|
- void Update(object? from, object? to);
|
|
|
+ void Update(object from, object to);
|
|
|
|
|
|
/// <summary>
|
|
|
/// This equality comparer checks against type, path, source and target
|
|
@@ -29,11 +29,11 @@ namespace InABox.Core
|
|
|
public Type Type => typeof(TLinkedEntity);
|
|
|
public String Path { get; }
|
|
|
|
|
|
- private Func<TEntityLink?, TType> _source;
|
|
|
+ private Func<TEntityLink, TType> _source;
|
|
|
public String Source { get; }
|
|
|
public String Target { get; }
|
|
|
|
|
|
- private readonly Func<TLinkedEntity?, TType, Result<TType, string>>? _func;
|
|
|
+ private readonly Func<TLinkedEntity, TType, Result<TType, string>>? _func;
|
|
|
|
|
|
public override string ToString()
|
|
|
{
|
|
@@ -41,9 +41,9 @@ 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, string>>? func = null)
|
|
|
+ Expression<Func<TEntityLink, TType>> source,
|
|
|
+ Expression<Func<TLinkedEntity, TType>> target,
|
|
|
+ Func<TLinkedEntity,TType, Result<TType, string>>? func = null)
|
|
|
{
|
|
|
Path = CoreUtils.GetFullPropertyName(path, ".");
|
|
|
Source = CoreUtils.GetFullPropertyName(source, ".");
|
|
@@ -52,15 +52,15 @@ namespace InABox.Core
|
|
|
_source = source.Compile();
|
|
|
}
|
|
|
|
|
|
- public void Update(object? from, object? to)
|
|
|
+ public void Update(object from, object to)
|
|
|
{
|
|
|
- if (from != null && to != null)
|
|
|
+ if (from is TEntityLink fromLink && to is TLinkedEntity toEntity)
|
|
|
{
|
|
|
- var value = _source.Invoke(from as TEntityLink);
|
|
|
+ var value = _source.Invoke(fromLink);
|
|
|
//var value = CoreUtils.GetPropertyValue(from, Source);
|
|
|
if (_func != null)
|
|
|
{
|
|
|
- var result = _func(to as TLinkedEntity, value);
|
|
|
+ var result = _func(toEntity, value);
|
|
|
if (!result.Get(out value, out var _)) return;
|
|
|
}
|
|
|
CoreUtils.SetPropertyValue(to, Target, value);
|