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
csharp: DefaultValueAttribute Class的更多相关文章
- c#操作MangoDB 之MangoDB CSharp Driver驱动详解
序言 MangoDB CSharp Driver是c#操作mongodb的官方驱动. 官方Api文档:http://api.mongodb.org/csharp/2.2/html/R_Project_ ...
- c#进阶之神奇的CSharp
CSharp 简写为c#,是一门非常年轻而又有活力的语言. CSharp的诞生 在2000年6月微软发布了c#这门新的语言.作为微软公司.NET 平台的主角,c#吸收了在他之前诞生的语言(c ...
- WindowsCE project missing Microsoft.CompactFramework.CSharp.targets in Visual Studio 2008
00x0 前言 之前在Windows 7系统中开发的WindowsCE项目,最近换成Windows 10系统,需要将项目进行修改,打开项目后提示如下错误: 无法读取项目文件"App.cspr ...
- csharp: Oracle Stored Procedure DAL using ODP.NET
paging : http://www.codeproject.com/Articles/44858/Custom-Paging-GridView-in-ASP-NET-Oracle https:// ...
- Excel转Json,Json转CSharp
一份给策划最好的礼物!就是:Excel2Json2CSharp 策划配置Excel,动不动就要改数值啊,增加字段啊. 程序这边对应的解析类就得改动啊.整一个麻烦了得! 所以我就整理了这个Excel2J ...
- Microsoft.CompactFramework.CSharp.targets not found
今天打开VS2008的智能设备项目,报以下错误,应该是文件找不到了. The imported project "C:\WINDOWS\Microsoft.NET\Framework\v3. ...
- CSharp 相关知识点小结
1.JS获取iframe下面的内容document.getElementById('IFRAME1').contentDocument; 2.dialog 弹出层,定位:postion:'bottom ...
- 自己动手制作CSharp编译器
在你喜欢的位置(如F盘根目录)新建一个文件夹,并命名为“CSharp开发环境”.找到或下载C#编译器组件(csc.exe和cscui.exe),并放在先前建立的文件夹中.该组件的一般位置在C盘的.NE ...
- Storm系列(二):使用Csharp创建你的第一个Storm拓扑(wordcount)
WordCount在大数据领域就像学习一门语言时的hello world,得益于Storm的开源以及Storm.Net.Adapter,现在我们也可以像Java或Python一样,使用Csharp创建 ...
随机推荐
- cf 20C Dijkstra?
带队列 dijkstra #include <iostream> #include <cstdio> #include <queue> #include < ...
- 【转】vim 命令
Vim命令合集 建议直接看原文:(排版有些乱) 命令历史 以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令. 启动vim 在命令行窗口中输入以下命令即可 vim 直接 ...
- SpringCloud总结
初级入门使用轮廓,整理一下思路
- Servlet案例6:显示用户的上次访问时间
这里是cookie的简单应用 告诉用户您的上次访问时间是:xxxx-xx-xx xx:xx:xx 思路: 第一次访问该网站时候,记录当前访问时间(new Date()) 把当前时间以cookie的形式 ...
- JS应用实例2:轮播图
在学习轮播图之前,要先会切换图片: 找三张图片,命名1.jpg,2.jpg,3.jpg 示例: <!DOCTYPE html> <html> <head> < ...
- welcome-file-list修改后不生效
用别的浏览器重新尝试一下,或者清缓存.我就是这样解决的.值得注意的就是,<welcome-file>里面指定的文件可以是.do或者是action.
- MapReduce对交易日志进行排序的Demo(MR的二次排序)
1.日志源文件 (各个列分别是: 账户,营业额,花费,日期) zhangsan@163.com 6000 0 2014-02-20 lisi@163.com 2000 0 2014-02-20 lis ...
- dotnet new 命令使用模板生成Angular应用
dotnet new 命令使用模板快速生成单页应用,本文以Angular应用为例. 最新版.NET Core SDK RC4 最大改动是更新了 dotnet new 命令. dotnet new 默认 ...
- Python之unittest测试代码
前言 编写函数或者类时,还可以为其编写测试.通过测试,可确定代码面对各种输入都能够按要求的那样工作. 本次我将介绍如何使用Python模块unittest中的工具来测试代码. 测试函数 首先我们先编写 ...
- Percona 数据库
1. Percona介绍 Percona Server由领先的MySQL咨询公司Percona发布. Percona Server是一款独立的数据库产品,其可以完全与MySQL兼容,可以在不更改代码的 ...