static public void Main()
    {
        MyObject o1 = new MyObject()
        {
            Name  = "a",
            Price = 1
        };
        MyObject o2 = new MyObject()
        {
            Name  = "b",
            Price = 1
        };
        MyObject o3 = new MyObject()
        {
            Name  = "a",
            Price = 1
        };

        Console.WriteLine("o1 == o2: {0}", o1.Equals(o2));
        Console.WriteLine("o1 == o3: {0}", o1.Equals(o3));
        Console.ReadKey();
    }
示例#2
0
 public bool Equals(DependencyGraphNode <T, T2> other)
 {
     if (other == null)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     if (Root != null)
     {
         return(Root == other.Root &&
                (MyObject.Equals(default(T)) && other.MyObject.Equals(default(T)) ||
                 MyObject?.Equals(other.MyObject) == true));
     }
     return(false);
 }
        public override bool Equals(object obj)
        {
            if (obj is DependencyGraphNode <T, T2> objOtherNode)
            {
                if (Root != null)
                {
                    return(Root == objOtherNode.Root &&
                           (MyObject.Equals(default(T)) && objOtherNode.MyObject.Equals(default(T)) ||
                            MyObject?.Equals(objOtherNode.MyObject) == true));
                }
                if (objOtherNode.Root != null)
                {
                    return(false);
                }
            }

            // ReSharper disable once BaseObjectEqualsIsObjectEquals
            return(base.Equals(obj));
        }
示例#4
0
        public override bool Equals(object obj)
        {
            if (Root != null)
            {
                if (obj is DependancyGraphNode <T> objOtherNode)
                {
                    return(Root == objOtherNode.Root && (MyObject == null && objOtherNode.MyObject == null || MyObject?.Equals(objOtherNode.MyObject) == true));
                }
            }
            else if (obj is DependancyGraphNode <T> objOtherNode && objOtherNode.Root != null)
            {
                return(false);
            }

            // ReSharper disable once BaseObjectEqualsIsObjectEquals
            return(base.Equals(obj));
        }