随笔分类 -  知识总结

主要对一些不容易记住的知识的记录,便于搜索与查找。应该只放在自己的主页上。
实用网页抓取
摘要:本文主要介绍如何抓取网页中的内容、如何解决乱码问题、如何解决登录问题以及对所采集的数据进行处理显示的过程。 阅读全文

posted @ 2014-04-03 23:43 yao2yao4 阅读(9046) 评论(21) 推荐(9)

总结
摘要:1、接口 无依赖的静态方法 常数 枚举类型 接口 无依赖的数据模型2、容器 静态对象 静态方法3、必须为public的情况 xml序列化 Window类派生类的构造函数 模型的属性 单元测试项目的方法 IOC用于构造函数注入的构造函数 阅读全文

posted @ 2013-12-06 22:03 yao2yao4 阅读(188) 评论(0) 推荐(0)

IL命令
摘要:hidebysig means HIDE (a method) BY (its) SIGnaturenop //即No Operation 没有任何操作ldcLoad consti4 int32ldstr.:即Load Stringstlocldlocret //即为 returnM1 minus 1 阅读全文

posted @ 2013-10-15 21:26 yao2yao4 阅读(195) 评论(0) 推荐(0)

秘钥与单元测试
摘要:1、对程序集及单元测试的程序集用同一个秘钥签名;2、打开vs开发人员命令提示,输入:D:cd abc\def\来调整目录到D:\abc\def\;3、输入sn -p Key.pfx Key.PK.pfx回车,以生成公钥文件;4、输入sn -tp Key.PK.pfx回车,以产生公钥;5、在AssemblyInfo.cs中添加[assembly: InternalsVisibleTo("SQLiteHelper.Test,PublicKey=00240000048000009400000006020000002400005253413100040000010001001b950384e 阅读全文

posted @ 2013-10-04 06:39 yao2yao4 阅读(235) 评论(0) 推荐(0)

linux 命令缩写
摘要:su super userapt advanced packaging toolifconfig interface configurationso shared objectfsp fractional second part 阅读全文

posted @ 2013-10-01 19:51 yao2yao4 阅读(145) 评论(0) 推荐(0)

单元测试的替代
摘要:1、智能提示即时进行语句级测试。2、函数的输入、输出、极值通过异常的传递来进行防御编程。3、顶层及捕获异常记录捕获的异常日志。4、需求在体现需求的代码处记录日志。 阅读全文

posted @ 2013-09-11 18:31 yao2yao4 阅读(223) 评论(0) 推荐(0)

获取本机可用端口
摘要:如下:using System;using System.Collections.Generic;using System.Linq;using System.Net.NetworkInformation;namespace ConsoleApplication2{ public static class AvailablePort { /// public static int GetFirstAvailablePort() { const int MAX_PORT = 65535; cons... 阅读全文

posted @ 2013-08-14 20:07 yao2yao4 阅读(376) 评论(0) 推荐(0)

textbox的验证
摘要:代码如下:textBox1.KeyDown += (a, b) => { if (b.KeyCode == Keys.Enter) { textBox2.Focus(); } };textBox1.Leave += delegate { int result; if (!int.TryParse(textBox1.Text.Trim(), out result)) { MessageBox.Show("fsfd"); textB... 阅读全文

posted @ 2013-08-14 07:17 yao2yao4 阅读(303) 评论(0) 推荐(0)

鼠标和键盘操作的全局钩子库
摘要:注意只能用于AnyCPU、.NET版本一致、只能用于Winform。简化后的代码如下:using System;using System.ComponentModel;using System.Reflection;using System.Runtime.InteropServices;using System.Windows.Forms;namespace UserActivityMonitor{ /// /// This class monitors all mouse activities globally (also outside of the application... 阅读全文

posted @ 2013-08-14 06:46 yao2yao4 阅读(720) 评论(0) 推荐(0)

数码管图片
摘要:地址 阅读全文

posted @ 2013-08-12 21:04 yao2yao4 阅读(116) 评论(0) 推荐(0)

正则表达式
摘要:IP^(?!0.0.0.0)(?!255.255.255.255)((25[0-5]|2[0-4]\d|1\d\d|\d\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|\d\d|\d)$子网掩码 ^(254|252|248|240|224|192|128|0)\.0\.0\.0$|^(255\.(254|252|248|240|224|192|128|0)\.0\.0)$|^(255\.255\.(254|252|248|240|224|192|128|0)\.0)$|^(255\.255\.255\.(254|252|248|240|224|192|128|0))$ 阅读全文

posted @ 2013-08-12 21:01 yao2yao4 阅读(248) 评论(0) 推荐(0)

ToString的格式化字符串
摘要:如下:var a = new TimeSpan(1, 2, 3).ToString(@"d\.hh\:mm\:ss");var b = DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss");var c = 12.ToString("0000");var d = 12.ToString("0.00");0.01:02:032013-08-12 20:08:48001212.00 阅读全文

posted @ 2013-08-12 20:10 yao2yao4 阅读(241) 评论(0) 推荐(0)

C# Builder
摘要:如下:class Program{ static void Main(string[] args) { var a = new Class1.Builder().BuildA(1).BuildB(2.1).BuildUp(); Console.Read(); }}public class Class1{ private Class1(Builder builder) { A = builder.A; B = builder.B; } internal int A { get; set; } ... 阅读全文

posted @ 2013-08-04 21:18 yao2yao4 阅读(205) 评论(0) 推荐(0)

获取附加在方法上的Attribute
摘要:如下:class Program{ static void Main(string[] args) { var methodInfo = typeof(Program).GetMethod("Function"); var a = methodInfo.CustomAttributes.First(w => w.AttributeType == typeof(BrowsableAttribute)); var b = (bool)(a.ConstructorArguments.First().Value); Console.R... 阅读全文

posted @ 2013-08-04 20:53 yao2yao4 阅读(270) 评论(0) 推荐(0)

用于创建实例的反射
摘要:如下:(int)Activator.CreateInstance(typeof(int));上面的int一般用接口来处理。该方法的参数是Type类型,而配置是string,所以建立string及其对应的Type的映射就很关键了。 阅读全文

posted @ 2013-08-04 19:56 yao2yao4 阅读(132) 评论(0) 推荐(0)

C# 简单工厂
摘要:如下:public static IList Create(Type type){ if (type == typeof(List)) { return new List(); } if (type == typeof(T[])) { return new T[0]; } throw new Exception();} 阅读全文

posted @ 2013-08-04 19:41 yao2yao4 阅读(101) 评论(0) 推荐(0)

C#单例模式
摘要:如下:sealed class Singleton{ Singleton() { } public static readonly Singleton Instance = new Singleton();} 阅读全文

posted @ 2013-08-04 18:33 yao2yao4 阅读(129) 评论(0) 推荐(0)

C#原型模式
摘要:如下:[Serializable]public class ModelNewTable : ICloneable{ public object Clone() { using (var stream = new MemoryStream()) { var formatter = new BinaryFormatter(); formatter.Serialize(stream, this); stream.Seek(0, SeekOrigin.Begin); retu... 阅读全文

posted @ 2013-08-04 18:32 yao2yao4 阅读(145) 评论(0) 推荐(0)

整洁代码清单
摘要:注释 去除可以在源代码控制系统中可以处理的注释 去除废弃的注释 去除冗余的注释 去除注释掉的代码函数 去除输出参数 去除布尔值参数 去除不会被使用的函数一般 去除重复 去除魔数 类和函数分离出职责 阅读全文

posted @ 2013-08-04 08:32 yao2yao4 阅读(146) 评论(0) 推荐(0)

Visual Studio快捷键设置
摘要:1、查看当前快捷键:环境-键盘-按快捷键2、文本编辑器-C#-显示-行号3、文本编辑器-C#-制表符-插入空格4、文本编辑器-所有语言-没有选定内容时对空行应用剪切或复制命令5、Ctrl+Shift-V 循环粘贴6、Ctrl+Shift-Enter 下开新行7、Ctrl+W 选中单词8、Ctrl+L 剪切当前行9、Ctrl+G 转到某行10、Ctrl+I Ctrl+Shift+I Esc 渐进式搜索 阅读全文

posted @ 2013-08-04 08:22 yao2yao4 阅读(476) 评论(0) 推荐(0)

导航