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
/** | |
* Install-Package mongocsharpdriver | |
* Install-Package newtonsoft.json | |
*/ | |
var document = new BsonDocument | |
{ | |
{ "_id", Guid.NewGuid() }, | |
{ "Name", "Hagbarddenstore" }, | |
{ |
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 Person | |
{ | |
public Person(string firstname, string lastname) | |
{ | |
Firstname = firstname; | |
Lastname = lastname; | |
} | |
public string Firstname { get; private set; } |
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 static class CachedReflector | |
{ | |
private static readonly Dictionary<Type, IEnumerable<PropertyInfo>> _cachedProperties = new Dictionary<Type, IEnumerable<PropertyInfo>>(); | |
public static IEnumerable<PropertyInfo> GetProperties(Type type) | |
{ | |
IEnumerable<PropertyInfo> properties; | |
if (!_cachedProperties.TryGetValue(type, out properties)) | |
{ |
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
1. Tasks are recieved on the "tasks"-queue. | |
2. A worker dequeues a task. | |
3. The worker locks the entity related to the task. | |
4. The worker executes the task with the given entity. | |
5. The worker releases the locked entity. |
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
int ParseTime(string input) | |
{ | |
var totalMinutes = 0; | |
input = Regex.Replace(input.ToLower(), "[^\\d|m|h]", string.Empty); | |
var hoursMatch = Regex.Match(input, "(?<Hours>\\d+)h"); | |
if (hoursMatch.Success) | |
{ |
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 Page | |
{ | |
public Guid Id { get; set; } | |
public DateTime CreatedOn { get; set; } | |
public Dictionary<string, string> Title { get; set; } | |
public Dictionary<string, string> Content { get; set; } | |
} |
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
namespace $NAMESPACE$ | |
{ | |
[System.SerializableAttribute] | |
public class $NAME$ : System.Exception | |
{ | |
/// <summary> | |
/// Initializes a new instance of the <see cref="$NAME$"/> class. | |
/// </summary> | |
public $NAME$() | |
{ |
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
from match in Regex.Matches(actionRoute.Url, "\\{(\\w+)\\}").OfType<Match>() | |
let parameterName = match.Groups[1].Value | |
join parameter in action.GetParameters() on parameterName.ToLower() equals parameter.Name.ToLower() | |
select new { Name = parameterName, Parameter = parameter } |
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
struct TileType | |
{ | |
public static readonly TileType Water = new TileType('~', false, 0.0, "Water", null, "water.png"); | |
public static readonly TileType Sand = new TileType('§', true, 0.75, "Sand", null, "sand.png"); | |
public static readonly TileType Dirt = new TileType('#', true, 1.0, "Dirt", null, "dirt.png"); | |
public static readonly TileType Grass = new TileType('"', true, 1.0, "Grass", null, "grass.png"); | |
public static readonly TileType Pebbles = new TileType('*', true, 1.0, "Pebbles", null, "pebbles.png"); | |
public static readonly TileType Rock = new TileType('^', false, 0.0, "Rock", null, "rocks.png"); | |
public static readonly TileType Tree = new TileType('†', true, 0.5, "Tree", null, "tree.png"); | |
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
void Main() | |
{ | |
var s = File.ReadAllLines("C:\\Users\\kim\\Desktop\\ReportingEvents.log").Last(x => x.ToLower().Contains("installation successful")).Substring(39,19); | |
Console.WriteLine(s); | |
} |