zoukankan      html  css  js  c++  java
  • csharp: DefaultValueAttribute Class

        public class CalendarEvent
        {
    
    
            public int id { get; set; }
    
            public string title { get; set; }
            
            public string description { get; set; }
    
            [DefaultValue(typeof(DateTime), DateTime.Now.ToString("yyyy-MM-dd HH:mm"))]
            public DateTime start { get; set; }
            [DefaultValue(typeof(DateTime),DateTime.Now.ToString("yyyy-MM-dd HH:mm"))]
            public DateTime end { get; set; }
            [DefaultValue(typeof(bool), "false")]
            public bool allDay { get; set; }
            [DefaultValue(typeof(bool), "false")]
            public bool overlap { get; set; }
            [DefaultValue(typeof(string), "background-color")]
            public string rendering { get; set; } //border-color,background-color 
            [DefaultValue(typeof(string), "#FFFFFF")]
            public string color { get; set; } //
            [DefaultValue(typeof(string), "#FFFFFF")]
            public string backgroundColor { get; set; }
            [DefaultValue(typeof(string), "#FFFFFF")]
            public string textColor { get; set; }
            [DefaultValue(typeof(string),"#FFFFFF")]
            public string borderColor { get; set; }
            [DefaultValue(typeof(int),"0")]
            public int typeid { get; set; }
            [DefaultValue(typeof(DateTime), DateTime.Now.ToString("yyyy-MM-dd HH:mm"))]
            public DateTime adddate { get; set; }
    
    
    
            //private DateTime? dateCreated = null;
    
            //public DateTime DateCreated
            //{
            //    get
            //    {
            //        return this.dateCreated.HasValue
            //           ? this.dateCreated.Value
            //           : DateTime.Now;
            //    }
    
            //    set { this.dateCreated = value; }
            //}
    
    
            public DateTime DateCreated
            {
                get
                {
                    return (this.dateCreated == default(DateTime))
                       ? this.dateCreated = DateTime.Now
                       : this.dateCreated;
                }
    
                set { this.dateCreated = value; }
            }
            private DateTime dateCreated = default(DateTime);
    
            private bool myVal = false;
    
            [DefaultValue(false)]
            public bool MyProperty
            {
                get
                {
                    return myVal;
                }
                set
                {
                    myVal = value;
                }
            }
    
    
        }
    

     http://stackoverflow.com/questions/691035/setting-the-default-value-of-a-datetime-property-to-datetime-now-inside-the-syst 

  • 相关阅读:
    APMServ5.2.6 无法启动Apache的一个问题
    【转】流媒体技术笔记(视频编码相关)
    用APMServ一键快速搭建Apache+PHP+MySQL+Nginx+Memcached+ASP运行平台
    java swing 基础
    python class 类
    python 经验
    python 导入(转)
    kernel ipv4/ip_output.c
    python+正则表达式(转)
    Eclipse中如何快速添加、删除jar包
  • 原文地址:https://www.cnblogs.com/geovindu/p/6742866.html
Copyright © 2011-2022 走看看