Skip to content

Instantly share code, notes, and snippets.

View kolosovpetro's full-sized avatar

Petro Kolosov kolosovpetro

View GitHub Profile
using System;
namespace SolidRules.ISP
{
public class DrivableBad : IDrivable
{
public void Drive() => Console.WriteLine("Driving...");
public void Fly() => Console.WriteLine("Flying....");
using System;
namespace SolidRules.ISP
{
public class DrivableBad : IDrivable, IFlyable, ISwimable
{
public void Drive() => Console.WriteLine("Driving...");
public void Fly() => Console.WriteLine("Flying....");
namespace SolidRules.LSP
{
public class Rectangle
{
protected double Width { get; }
private double Height { get; }
public Rectangle(double width, double height)
{
Width = width;
using System;
namespace SolidRules.SRP
{
// SRP is not violated here
public class SrpFriendly
{
private readonly ConsoleNotifier _notifier = new ConsoleNotifier();
private readonly ConsoleReader _reader = new ConsoleReader();
private readonly StringValidator _validator = new StringValidator();
@kolosovpetro
kolosovpetro / Chain.cs
Last active April 4, 2021 21:23
Chain
using System;
namespace Chain
{
internal static class Program
{
private static void Main()
{
var ch = new ChildHairdresser();
var wm = new WomenHairDresser();
@kolosovpetro
kolosovpetro / FluentFilter.cs
Last active April 4, 2021 21:23
FluentFilter.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace Fluent
{
public static class Program
{
public static void Main()
{
using System;
class Account
{
public void Main()
{
Action<string> action = (str) => Console.WriteLine(str);
action("test");
}
}
using System;
class Account
{
public delegate void AccountHandler(string message);
public event AccountHandler Notify; // 1.Определение события
public Account(int sum)
{
Sum = sum;
}
public int Sum { get; private set;}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
public class C {
public void Main()
{
var str = new DisposableStruct();
using(str) {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
public class C {
public async Task M() {
Console.WriteLine("Before await");
await Task.Delay(1000);
Console.WriteLine("After await");
}