Skip to content

Commit

Permalink
Restore variants label
Browse files Browse the repository at this point in the history
  • Loading branch information
Nice3point committed Jan 29, 2025
1 parent f446803 commit 628a80e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,4 @@ IEnumerator<Variant> IEnumerable<Variant>.GetEnumerator()
{
return _items.GetEnumerator();
}

public object GetResult()
{
return this;
}

public string? GetMetadata()
{
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace LookupEngine.Abstractions.Decomposition;

public interface IVariantsCollection
{
IVariant Consume();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
namespace LookupEngine.Abstractions.Decomposition;

public interface IVariantsCollection<in T>
public interface IVariantsCollection<in T> : IVariantsCollection
{
IVariantsCollection<T> Add(T? result);
IVariantsCollection<T> Add(T? result, string description);
IVariant Consume();
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,16 @@ private object RedirectValue(object value, out Descriptor valueDescriptor)
private protected virtual object RedirectValue(object value, string target, out Descriptor valueDescriptor)
{
var variant = value as IVariant;
if (variant is not null)
switch (variant)
{
value = variant.Value ?? throw new EngineException("Nullable variant must be handled before decomposition");
case null:
break;
case IVariantsCollection:
value = variant;
break;
default:
value = variant.Value ?? throw new EngineException("Nullable variant must be handled before decomposition");
break;
}

valueDescriptor = _options.TypeResolver.Invoke(value, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ private protected override object RedirectValue(object value)
private protected override object RedirectValue(object value, string target, out Descriptor valueDescriptor)
{
var variant = value as IVariant;
if (variant is not null)
switch (variant)
{
value = variant.Value ?? throw new EngineException("Nullable variant must be handled before decomposition");
case null:
break;
case IVariantsCollection:
value = variant;
break;
default:
value = variant.Value ?? throw new EngineException("Nullable variant must be handled before decomposition");
break;
}

valueDescriptor = _options.TypeResolver.Invoke(value, null);
Expand Down

0 comments on commit 628a80e

Please sign in to comment.