This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Global : HttpApplication | |
{ | |
public void Application_Start() | |
{ | |
// Clears all previously registered view engines. | |
ViewEngines.Engines.Clear(); | |
// Registers our Razor C# specific view engine. | |
// This can also be registered using dependency injection through the new IDependencyResolver interface. | |
ViewEngines.Engines.Add(new RazorViewEngine()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task default -depends GetBuildNumber | |
task GetBuildNumber { | |
Assert ($base_directory -ne $null) '$base_directory should not be null. Try %system.teamcity.build.checkoutDir%' | |
Assert ($solution_name -ne $null) '$solution_name should not be null' | |
$version = gc $base_directory\$solution_name\Properties\AssemblyInfo.cs | select-string -pattern "AssemblyVersion" | Out-String | |
$version | Foreach-Object { Write-Host $_ } | |
$version -imatch '\[assembly: Assembly(File)?Version\("(?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<revision>[0-9]+)\.(?<build>[0-9]+)"\)\]' | Out-Null | |
Assert ($matches -ne $null) 'Unable to find AssemblyVersion string!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SetAssemblyVersion.ps1 | |
# | |
# http://www.luisrocha.net/2009/11/setting-assembly-version-with-windows.html | |
# http://blogs.msdn.com/b/dotnetinterop/archive/2008/04/21/powershell-script-to-batch-update-assemblyinfo-cs-with-new-version.aspx | |
# http://jake.murzy.com/post/3099699807/how-to-update-assembly-version-numbers-with-teamcity | |
# https://github.com/ferventcoder/this.Log/blob/master/build.ps1#L6-L19 | |
Param( | |
[string]$path=$pwd | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo =========================================================================== | |
echo This batch file will upload tomato.trx in the current directory to | |
echo 192.168.11.1 during the router's bootup. | |
echo. | |
echo * Set your ethernet card's settings to: | |
echo IP: 192.168.1.2 | |
echo Mask: 255.255.255.0 | |
echo Gateway: 192.168.1.1. | |
echo * Unplug the router's power cable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Mvc; | |
namespace System.Web.Mvc.Html | |
{ | |
public static class TwitterBootstrapHelperExtensions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^[^\S\r\n]*[^using](?<sql>new SQLiteCommand\((.*), (.*)\))\.ExecuteNonQuery\(\); | |
replace with: | |
using (var c = ${sql})\nc.ExecuteNonQuery(); | |
Finding any SQLiteCommand that is wrapped in a using statement: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[STAThread] | |
static int Main(string[] args) | |
{ | |
//load assembly via the resources (such as using Costura advanced): | |
AttachResolverForLocalPaths(); | |
} | |
public static void AttachResolverForLocalPaths() | |
{ | |
var currentDomain = AppDomain.CurrentDomain; | |
currentDomain.AssemblyResolve += OnCurrentDomainOnAssemblyResolve; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Returns a string containing all of the public properties and fields for a given type. | |
/// </summary> | |
/// <param name="o">Type to print properties and fields for.</param> | |
/// <returns>Properties and fields seperated by newlines.</returns> | |
public static string PrintPublicPropertiesAndFields(this object o, string seperator = "\r\n") | |
{ | |
StringBuilder sb = new StringBuilder(); | |
Type otype = o.GetType(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Dynamically casts a type to another type without knowing the CLR knowing the object's type. Before calling this method, | |
/// ensure the object's type matches what you are trying to cast to! | |
/// </summary> | |
/// <exception cref="System.InvalidCastException"></exception> | |
public static dynamic DynamicCast(this Type T, dynamic o) | |
{ | |
return typeof(ReflectionHelpers).GetMethod("Cast", BindingFlags.Static | BindingFlags.NonPublic) | |
.MakeGenericMethod(T).Invoke(null, new object[] { o }); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Clones all public properties and fiels on one object to another (excluding index based properties). The properties | |
/// must have the same name scheme. Type does not matter. | |
/// </summary> | |
/// <param name="o"></param> | |
/// <param name="destination">Where to clone the properties to.</param> | |
public static void ClonePublicPropertiesAndFields(this object o, object destination) | |
{ | |
if (destination == null) throw new ArgumentNullException("destination", "Destination cannot be null!"); |
OlderNewer