zoukankan      html  css  js  c++  java
  • 通过用户登陆消息类,来学习面向对象的实体统一接口和验证统一接口

    namespace Entity
    {
        /// <summary>
        /// 用户登录消息
        /// </summary>
        public class UserLoginMessage : IEntity
        {
            List<string> message = new List<string>();
            /// <summary>
            /// 列表
            /// </summary>
            public List<string> List
            {
                get { return this.message; }
            }

            public IDataEntity Entity { get; set; }

            #region IEntity 成员

            public bool IsValid
            {
                get { return this.message.Count == 0; }
            }

            public IEnumerable<RuleViolation> GetRuleViolations()
            {
                throw new Exception("不提供本方法");
            }

            #endregion

        }
    }

    namespace Entity
    {
        /// <summary>
        /// 模型接口,与数据库无关
        /// </summary>
        public interface IEntity
        {
            /// <summary>
            /// 数据验证(是否成功)
            /// </summary>
            bool IsValid { get; }
            /// <summary>
            /// 获取验证失败的信息枚举,它使用了简单的迭代器,如果GetRuleViolations有错误则返回假
            /// </summary>
            /// <returns></returns>
            IEnumerable<RuleViolation> GetRuleViolations();
           
        }
    }

    namespace Entity
    {
        /// <summary>
        /// 数据库对象统一协调接口
        /// </summary>
        public interface IDataEntity
        {

        }
    }

  • 相关阅读:
    使用CoreData [3]
    使用CoreData [2]
    使用CoreData [1]
    [翻译] CRPixellatedView-用CIPixellate滤镜动态渲染UIView
    简易使用UILabel的富文本
    [翻译] OrigamiEngine
    [翻译] DoActionSheet
    解决tableView中cell动态加载控件的重用问题
    ARC中用代码检测一个对象有没有释放掉
    HTTP请求中浏览器的缓存机制
  • 原文地址:https://www.cnblogs.com/lori/p/2051245.html
Copyright © 2011-2022 走看看