Skip to content

Instantly share code, notes, and snippets.

View 1saeedsalehi's full-sized avatar

Saeed Salehi 1saeedsalehi

View GitHub Profile
@1saeedsalehi
1saeedsalehi / Result.cs
Last active April 10, 2020 18:23
implementing Result in dotnet
using System;
namespace Excecptions
{
// Still a draft
class Program
{
static void Main(string[] args)
{
Action action = GetThing() switch
@1saeedsalehi
1saeedsalehi / ValueObject.cs
Last active April 1, 2020 12:51
Deal with Primitive Obsession - define ValueObjects in a single line (of C#).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace ValueOf
{
public class ValueOf<TValue, TThis> where TThis : ValueOf<TValue, TThis>, new()
{
using System;
namespace Exceptions
{
public class Result
{
public bool IsSuccess { get; }
public string Error { get; }
public bool IsFailure => !IsSuccess;
@1saeedsalehi
1saeedsalehi / Delete-Bin-Obj-node_Modules-Folders.bat
Created May 28, 2019 07:21
Delete bin obj node_modules folder from whole project
@ECHO off
cls
ECHO Deleting all BIN and OBJ folders...
ECHO.
FOR /d /r . %%d in (bin,obj) DO (
IF EXIST "%%d" (
ECHO %%d | FIND /I "\node_modules\" > Nul && (
ECHO.Skipping: %%d
@1saeedsalehi
1saeedsalehi / Delete-Bin-Obj-node_Modules-Folders.bat
Created May 28, 2019 07:21
Delete bin obj node_modules folder from whole project
@ECHO off
cls
ECHO Deleting all BIN and OBJ folders...
ECHO.
FOR /d /r . %%d in (bin,obj) DO (
IF EXIST "%%d" (
ECHO %%d | FIND /I "\node_modules\" > Nul && (
ECHO.Skipping: %%d
using System;
using System.Windows.Controls;
using System.Windows.Input;
namespace XeRetail.FrontOffice.UI.CustomControls
{
public class TouchScroller : ScrollViewer
{
private double _firstMousePosition;
private bool _isScrolling;
@1saeedsalehi
1saeedsalehi / Iran-IP-Address.json
Created October 17, 2017 09:30
list of IPv4 address allocation in iran based on each state
This file has been truncated, but you can view the full file.
{
"IranCityIP": [
{
"FromIP": "2.144.0.0",
"ToIP": "2.147.255.255",
"Country": "IR",
"Provience": "Tehran",
"City": "Tehran"
},
@1saeedsalehi
1saeedsalehi / DateTimeToPersianDateTimeConverter.cs
Last active February 7, 2021 21:57
Automapper string and date conversion for persian date time
public class DateTimeToPersianDateTimeConverter : ITypeConverter<DateTime, string>
{
private readonly string _separator;
private readonly bool _includeHourMinute;
public DateTimeToPersianDateTimeConverter(string separator = "/", bool includeHourMinute = true)
{
_separator = separator;
_includeHourMinute = includeHourMinute;
}