Skip to content

Instantly share code, notes, and snippets.

View JoshClose's full-sized avatar

Josh Close JoshClose

View GitHub Profile
@JoshClose
JoshClose / dotnetlayout.md
Created April 25, 2022 16:17 — forked from davidfowl/dotnetlayout.md
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
void Main()
{
var s = new StringBuilder();
s.AppendLine("Id,Name,A,B,C");
s.AppendLine("1,one,9,8,7");
s.AppendLine("2,two,6,5,4");
using (var reader = new StringReader(s.ToString()))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
csv.Configuration.RegisterClassMap<FooMap>();
@JoshClose
JoshClose / Example.cs
Created May 17, 2019 18:00
CsvHelper writing dictionary values
void Main()
{
var records = new List<Dictionary<string, string>>
{
new Dictionary<string, string> { { "Id", "1" }, { "Name", "one" } },
new Dictionary<string, string> { { "Id", "2" }, { "Name", "two" } }
};
using (var writer = new StringWriter())
using (var csv = new CsvWriter(writer))
{
void Main()
{
using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream))
using (var reader = new StreamReader(stream))
using (var csv = new CsvReader(reader))
{
writer.WriteLine("X,Y,Z");
writer.WriteLine("1.23e-15,2.34e-15,3.45e-15");
writer.Flush();
void Main()
{
using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream))
using (var reader = new StreamReader(stream))
using (var csv = new CsvReader(reader))
{
writer.WriteLine("Id,,Name");
writer.WriteLine("1,,one");
writer.WriteLine("2,,two");
@JoshClose
JoshClose / Game1.cs
Created October 30, 2017 20:04
MonoGame draw issue
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Game1
{
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Id Name
1 one
2 two
using Irony.Parsing;
namespace Irony.Samples.SQLite
{
[Language( "SQLite", "3", "SQLite Grammar" )]
// ReSharper disable once InconsistentNaming
public class SQLiteGrammar : Grammar
{
public SQLiteGrammar() : base( false )
{
@JoshClose
JoshClose / Example1.cs
Created December 2, 2011 02:41
Navigating to the Current Page on WP7
var uri = new Uri( string.Format( "{0}?unique={1}", "SamePage.xaml, Guid.NewGuid() ), UriKind.RelativeOrAbsolute );
RemoveBackEntry = true;
NavigationService.Navigate( uri );
@JoshClose
JoshClose / Example1.xml
Created November 15, 2011 17:15
Making a Custom Window Resizable in WPF
<aero:SystemDropShadowChrome CornerRadius="10" Margin="10">
<Border BorderThickness="1" BorderBrush="Black" Background="White"
Margin="0" CornerRadius="10">
<Grid>
<Border Height="40" Background="#01000000" VerticalAlignment="Top"
CornerRadius="10,10,0,0" MouseLeftButtonDown="DragWindow" />
<Rectangle x:Name="ResizeN" Fill="Yellow" VerticalAlignment="Top"
Height="4" Margin="9,-2,9,0" MouseEnter="DisplayResizeCursor"
MouseLeave="ResetCursor" PreviewMouseLeftButtonDown="Resize" />
<Rectangle x:Name="ResizeE" Fill="Yellow" HorizontalAlignment="Right"