This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace SolidRules.ISP | |
| { | |
| public class DrivableBad : IDrivable | |
| { | |
| public void Drive() => Console.WriteLine("Driving..."); | |
| public void Fly() => Console.WriteLine("Flying...."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace SolidRules.ISP | |
| { | |
| public class DrivableBad : IDrivable, IFlyable, ISwimable | |
| { | |
| public void Drive() => Console.WriteLine("Driving..."); | |
| public void Fly() => Console.WriteLine("Flying...."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace SolidRules.LSP | |
| { | |
| public class Rectangle | |
| { | |
| protected double Width { get; } | |
| private double Height { get; } | |
| public Rectangle(double width, double height) | |
| { | |
| Width = width; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace Chain | |
| { | |
| internal static class Program | |
| { | |
| private static void Main() | |
| { | |
| var ch = new ChildHairdresser(); | |
| var wm = new WomenHairDresser(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| namespace Fluent | |
| { | |
| public static class Program | |
| { | |
| public static void Main() | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| class Account | |
| { | |
| public void Main() | |
| { | |
| Action<string> action = (str) => Console.WriteLine(str); | |
| action("test"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); | |
| } |