This file contains 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 HttpContextBase FakeHttpContext() { | |
var context = new Mock<HttpContextBase>(); | |
var files = new Mock<HttpFileCollectionBase>(); | |
var request = new Mock<HttpRequestBase>(); | |
var response = new Mock<HttpResponseBase>(); | |
var session = new Mock<HttpSessionStateBase>(); | |
var server = new Mock<HttpServerUtilityBase>(); | |
var user = new Mock<IPrincipal>(); | |
var identity = new Mock<IIdentity>(); | |
request.Setup(req => req.ApplicationPath).Returns("~/"); |
This file contains 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
class Program { | |
static void Main(string[] args) { | |
using (var store = new EmbeddableDocumentStore { RunInMemory = true }) { | |
store.Initialize(); | |
using (var session = store.OpenSession()) { | |
session.Store(new Document { Path = "a" }); | |
session.Store(new Document { Path = "a/b" }); | |
session.Store(new Document { Path = "a/b/c" }); | |
session.Store(new Document { Path = "a/d" }); |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<!-- make all references non-private, so they won't be copied to the output folder --> | |
<Target Name="ClearReferenceCopyLocalPaths" AfterTargets="ResolveAssemblyReferences"> | |
<ItemGroup> | |
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" /> | |
</ItemGroup> | |
</Target> |
This file contains 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
# | |
# Add the SQL Server Provider. | |
# Source: http://technet.microsoft.com/en-us/library/cc281962(v=sql.105).aspx | |
# | |
$ErrorActionPreference = "Stop" | |
$sqlpsreg="HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps" | |
if (Get-ChildItem $sqlpsreg -ErrorAction "SilentlyContinue") |
This file contains 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
[TestFixture] | |
public class UshortRegexTest { | |
readonly Regex _ushortRegex = new Regex(@"^( | |
0 # 0 | |
| | |
[1-9]\d{0,3} # 1-9999 | |
| | |
[1-5]\d{4} # 10000-59999 | |
| | |
6[0-4]\d\d\d # 60000-64999 |
This file contains 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.Diagnostics; | |
using Raven.Client.Embedded; | |
using Raven.Client.Listeners; | |
using Raven.Json.Linq; | |
namespace StackOverflow20764813 { | |
internal class Program { | |
private static void Main() { | |
using (var store = new EmbeddableDocumentStore { RunInMemory = true }) { | |
store.RegisterListener(new TestDocumentStoreListener()); |
This file contains 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
function UpdateVcxprojFile($filename) { | |
$content = [xml](Get-Content -Path $filename) | |
$changed = $false | |
$toolsVersion = $content.Project.ToolsVersion | |
if ($toolsVersion -ne "12.0") { | |
$content.Project.ToolsVersion = "12.0" | |
$changed = $true | |
} | |
This file contains 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 FormatKbSizeConverter : IValueConverter { | |
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)] | |
private static extern long StrFormatByteSizeW(long qdw, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszBuf, | |
int cchBuf); | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { | |
var number = System.Convert.ToInt64(value); | |
var sb = new StringBuilder(32); | |
StrFormatByteSizeW(number, sb, sb.Capacity); | |
return sb.ToString(); |
This file contains 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 EncryptingJsonConverter : JsonConverter { | |
private readonly byte[] _encryptionKeyBytes; | |
public EncryptingJsonConverter(string encryptionKey) { | |
if (encryptionKey == null) { | |
throw new ArgumentNullException(nameof(encryptionKey)); | |
} | |
// Hash the key to ensure it is exactly 256 bits long, as required by AES-256 | |
using (var sha = new SHA256Managed()) { |
This file contains 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
[CmdletBinding(SupportsShouldProcess=$True)] | |
Param( | |
[int]$CutoffDays = 150 | |
) | |
$cutoffDate = (Get-Date).AddDays(-$CutoffDays) | |
# get path to cached NuGet packages ("%USERPROFILE$\.nuget\packages") | |
$nugetCachePath = Join-Path "$([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile))" ".nuget\packages" |