예제 #1
0
            public bool Equals(Temp other)
            {
                if (other == null)
                {
                    throw new Exception("Equals failed.");
                }
                if (ReferenceEquals(this, other))
                {
                    throw new Exception("Equals failed.");
                }
                if (IntIntArray.Rank != other.IntIntArray.Rank)
                {
                    throw new Exception("Equals failed.");
                }

                for (var i = 0; i < IntIntArray.Rank; ++i)
                {
                    for (var j = 0; j < IntIntArray.GetLength(i); ++j)
                    {
                        if (IntIntArray[j, i] != other.IntIntArray[j, i])
                        {
                            throw new Exception("Equals failed.");
                        }
                    }
                }

                if (Exception.GetType() != other.Exception.GetType())
                {
                    throw new Exception("Equals failed.");
                }
                if (Exception.Message != other.Exception.Message)
                {
                    throw new Exception("Equals failed.");
                }
                if (Exception.InnerException != null &&
                    Exception.InnerException.GetType() != other.Exception.InnerException.GetType())
                {
                    throw new Exception("Equals failed.");
                }

                for (var i = 0; i < SubArray.Length; i++)
                {
                    if (SubArray[i].GetType() != other.SubArray[i].GetType())
                    {
                        throw new Exception("Equals failed.");
                    }

                    if (SubArray[i] is Array arr)
                    {
                        var oArr = (Array)other.SubArray[i];
                        for (var j = 0; j < arr.Length; ++j)
                        {
                            if (!arr.GetValue(j).Equals(oArr.GetValue(j)))
                            {
                                throw new Exception("Equals failed.");
                            }
                        }
                    }
                    else if (!SubArray[i].Equals(other.SubArray[i]))
                    {
                        throw new Exception("Equals failed.");
                    }
                }

                foreach (var key in Dictionary.Keys)
                {
                    if (!Dictionary[key].Equals(other.Dictionary[key]))
                    {
                        throw new Exception("Equals failed.");
                    }
                }

                foreach (var key in ImmutableDictionary.Keys)
                {
                    if (!ImmutableDictionary[key].Equals(other.ImmutableDictionary[key]))
                    {
                        throw new Exception("Equals failed.");
                    }
                }

                if (other.Delegate(2, 2) != 4)
                {
                    throw new Exception("Equals failed.");
                }

                if (!IntArray.SequenceEqual(other.IntArray))
                {
                    throw new Exception("Equals failed.");
                }
                if (!Equals(Poco, other.Poco))
                {
                    throw new Exception("Equals failed.");
                }
                if (String != other.String)
                {
                    throw new Exception("Equals failed.");
                }
                if (!TestEnum.SequenceEqual(other.TestEnum))
                {
                    throw new Exception("Equals failed.");
                }
                if (!ImmutableList.SequenceEqual(other.ImmutableList))
                {
                    throw new Exception("Equals failed.");
                }

                return(true);
            }