Programming

Recursive Object Properties

Recursive Object Properties I’ve been working to create a virtual file system for SQL databases and represent this in a web interface. While creating the classes in .NET I realised that I needed to be able to traverse all the ancestors of a file up to the root level and Read more…

By Shinigami, ago
Programming

List Shuffling

List Shuffling This is just a simple extension for lists to enable the shuffling of items within it based on the StackOverflow answer here. This relies on System.Random so isn’t as random as it could be but is fine for my purposes. public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source, Random rng) Read more…

By Shinigami, ago
Programming

Enum JSON Converter

Enum JSON converter. In addition to the SingleOrArrayEnumConverter mentioned previously I’ve also created a version to translate enums to/from JSON using the name of the enum rather than it’s value as is the default. class EnumConverter<T> : JsonConverter { public override bool CanConvert(Type objectType) { return (objectType == typeof(T)); } Read more…

By Shinigami, ago
Programming

SQL Stored Procedure in .NET Core

SQL stored procedure in .NET Core. I call SQL stored procedures slightly differently in .NET Core to the way I did in .NET framework as I now pass the connection string through as an argument and I need to remember to add the System.Data.SqlClient NuGet package. public static List<string> GetBlogSummaries(string Read more…

By Shinigami, ago
Programming

Splitting Lists Into Chunks

Splitting lists into chunks. Whilst writing a process to upload instore purchases to Facebook using their offline conversion API I discovered that their API only accepts a maximum of 2,100 events in any one API call. As I already ahd a nice list of events I had a look around Read more…

By Shinigami, ago