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; | |
| namespace Shouldly | |
| { | |
| static class ShouldlyExtensions | |
| { | |
| public static void ShouldHavePropertyValuesEqualTo(this object actual, object expected) | |
| { | |
| foreach (var prop in expected.GetType().GetProperties()) |
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 Newtonsoft.Json; | |
| using Newtonsoft.Json.Converters; | |
| using Newtonsoft.Json.Serialization; | |
| using System.Web; | |
| using System.Web.Mvc; | |
| using System; | |
| namespace MyMvcApp.ActionResults | |
| { | |
| public class BetterJsonResult : JsonResult |
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.Diagnostics; | |
| namespace Diagnostics | |
| { | |
| public class ExecutionTimer : IDisposable | |
| { | |
| private Stopwatch stopwatch; | |
| private string name; | |
| private Action<string> outputAction; |
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
| Write-Host ( Get-ChildItem C:\somefolder | Measure-Object ).Count |
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
| # Moves only files matching any wildcard in the array | |
| # PowerShell has a bug that throws errors for each non-matching file | |
| # but it still works and moves the matches | |
| # https://github.com/PowerShell/PowerShell/issues/2385 | |
| $filters = @("*.pdf", "*.jpg") | |
| # alternatively read in filters from a text file, separated by newlines | |
| # $filterFile = "C:\filters.txt" | |
| # $filters = Get-Content -Path $filterFile |
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 interface IIndexAccessible<TKey, TValue> | |
| { | |
| TValue this[TKey index] { get; } | |
| } |
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
| <?xml version="1.0" encoding="utf-8" ?> | |
| <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
| <CodeSnippet Format="1.0.0"> | |
| <Header> | |
| <Title>parens</Title> | |
| <Shortcut>parens</Shortcut> | |
| <Description>Code snippet to surround a block of code with parentheses</Description> | |
| <Author>Dan Lumpp</Author> | |
| <SnippetTypes> | |
| <SnippetType>Expansion</SnippetType> |
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.IO; | |
| using System.Reflection; | |
| public static class EmbeddedResources | |
| { | |
| public static string Read(string resourceName) | |
| { | |
| var assembly = Assembly.GetExecutingAssembly(); | |
| var defaultNamespace = assembly.GetName().Name; |
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
| // https://andrewlock.net/creating-strongly-typed-xunit-theory-test-data-with-theorydata/ | |
| public class CalculatorTestData : TheoryData<int, int, int> | |
| { | |
| public CalculatorTestData() | |
| { | |
| Add(1, 2, 3); | |
| Add(-4, -6, -10); | |
| Add(-2, 2, 0); | |
| Add(int.MinValue, -1, int.MaxValue); | |
| Add(1.5, 2.3m, "The value"); // will not compile! |
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.Linq; | |
| namespace System.Collections.Generic; | |
| public static class List | |
| { | |
| public static List<T> From<T>(T value) => new(1) { value }; | |
| public static List<T> From<T>(params T[] values) => values.ToList(); | |
| } |
OlderNewer