随笔分类 -  Code Snippets

摘要:Code Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System; class FlagsAttributeDemo { // Define an Enum without FlagsAttribute. enum ... 阅读全文
posted @ 2009-01-05 16:39 new 维生素C.net() 阅读(307) 评论(0) 推荐(0) 编辑
摘要:if (!Enum.IsDefined(typeof(SearchMode), options)) throw new ArgumentException(Properties.Resources.InvalidEnumerationValue, "options"); 如果数据库中存储的值,在程序里用枚举表示,在做parse的时候可以使用这样的方法监测options的值。 阅读全文
posted @ 2009-01-05 14:53 new 维生素C.net() 阅读(234) 评论(2) 推荐(0) 编辑
摘要:1: public bool Exists(Predicate predicate) 2: { 3: bool returnValue = false; 4: 5: Each(delegate(VALUE value) { returnValue |= predicate(value); }); 6:... 阅读全文
posted @ 2008-12-31 04:41 new 维生素C.net() 阅读(373) 评论(0) 推荐(0) 编辑
摘要:在Microsoft.Practices.ObjectBuilder2中的StagedStrategyChain类中只用的下面的方法来获取枚举里元素的个数: 1: private static int NumberOfEnumValues() 2: { 3: return typeof(TStageEnum).GetFields(BindingFlags.Public ... 阅读全文
posted @ 2008-12-28 16:43 new 维生素C.net() 阅读(1983) 评论(0) 推荐(0) 编辑
摘要:虽然复杂,但是考虑到业务逻辑的需要,这套Lock方案还是相当不错的: 1: CacheItem cacheItemBeforeLock = null; 2: bool lockWasSuccessful = false; 3: 4: do 5: { 6: lock (inMemoryCache.SyncRoot) 7: { 8: ... 阅读全文
posted @ 2008-12-17 01:20 new 维生素C.net() 阅读(382) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示