-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
121 changed files
with
4,655 additions
and
29 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Git LFS file not shown
22 changes: 22 additions & 0 deletions
22
Labs/IW5-Excercise-03/CleanCode/CleanCodeSample/CleanCodeSample.sln
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.31101.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanCodeSample", "CleanCodeSample\CleanCodeSample.csproj", "{3E9DD469-D148-4AB9-A00B-7843B6B6DC0E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{3E9DD469-D148-4AB9-A00B-7843B6B6DC0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3E9DD469-D148-4AB9-A00B-7843B6B6DC0E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3E9DD469-D148-4AB9-A00B-7843B6B6DC0E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3E9DD469-D148-4AB9-A00B-7843B6B6DC0E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
6 changes: 6 additions & 0 deletions
6
Labs/IW5-Excercise-03/CleanCode/CleanCodeSample/CleanCodeSample/App.config
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
65 changes: 65 additions & 0 deletions
65
Labs/IW5-Excercise-03/CleanCode/CleanCodeSample/CleanCodeSample/CleanCodeSample.csproj
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{3E9DD469-D148-4AB9-A00B-7843B6B6DC0E}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CleanCodeSample</RootNamespace> | ||
<AssemblyName>CleanCodeSample</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ConsoleHelper.cs" /> | ||
<Compile Include="MathExcercisesProgram.cs" /> | ||
<Compile Include="MathExcercise\AdditionMathExcercise.cs" /> | ||
<Compile Include="MathExcercise\IMathExcercise.cs" /> | ||
<Compile Include="MathExcercise\MathExcerciseRunner.cs" /> | ||
<Compile Include="MathExcercise\MultiplicationMathExcercise.cs" /> | ||
<Compile Include="MathExcercise\SubstractionMathExcercise.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
27 changes: 27 additions & 0 deletions
27
Labs/IW5-Excercise-03/CleanCode/CleanCodeSample/CleanCodeSample/ConsoleHelper.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
|
||
namespace CleanCodeSample | ||
{ | ||
public class ConsoleHelper | ||
{ | ||
|
||
public int ReadNumber(string message) | ||
{ | ||
Console.Write(message); | ||
int input; | ||
if (!int.TryParse(Console.ReadLine(), out input)) | ||
{ | ||
return ReadNumber(message); | ||
} | ||
return input; | ||
} | ||
|
||
public void WriteColorLine(ConsoleColor foregroundColor, string message) | ||
{ | ||
var previouslyForegroundColor = Console.ForegroundColor; | ||
Console.ForegroundColor = foregroundColor; | ||
Console.WriteLine(message); | ||
Console.ForegroundColor = previouslyForegroundColor; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...rcise-03/CleanCode/CleanCodeSample/CleanCodeSample/MathExcercise/AdditionMathExcercise.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace CleanCodeSample.MathExcercise | ||
{ | ||
class AdditionMathExcercise : IMathExcercise | ||
{ | ||
public char Operand { get; } = '+'; | ||
public string OperationName { get; } = "sčítání"; | ||
|
||
public int GetCorrectResult(int leftOperand, int rightOperand) | ||
{ | ||
return leftOperand + rightOperand; | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...W5-Excercise-03/CleanCode/CleanCodeSample/CleanCodeSample/MathExcercise/IMathExcercise.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace CleanCodeSample.MathExcercise | ||
{ | ||
public interface IMathExcercise | ||
{ | ||
char Operand { get; } | ||
string OperationName { get; } | ||
int GetCorrectResult(int leftOperand, int rightOperand); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...cercise-03/CleanCode/CleanCodeSample/CleanCodeSample/MathExcercise/MathExcerciseRunner.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
|
||
namespace CleanCodeSample.MathExcercise | ||
{ | ||
class MathExcerciseRunner | ||
{ | ||
protected ConsoleHelper consoleHelper = new ConsoleHelper(); | ||
|
||
public void Test(IMathExcercise mathExcercise) | ||
{ | ||
var leftOperand = consoleHelper.ReadNumber($"Zadejte 1. číslo pro {mathExcercise.OperationName}: "); | ||
var rightOperand = consoleHelper.ReadNumber($"Zadejte 2. číslo pro {mathExcercise.OperationName}: "); | ||
|
||
var askForSolution = $"{leftOperand} {mathExcercise.Operand} {rightOperand} = "; | ||
var userAnswer = consoleHelper.ReadNumber(askForSolution); | ||
|
||
var correctResult = mathExcercise.GetCorrectResult(leftOperand, rightOperand); | ||
WriteResultMessage(correctResult, userAnswer); | ||
} | ||
|
||
private void WriteResultMessage(int correctResult, int userAnswer) | ||
{ | ||
var wasUserAnswerCorrect = correctResult == userAnswer; | ||
var wasAnswerCorrectMessage = GetWasAnswerCorrectMessage(wasUserAnswerCorrect); | ||
var messageColor = GetMessageColor(wasUserAnswerCorrect); | ||
|
||
string message = $"Vaše odpověď \"{userAnswer}\" {wasAnswerCorrectMessage}"; | ||
consoleHelper.WriteColorLine(messageColor, message); | ||
} | ||
|
||
private static ConsoleColor GetMessageColor(bool wasUserAnswerCorrect) | ||
{ | ||
return wasUserAnswerCorrect ? ConsoleColor.Green : ConsoleColor.Red; | ||
} | ||
|
||
private static string GetWasAnswerCorrectMessage(bool wasUserAnswerCorrect) | ||
{ | ||
return wasUserAnswerCorrect ? "byla správná" : "nebyla správná"; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...03/CleanCode/CleanCodeSample/CleanCodeSample/MathExcercise/MultiplicationMathExcercise.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace CleanCodeSample.MathExcercise | ||
{ | ||
class MultiplicationMathExcercise : IMathExcercise | ||
{ | ||
public char Operand { get; } = '*'; | ||
public string OperationName { get; } = "násobení"; | ||
|
||
public int GetCorrectResult(int leftOperand, int rightOperand) | ||
{ | ||
return leftOperand * rightOperand; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...e-03/CleanCode/CleanCodeSample/CleanCodeSample/MathExcercise/SubstractionMathExcercise.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace CleanCodeSample.MathExcercise | ||
{ | ||
class SubstractionMathExcercise : IMathExcercise | ||
{ | ||
public char Operand { get; } = '-'; | ||
public string OperationName { get; } = "odčítání"; | ||
|
||
public int GetCorrectResult(int leftOperand, int rightOperand) | ||
{ | ||
return leftOperand - rightOperand; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Labs/IW5-Excercise-03/CleanCode/CleanCodeSample/CleanCodeSample/MathExcercisesProgram.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Collections.Generic; | ||
using CleanCodeSample.MathExcercise; | ||
|
||
namespace CleanCodeSample | ||
{ | ||
class MathExcercisesProgram | ||
{ | ||
private readonly List<IMathExcercise> mathExcercises = new List<IMathExcercise> | ||
{ | ||
new AdditionMathExcercise(), | ||
new SubstractionMathExcercise(), | ||
new MultiplicationMathExcercise() | ||
}; | ||
|
||
public void Run() | ||
{ | ||
var mathExcerciseRunner = new MathExcerciseRunner(); | ||
foreach (var mathExcercise in mathExcercises) | ||
{ | ||
mathExcerciseRunner.Test(mathExcercise); | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Labs/IW5-Excercise-03/CleanCode/CleanCodeSample/CleanCodeSample/Program.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CleanCodeSample | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var mathExcercisesProgram = new MathExcercisesProgram(); | ||
mathExcercisesProgram.Run(); | ||
|
||
Console.ReadKey(); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Labs/IW5-Excercise-03/CleanCode/CleanCodeSample/CleanCodeSample/Properties/AssemblyInfo.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("CleanCodeSample")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("CleanCodeSample")] | ||
[assembly: AssemblyCopyright("Copyright © 2015")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("39b2ae37-4084-4a0a-9f83-938ea370bb67")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> | ||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> | ||
</configSections> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
</startup> | ||
<entityFramework> | ||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> | ||
<parameters> | ||
<parameter value="mssqllocaldb" /> | ||
</parameters> | ||
</defaultConnectionFactory> | ||
<providers> | ||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> | ||
</providers> | ||
</entityFramework> | ||
<connectionStrings> | ||
<add name="CookBookContext" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=CookBookDB;MultipleActiveResultSets=True;Integrated Security=True;" providerName="System.Data.SqlClient" /> | ||
</connectionStrings> | ||
</configuration> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Application x:Class="CookBook.App.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:converters="clr-namespace:CookBook.App.Converters" | ||
xmlns:app="clr-namespace:CookBook.App" | ||
StartupUri="Views/MainWindow.xaml"> | ||
<Application.Resources> | ||
<converters:TimeSpanToMinutesConverter x:Key="TimeSpanToMinutesConverter"/> | ||
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/> | ||
<app:ViewModelLocator x:Key="ViewModelLocator" /> | ||
</Application.Resources> | ||
</Application> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Windows; | ||
|
||
namespace CookBook.App | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
} |
Oops, something went wrong.