예제 #1
0
        public List <T> QueryData <T>(string sql, IDataRelation <T> relation)
        {
            var list = new List <T>();

            if (NotImplementedAttribute.IsMethodNotImplemented(this.GetType().Name, "CreateDataAdapter") == false &&
                NotImplementedAttribute.IsMethodNotImplemented(relation.GetType().Name, "DataRowToEntity") == false)
            {
                this.CreateDataAdapter(sql);
                var dt = new DataTable();
                this.DataAdapter.Fill(dt);

                foreach (DataRow dr in dt.Rows)
                {
                    list.Add(relation.DataRowToEntity(dr));
                }
                return(list);
            }

            if (NotImplementedAttribute.IsMethodNotImplemented(this.GetType().Name, "CreateDataReader") == false &&
                NotImplementedAttribute.IsMethodNotImplemented(relation.GetType().Name, "DataReaderToEntity") == false)
            {
                this.CreateDataReader(sql);
                while (this.DataReader.Read())
                {
                    list.Add(relation.DataReaderToEntity(this.DataReader));
                }
                return(list);
            }

            throw new NotImplementedException(this.GetType().ToString());
        }
        public void ValidationAttribute_Throws_NotImplementedException_From_IsValid()
        {
            var attribute = new NotImplementedAttribute();

            ExceptionHelper.ExpectException <NotImplementedException>(delegate() {
                attribute.IsValid(null);
            });
        }
        public void ValidationAttribute_Throws_NotImplementedException_From_GetValidationResult()
        {
            var attribute = new NotImplementedAttribute();
            var instance  = new object();

            ExceptionHelper.ExpectException <NotImplementedException>(delegate() {
                attribute.GetValidationResult(instance, new ValidationContext(instance, null, null));
            });
        }
예제 #4
0
        /***************************************************/

        public static bool IsNotImplemented(this Type type)
        {
            if (type == null)
            {
                return(true);
            }

            NotImplementedAttribute attribute = type.GetCustomAttribute <NotImplementedAttribute>();

            return(attribute != null);
        }
예제 #5
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static bool IsNotImplemented(this MethodBase method)
        {
            if (method == null)
            {
                return(true);
            }

            NotImplementedAttribute attribute = method.GetCustomAttribute <NotImplementedAttribute>();

            return(attribute != null);
        }