摘要:https://gist.github.com/abombss/2720757public static class WebRequestExtensions { public static HttpWebRequest CloneRequest(this HttpWebRequ...
阅读全文
摘要:public static string Referer { get { var context = HttpContext.Current; return cont...
阅读全文
摘要:/// /// Copies all headers and content (except the URL) from an incoming to an outgoing /// request. /// /// The request to copy from /// The request to copy to public static void CopyTo(this System.Web.HttpRequestBase source, HttpWebRequest destination) ...
阅读全文
摘要:using (TempFile tempFile = new TempFile()) { using (FileStream fs = new FileStream(tempFile.FileName, FileMode.Create, FileAccess.Write, FileShare.Read, 0x1000)) using (Stream input = propertyBag.GetResponse()) { input.CopyTo...
阅读全文
摘要:参考:http://social.msdn.microsoft.com/Forums/vstudio/en-US/aa542153-b2a5-4b14-98a3-572f7b028c61/updated-to-ef6-and-now-my-unittests-dont-work-systemdatasqlclient-could-not-be-loaded?forum=adodotnetentityframeworkhttp://thecurlybrace.blogspot.com/2013/11/entity-framework-5-to-601-upgrade.htmlhttp://rob
阅读全文
摘要:想当年毕业设计就是测试驱动开发,所以从刚入行开始就对单元测试、测试驱动开发有比较深入的认识,刚开始一直作为敏捷开发的忠实粉丝。但是几年工作下来,我开始对单元测试持矛盾的态度:单元测试当然是一种很好的创举,但是具体使用当中,它却经常会产生种种负作用,使开发人员望而生畏。这当然不是因为单元测试这一技术或思想本身的问题,而是实践这一思想的人的问题。当前很多公司使用单元测试的怪现象:如今,很多公司为了说出去好看——我们的开发遵循敏捷开发,拥有近100%的单元测试覆盖率,所以代码质量有非常可靠的保障。但是实际上,单元测试都是软件已经开发完成之后加上去的,而且经常还是由专门分配的几个人去写单元测试的,而这
阅读全文
摘要:using Microsoft.JScript;using System;using System.CodeDom.Compiler;using System.Collections.Generic;using System.Linq;using System.Reflection;using System.Text;using System.Threading.Tasks;namespace Soubisc.Infrastructure{ public static class JEvaluator { private const string JScriptSou...
阅读全文
摘要:1. 用wine直接运行exe。安装wine后有个放exe的文件夹,双击后会自动包装运行。看起来挺方便的,就怕暂用资源比较大;http://www.youtube.com/watch?v=eYISVQBBkJIhttp://winebottler.kronenberg.org/(推荐)http://linfan.info/blog/2012/03/01/wine-mac/http://wiki.winehq.org/2. 用mac os 终端运行mono编译后的exe;有个问题,这个终端窗口关闭则exe窗口也会关闭;http://www.cnblogs.com/codelove/archive
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data.Common;namespace System.Data{ /// /// MultipleActiveResultSets=True; /// [Serializable] public sealed class ConnectionStringBuilder : DbConnectionStringBuilder { #region Pro...
阅读全文
摘要:You should never use Thread.VolatileRead/Write(). It was a design mistake in .NET 1.1, it uses a full memory barrier. This was corrected in .NET 2.0, but they couldn't fix these methods anymore and had to add a new way to do it, provided by the System.Threading.Volatile class. Which is a class t
阅读全文
摘要:Typically, services are designed to run unattended without any UI with any need to interact with desktop or any GUI application. However, in some cases, it is desired to let the service show and communicate with graphical applications. A reason might be to track an already developed application and
阅读全文
摘要:using System;using System.Diagnostics;using System.IO;using System.Linq;using System.Management;using System.Runtime.InteropServices;using System.Text;namespace Metasharp{ public class DriveManager { #region SetLabel /// /// set a drive label to the desired value /...
阅读全文
摘要:gacutil /if E:\ThirdParty\RockyLib\Rocky\bin\Release\Rocky.dllgacutil /u RockyView Code partial class GmailForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being u...
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data.Common;using System.Data.Linq;using System.Reflection;using System.Linq.Expressions;using System.Collections;using System.Text.RegularExpressions;namespace Rocky.Data{ /// <summary> /// Business
阅读全文
摘要:HTTP隧道是一种通信技术,通过该技术,使用不同的网络协议,使用HTTP协议,网络协议问题通常属于TCP / IP的协议族的封装。HTTP协议,因此,作为一个通道,被传输的网络协议进行通信时使用的包装。HTTP流,其隐蔽通道被称为一个HTTP隧道。HTTP隧道软件由客户端-服务器的HTTP隧道与现有的应用软件集成的应用程序,允许它们被用在条件受限的网络连接,包括防火墙的网络。 HTTP隧道机制:希望与远程主机进行通信的应用程序打开一个HTTP连接到一个中介服务器,充当通信中继和远程主机。然后,应用程序与中介服务器使用HTTP请求,这些请求内封装的实际通信。中介服务器解开前的实际数据转发到...
阅读全文
摘要:更新使用.net 4.0Parallel 来代替 new Thread();/*********************************************************************************** File Name : FileTransmitor.cs** Copyright (C) 2010 Snda Network Corporation. All Rights Reserved.** Creator : RockyWong** Create Date : 2010-06-02 11:22:45...
阅读全文
摘要:string menuShortcut = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), string.Format(@"{0}\{1}.appref-ms", Application.CompanyName, Application.ProductName)); Console.Out.WriteInfo(menuShortcut); string startupShort...
阅读全文
摘要:private Socket GetPushSock(Stream pushStream) { var prop = pushStream.GetType().GetProperty("InternalSocket", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty); return (Socket)prop.GetValue(pushStream, null); }
阅读全文
摘要:/// <summary> /// Expression visitor /// (from http://blogs.msdn.com/mattwar/archive/2007/07/31/linq-building-an-iqueryable-provider-part-ii.aspx) /// </summary> public abstract class ExpressionVisitor { protected ExpressionVisitor() { } protected virtual E...
阅读全文
摘要:var reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (reg.GetValue(_notify.Text) == null) { reg.SetValue(_notify.Text, Application.ExecutablePath); Console.Out.Writ...
阅读全文