using System;
using Machinations.FromFlash.graph;

namespace Machinations.UserComponents
{
    public struct MergedConnectionKey
    {
        private readonly GraphConnection m_innerConnection;
        private readonly GraphConnection m_outerConnection;

        public MergedConnectionKey(GraphConnection innerConnection, GraphConnection outerConnection)
        {
            m_innerConnection = innerConnection;
            m_outerConnection = outerConnection;
        }

        public GraphConnection InnerConnection
        {
            get { return m_innerConnection; }
        }

        public GraphConnection OuterConnection
        {
            get { return m_outerConnection; }
        }

        public override bool Equals(Object obj)
        {
            return obj is MergedConnectionKey && this == (MergedConnectionKey)obj;
        }
        public override int GetHashCode()
        {
            return InnerConnection.GetHashCode() ^ OuterConnection.GetHashCode();
        }
        public static bool operator ==(MergedConnectionKey x, MergedConnectionKey y)
        {
            return x.InnerConnection == y.InnerConnection && x.OuterConnection == y.OuterConnection;
        }
        public static bool operator !=(MergedConnectionKey x, MergedConnectionKey y)
        {
            return !(x == y);
        }
    }
}