コード例 #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (this == obj)
            {
                return(true);
            }
            if (!GetType().Equals(obj.GetType()))
            {
                return(false);
            }
            RowDataGateway <T> gateway = RowDataGatewayRegistry <T> .GetRowDataGateway();

            object pk1 = gateway.PrimaryKey.Get(this);
            object pk2 = gateway.PrimaryKey.Get(obj);
            bool   equals;

            if (pk1 == null)
            {
                if (pk2 == null)
                {
                    equals = base.Equals(obj);
                }
                else
                {
                    equals = false;
                }
            }
            else
            {
                if (pk2 == null)
                {
                    equals = false;
                }
                else
                {
                    equals = pk1.Equals(pk2);
                }
            }
            return(equals);
        }
コード例 #2
0
        public static RowDataGateway <T> GetRowDataGateway()
        {
            RowDataGateway <T> gateway;

            lock (registry)
            {
                if (registry.Keys.Contains(typeof(T)))
                {
                    gateway = registry[typeof(T)];
                }
                else
                {
                    gateway = new RowDataGateway <T>();

                    registry.Add(typeof(T), gateway);
                }
            }

            return(gateway);
        }