thygesteffensen / PowerAutomateMockUp

Skeleton to run Power Automate Flows from their JSON descriptions.
MIT License
7 stars 1 forks source link

Fix comparison #25

Closed github-actions[bot] closed 3 years ago

github-actions[bot] commented 3 years ago

Fix comparison

https://github.com/thygesteffensen/PowerAutomateMockUp/blob/b96f031a9bb5f647f2e4dc517051b9e872b25e99/PowerAutomateMockUp/ExpressionParser/ValueContainer.cs#L322

            return _type == ValueType.Null;
        }

        public int CompareTo(object? obj)
        {
            if (obj == null || obj.GetType() != GetType()) throw new InvalidOperationException("Cannot compare these two...");

            var other = (ValueContainer) obj;
            if (other.Type() != _type)
            {
                // TODO: Fix comparison

                throw new InvalidOperationException("Cannot compare two different ValueContainers");
            }
            else
            {
                switch (_value)
                {
                    case bool b:
                        return b.CompareTo(other._value);
                    case int i:
                        return i.CompareTo(other._value);
                    case float f:
                        return f.CompareTo(other._value);
                    case string s:
                        return s.CompareTo(other._value);
                    case Dictionary<string, ValueContainer> d:
                        var d2 = (Dictionary<string, ValueContainer>) other._value;
                        return d.Count - d2.Count;
                    case IEnumerable<ValueContainer> l:
                        var l2 = (IEnumerable<ValueContainer>) other._value;
                        return l.Count() - l2.Count();
                    default:
                        return -1;
                }
            }
        }

        public bool Equals(ValueContainer other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(_value, other._value) && _type == other._type;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != GetType()) return false;
            return Equals((ValueContainer) obj);
        }

        /*public override int GetHashCode()
        {
            return HashCode.Combine(_value, (int) _type);
        }*/
    }

    static class ValueContainerExtensions
ew file mode 100644
ndex 0000000..195cebc
++ b/PowerAutomateMockUp/FlowParser/ActionExecutors/Implementations/DoUntilActionExecutor.cs

1a35a5876b7fafafe7c97fd46d8a9ee05986371e

thygesteffensen commented 3 years ago

:tada: This issue has been resolved in version 1.0.0-alpha.24 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

thygesteffensen commented 3 years ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: