public static KnownSetDecoratorDataType Difference(KnownSetDecoratorDataType left, KnownSetDecoratorDataType right) => (!left.Decorates.Equals(right.Decorates)) ? (new InvalidOperationException(nameof(Difference) + "When subtracting KnownSets they must be of the same value.")).AsValue <KnownSetDecoratorDataType>() : (left.Include) ? (right.Include) ? new KnownSetDecoratorDataType(true, left.Values.Where(leftValue => !right.ContainsItem(leftValue)), left._decorates) : new KnownSetDecoratorDataType(true, left.Values.Concat(right.Values).Distinct(), left._decorates) : (right.Include) ? new KnownSetDecoratorDataType(false, left.Values.Concat(right.Values).Distinct(), left._decorates) : (new InvalidOperationException(nameof(Difference) + "When subtracting KnownSets they must be of the same value.")).AsValue <KnownSetDecoratorDataType>();
public static KnownSetDecoratorDataType Union(KnownSetDecoratorDataType left, KnownSetDecoratorDataType right) { if (!left.Decorates.Equals(right.Decorates)) { throw new InvalidOperationException(nameof(Union) + "When union KnownSets they must be of the same value."); } if (left.Include != right.Include) { throw new InvalidOperationException(nameof(Union) + "Must be same inclusion."); } return(new KnownSetDecoratorDataType(left.Include, left.Values.Concat(right.Values).Distinct(), left._decorates)); }