- 博客(58)
- 资源 (15)
- 收藏
- 关注
转载 Linq Expressions – Creating objects
This post shows how you can use Linq expression trees to replace Activator.CreateInstance.but first, please note that this is a followup on Oren’s post so read it before you read mine:http://w
2014-08-27 17:17:27
985
原创 Unit Test 访问Internal类型和方法
原则上Unit Test主要是测试一些Public的类型和方法等,但是有时候我们需要验证标记为Internal的类型是不是正常工作。那么,既然被标记为Internal了,应该就不能被所在项目之外的项目访问了,这时最容易想起来的方式是将Internal标记的类型临时改为Public,此方法可行,但是在大量Internal类型需要修改的时候就不适用:不但修改起来繁琐,还有可能会在最后忘记改回Inter
2014-03-14 11:27:39
4210
1
原创 MEF动态创建新的实例
MEF的基本概念不再赘述,不了解的朋友可以去MEF官网一探究竟。 本文主要分享在MEF中动态创建新实例的三种方法。使用.net 4.5中的ExportFactory类实现;使用反射的方式来实现;使用CompositionContainer类实现。接口定义internal interface IPerson { string Na
2014-03-13 16:28:55
6472
原创 比较C#中几种常见的复制字节数组方法的效率
在日常编程过程中,我们可能经常需要Copy各种数组,一般来说有以下几种常见的方法:Array.Copy,IList.Copy,BinaryReader.ReadBytes,Buffer.BlockCopy,以及System.Buffer.memcpyimpl,由于最后一种需要使用指针,所以本文不引入该方法。 本次测试,使用以上前4种方法,各运行1000万次,观察结果。us
2013-08-16 11:25:56
23987
1
原创 C#自动搜索符合特征的串口号
业务场景:在开发需要用到USB转串口的设备的时候,每次和电脑连接,COM名称都可能会改变。解决办法:最容易想起来的办法是把串口号写在配置文件中(或让用户在UI上选择),这样实际操作起来还是有些繁琐,下面我要介绍的是从CodeProject上看到的一篇文章,可以自动根据串口设备的某些特征来自动搜索特定的串口设备。 举例来说,根据串口的路径里是否包含“FDTIBUS”来判断是不是我要
2013-06-19 12:11:58
7896
转载 The Battle Between Flat Design And Skeuomorphism
If you're paying attention to what's going on in thedesign world, you've probably noticed the ongoing debate aroundskeuomorphism vs flat design.So here's a quick test. Which of these two calculators
2013-02-20 09:39:54
2913
转载 WPF Animations and Performance
I’ve been working on a WPF application that is fully skinned to make everything in the application look custom. WPF makes this really easy…almost too easy. We’ve been adding a lot of animations and
2013-02-17 15:02:46
741
转载 WPF中图形表示语法详解(Path之Data属性语法)
老规矩,看图说话。先看显示效果:(图1)XAML(代码A):http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > PathFigureCollection的表示方法-->P
2013-02-17 15:01:07
1658
转载 Silverlight 4 Binding and StringFormat in XAML
I discovered this amazing feature almost by accident and it has made this one part of my design so much easier that I had to share it.A new feature in Silverlight 4 is the ability to using the Str
2013-01-31 10:17:29
1002
翻译 Visual Studio 2012 Update 1 离线安装方法
最近微软发布了Visual Studio 2012 update 1,不只是包含了100多个bug 的fix,还增加了一些新功能,这是微软中文网站对此的描述:Visual Studio 2012 第一次迭代更新。不过只能通过在线安装,需要下载大概1 GB的程序包,这对大多数电脑来说都是不方便的,MSDN 上有人发布了离线安装更新的办法(How to: Install Visual St
2012-12-16 16:17:44
10175
1
转载 Clean Code Notes
Meaningful NamesUse intention revealing namesAvoid disinformationavoid names with meaningavoid type info (ex: accountList → accounts)avoid long names with minor differencesavoid in
2012-08-29 16:39:13
1387
转载 WPF Cover Flow Tutorial : Part 7 (source)
Before disclosing sources of Part 7, here a few notes.I provide a sample ThumbnailManager, working with an IsolatedStorageFile.view plainprint?public class ThumbnailManager : I
2012-08-29 15:33:19
809
转载 WPF Cover Flow Tutorial : Part 7
After some improvements in the Cover class, let's describe how virtualization works.We do not keep all covers in memory. Remember the drawing in Part 2. At a given time, we only keep a few c
2012-08-29 15:32:18
687
转载 WPF Cover Flow Tutorial : Part 6 (bis)
I'll start with some Cover refactoring :Class becomes internalI add the ICover interface, mainly for unit testing with a fake class implementing ICover :view plainprint?public inte
2012-08-29 15:29:55
934
转载 WPF Cover Flow Tutorial : Part 6
After building a standalone component in Part 5, I wanted to improve performance.I've read many blogs about IScrollInfo, ItemsContainerGenerator, Generator, Selector and ItemsControlclasses. I
2012-08-29 15:26:58
804
转载 WPF Cover Flow Tutorial : Part 5
After Part 4, we will partly refactor the code to build a custom component.We define a new assembly called FlowComponent where we will move most of the code. First, the c# code will be part of
2012-08-29 15:24:45
1453
转载 WPF Cover Flow Tutorial : Part 4
We can improve the HCI from Part 3 with some mouse handling.We add a MouseDown handler method to our Viewport3D :view plainprint?private void OnViewportMouseDown(object sender,
2012-08-29 15:22:34
931
转载 WPF Cover Flow Tutorial : Part 3
In Part 2, we miss the animation part of the flow.In the main TestWindow, we save all the covers in a List :view plainprint?private readonly List coverList = new List(); pub
2012-08-29 15:16:24
770
转载 WPF Cover Flow Tutorial : Part 2
Since Part 1, we now know how to display a cover in 3D.In order to display a reflection mirror, we add another GeometryModel3D to our Model3DGroup. This new element will be based on these points :
2012-08-29 15:14:06
1118
转载 WPF Cover Flow Tutorial : Part 1
Disclaimer : if you don't know anything about WPF, you should read this excellent tutorial. This should be considered as Part 0.Now, I will describe how to develop a Cover Flow component in WPF.
2012-08-29 15:00:13
1439
原创 WPF中的换行符
WPF中UI上和后台代码中的换行符不同。其中:XAML中为 C#代码中为\r\n或者:Environment.NewLine
2012-08-28 10:39:04
29224
1
转载 DateTime.DayOfWeek转换格式
DateTime.DayOfWeek默认获取的是英文格式,Monday、Tuesday等。有时候给用户显示的是中文,有时候用到数字,怎样转换呢。1.转中文。a)用switch,有点儿麻烦,不写了b)用数组string [] Day=new string []{"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};Console.W
2012-08-28 10:30:09
21095
原创 C#计时利器:Stopwatch的使用
本文演示C#计时器:Stopwatch的使用。 页面代码:<Window x:Class="TestStopwatch.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/
2012-08-23 15:28:31
5830
转载 Visual Studio 2012新特性一览
A quick tour of the new features in Visual studio 2012.Code window resizeA feature you can turn on/off is automatic resizing of the code window.When you are editing your code, sele
2012-08-17 13:51:29
5611
转载 Detection of Half-Open (Dropped) Connections
There is a three-way handshake to open a TCP/IP connection, and a four-way handshake to close it. However, once the connection has been established, if neither side sends any data, then no packets are
2012-08-13 13:18:25
1030
原创 VMWare虚拟机使用Bridge无法连接上物理路由器的DHCP
Bridge的本意是桥接,是使用和Host一样的网卡,相当于虚拟机和Host是同一级别的一台真正的机器。但是最近测试过几次之后都不能访问物理路由器组成局域网里的其他电脑,只能与Host去互相访问,修改了很多设置,都不起左右,后来Google了一下,有所灵感,把vmnet1禁用掉。然后,一切都好了,原因是vmnet1自带了DHCP服务器,如果启用的话,虚拟机先去访问这里的DHCP服务器。
2012-07-04 16:44:31
3950
原创 引用Microsoft.Build.Tasks.v4.0出错问题
Microsoft.Build.Tasks命名空间里有很多有用的类和方法(默认在Microsoft.Build.Tasks.v4.0C:\Windows\Microsoft.NET\Framework\v4.0.30319文件夹下). 最近为了为文件签名而需要使用SecurityUtilities,所以引用了它,但是引用之后出错,如图一所示:图一 引用Microso
2012-06-06 09:20:52
5588
转载 职场英语:上司希望你明白的二十四件事
1. Forget about excuses 不要寻找借口 Forget rare exceptions no boss cares why an assignment wasn't done. It's your job to get it done and on time. 上司都会关心为什么分配的工作没有完成,这很少有例外。因此及时完成工作是你的职责。
2012-05-20 12:00:37
2187
转载 回顾:你对Windows 8了解有多少?
从2010年微软Windows 8计划泄露一直延伸到近日Windows 8 Beta版发布。在这近两年的时间里,Windows 8只是偶尔跃入我们的眼帘,让我们对其一知半解,并没有系统的介绍。而本文的目的就是为了方便让广大用户能一气呵成了解Window 8历程。以下是文章内容:AD:从2010年微软Windows 8计划泄露一直延伸到近日Windows 8 Beta版发
2012-05-19 23:38:28
1013
原创 关于C#中的错误:The type 'X' does not exists in the "Y"
这个问题比较隐蔽,VisualStudio报错的文件和错误发生位置都不是问题真正的根源。 当出现这个问题时请检查这个项目中是否有类名和命名空间是否同名,同名的话就修改其中一个。
2012-05-18 10:22:06
998
原创 Kindle DXG的一些使用方法及技巧
总结一下Kindle DXG的一些使用方法及技巧: 一、文件支持和转换 1、文档支持:Kindle支持的文件格式包括Kindle (.AZW, .AZW1),Text (.TXT),PDF (.PDF),Unprotected Mobipocket (.MOBI, .PRC),Audible (.AA, .AAX),MP3 (.MP3)。 2、文档转换: 另
2012-05-06 08:52:49
29081
6
原创 Postgres Sql获取当前连接的客户端列表
可以使用SQL语句来查看当前连接数据库的客户端情况。1.获取当前连接客户端列表:SELECT * FROM pg_stat_activity;2.获取当前连接客户端的个数:SELECT count(*) FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS ConCount;------postgress
2012-02-22 11:14:03
4817
原创 购买火车票攻略
今天早上7点起床,7点半开始登陆12306.cn,到八点7分的时候登进去了,但是一直无法预订,直到8点15分了还是灰色的按钮,再过了几分钟,我朋友说先选择一个以前的日期,然后再返回就可以了,我操作了,然后不知道怎么回事,就被踢出来了。之后就再也没登陆上。 之后我就左手一个手机,右手一个手机,不停的拨打,在打了100多次之后终于打通了,但是在订票的过程中被一个来电打断。后来接着打,
2012-01-07 22:13:04
1042
原创 解决Windows7中无法识别读卡器的问题
Windows7问题还真不少,不是今天软件图标损坏了,就是明天不认识读卡器了,我的创建16GB的相机存储卡从来就没有直接识别过,只能通过读卡器才能认识,刚才又试了多次,还以为是驱动的问题,结果找了一个惠普官网Compaq 515的XP下的读卡器驱动,装上了还是不好使,随谷歌之,还真找到了解决方法,不过这个方法听上去很不可思议。 下面介绍怎么解决这个问题: 打开“计算机”
2011-12-12 19:18:42
13947
原创 Windows下使用批处理设置IP地址
有时候我们更换计算机的网络环境时,可能就需要设置计算机IP地址,而如果每次都通过点击网络连接->属性->IP地址这种方式来设置的话,也未免太繁琐了,下面我来介绍一下使用批处理设置计算机的IP地址。 有时候我们更换计算机的网络环境时,可能就需要设置计算机IP地址,而如果每次都通过点击网络连接->属性->IP地址这种方式来设置的话,也未免太繁琐了,下面我来介绍一下使用批处理
2011-12-12 12:33:31
15484
转载 解决Win7图标损坏
Win7用的时间长了之后就会出现莫名其妙的各种问题。前些日子,VS2010,迅雷的图标都相继变成损坏的模样,后来谷歌之,搜到了一个来自www.imchen.net上的一篇博文,方法也很好使,在此贴出,方便广大网友,也为自己打个Mark。 用记事本复制以下代码并保存为“Win7图标损坏修复程序.BAT”便可!-------------------代码开始-------
2011-12-02 22:33:59
2422
C# Unit Test 访问Internal类型和方法Demo
2014-03-14
verilog SPI slave
2012-09-29
《Windows下使用批处理设置IP地址》的批处理文件
2011-12-12
《C#序列化和反序列化之一-二进制序列化》源代码
2011-10-21
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人