Skip to content

Instantly share code, notes, and snippets.

public class JsonFilesRepository
{
private const string Root = "../../../json/";
public Dictionary<string, string> Files { get; } = new();
public JsonFilesRepository(params string[] files)
{
var filesList = files.ToList();
if (!filesList.Any())
foreach (var file in Directory.GetFiles(Root))
<ItemGroup>
<InternalsVisibleTo Include="SpecFlowWebApi.Specs" />
</ItemGroup>
public partial class Program { }
public interface IWeatherRepository
{
Task<IEnumerable<WeatherForecast>> GetAsync();
Task<WeatherForecast?> GetAsync(int id);
Task<WeatherForecast?> AddAsync(WeatherForecast entity);
Task<WeatherForecast?> UpdateAsync(WeatherForecast entity);
Task<int> RemoveAsync(int id);
}
@tonysneed
tonysneed / SaveClassAaJson.cs
Created January 26, 2022 21:49
Save class as Json
void SaveLocalSagaConfig(SagaConfigurationDto sagaConfig)
{
var options = new JsonSerializerOptions
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
};
var json = JsonSerializer.Serialize(sagaConfig, options);
File.WriteAllText(settings.SagaConfigPath, json);
}
@tonysneed
tonysneed / windows-terminal-setup.md
Last active January 14, 2022 12:27
Windows Terminal Setup
@tonysneed
tonysneed / InterfaceConverter.cs
Last active January 12, 2022 06:06
Deserializing Interfaces with System.Text.Json
public class InterfaceConverter<TImplementation, TInterface> : JsonConverter<TInterface>
where TImplementation : class, TInterface
{
public override TInterface? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> JsonSerializer.Deserialize<TImplementation>(ref reader, options);
public override void Write(Utf8JsonWriter writer, TInterface value, JsonSerializerOptions options)
{
}
}
@tonysneed
tonysneed / RiderMacShortcuts.md
Created January 8, 2022 18:37
Rider Mac Shortcut Settings

Rider Mac Shortcut Settings

Mac Shortcuts to Disable

  • Services: Search man page
    • Cmd + Shift + A
  • Mission Control: Disable all
@tonysneed
tonysneed / MyAppSettings.cs
Created January 2, 2022 20:31
Generic AddConfigSettings Extension method
public class MyAppSettings
{
public string StringSetting { get; set; }
public int IntSetting { get; set; }
public bool BoolSetting { get; set; }
}
@tonysneed
tonysneed / msbuild-target-file.xml
Last active December 4, 2021 17:37
MS Build Target File
<Project>
<ItemGroup>
<Files Include="$(MSBuildThisFileDirectory)/../contentFiles/CodeTemplates/**/*.*" />
</ItemGroup>
<Target Name="CopyFiles" AfterTargets="Build">
<Copy SourceFiles="@(Files)" DestinationFolder="$(TargetDir)/CodeTemplates/%(RecursiveDir)" />
</Target>
</Project>