Пример #1
0
        public override void CopyStructData(LinkSystemObject other)
        {
            //value = ((LinkObj<T>)other).value;
            LinkObj <T> o = other as LinkObj <T>;           //解决拆箱的问题

            if (o != null)
            {
                value = o.value;
            }
            else
            {
                value = (T)other.GetLinkData();
            }
        }
        public sealed override bool Equals(object obj)
        {
            LinkObj <T> other = obj as LinkObj <T>;

            if (other != null)
            {
                if (value != null)
                {
                    return(value.Equals(other.value));
                }
                else if (other.value != null)
                {
                    return(other.value.Equals(value));
                }
                else
                {
                    return(Equals(other.value, value));
                }
            }
            else
            {
                LinkObj <object> o2 = obj as LinkObj <object>;
                if (o2 != null)
                {
                    if (value != null)
                    {
                        return(value.Equals(o2.value));
                    }
                    else if (o2.value != null)
                    {
                        return(o2.value.Equals(value));
                    }
                    else
                    {
                        return(Equals(value, o2.value));
                    }
                }
                else
                {
                    return(false);
                }
            }
        }