Skip to content

Instantly share code, notes, and snippets.

View PatrickRainer's full-sized avatar

Patrick PatrickRainer

View GitHub Profile
@PatrickRainer
PatrickRainer / DatePickerConverter.cs
Last active October 22, 2020 12:12
Xamarin Snippets
using System;
using System.Globalization;
using Xamarin.Forms;
namespace Av_Planner_Demo.Controls.Converters
{
public class DatePickerConverter : IValueConverter
{
DateTime _timePickerDate;
@PatrickRainer
PatrickRainer / MinimalContainer.cs
Last active October 22, 2020 13:02
Minimal IOC
public class MinimalContainer
{
private readonly Dictionary<Type, Type> types = new Dictionary<Type, Type>();
public void Register<TInterface, TImplementation>() where TImplementation : TInterface
{
types[typeof(TInterface)] = typeof(TImplementation);
}
public TInterface Create()
public IEnumerable<LicenseType> LicenseTypes =>
Enum.GetValues(typeof(LicenseType))
.Cast<LicenseType>();
public LicenseType SelectedLicenseType
{
get => _selectedLicenseType;
set
{
_selectedLicenseType = value;
var properties = typeof(Phrase).GetProperties();
foreach (var prop in properties)
{
Console.Write(prop.GetValue(document) + " | ");
}
@PatrickRainer
PatrickRainer / ThrowingObject.cs
Created October 28, 2022 07:23
Shows a throwing Object in Godot without RB
using Godot;
public class ThrowingObject : Area2D
{
[Export()]float _throwDistance = 400;
[Export()]float _throwHeight = 400f;
Vector2 _startPos;
Vector2 _endPos;
float _radius;
@PatrickRainer
PatrickRainer / YearMonth.cs
Created October 3, 2023 08:45
A class for using YearMonth DataType
using System.Collections.ObjectModel;
/// <summary>
/// Represents a year and a month
/// </summary>
public struct YearMonth : IComparable<YearMonth>
{
public YearMonth(int year, int month)
{
if (year < 1900 || year > 9999)
public class FilePath
{
public FilePath(string fullPath)
{
FullPath = fullPath;
}
public string FullPath { get; }
public string FileName => Path.GetFileName(FullPath);