Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a30545e
MaldelbrotSet
Oct 6, 2020
95f44cd
Добавил maybebuilder в main и output
Oct 6, 2020
7baa153
Все построилось все работает, тока для терпеливых
Oct 7, 2020
d8e6c09
Исправил магические числа и убрал лишний код
Oct 7, 2020
138c188
CalculatorASPProject
Oct 11, 2020
8028afc
Написал Proxy class
Oct 11, 2020
c8a2930
ProxyMiddleware делает какую то фигню неправильную надо разобраться
Oct 11, 2020
ba3ba83
Клиент
Oct 12, 2020
34f4cfe
Теперь все работает :)
Oct 12, 2020
6b0d5d1
Update Program.fs
Oct 12, 2020
cee1a92
Update Program.fs
Oct 12, 2020
e609fa1
Вроде все правильно
Oct 14, 2020
b5a0924
Update Program.fs
Oct 14, 2020
1766153
Update Program.fs
Oct 14, 2020
33a3e3c
Убрал лишнее
Oct 14, 2020
0c36c55
Update Program.fs
Oct 14, 2020
dbf97d8
Пока как то так
Oct 26, 2020
896d0d5
:(
Oct 26, 2020
ca9a29e
Добавил запросы
Oct 26, 2020
6d5ffac
Доделал запросы
Oct 26, 2020
5b8a77b
Сделал запросы компактнее
Oct 26, 2020
31a561e
Строиться дерево, но пока скобки игнорит
Oct 27, 2020
ea775f7
Теперь скобки учитывает тоже
Oct 27, 2020
77f162d
По человечески выглядит
Oct 27, 2020
3e28717
Сделал static
Oct 27, 2020
b73cc95
Ощибка
Oct 28, 2020
fce65cb
:(
Oct 28, 2020
5635e70
а
Oct 28, 2020
fe4fda2
Вроде все работает
Oct 29, 2020
b93e115
Middleware теперь зависимость
Nov 1, 2020
e1969b4
Добавил зависимость
Nov 1, 2020
b138b19
Update Program.cs
Nov 1, 2020
63223d6
Добавил тесты
Nov 2, 2020
1913bf9
Update UnitTest1.cs
Dec 13, 2020
c02371c
ничего умнее не придумал :(
Dec 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Calculator/Calculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public decimal Calc(decimal arg1, decimal arg2, string oper)
{
return _calculatorOperations[oper](arg1, arg2);
}
public decimal GetNumber(string s)
public static decimal GetNumber(string s)
{
const NumberStyles styles = NumberStyles.AllowDecimalPoint;
var provider = new CultureInfo("en-US");
Expand Down
35 changes: 35 additions & 0 deletions CalculatorASP/Calculator/Calculator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Globalization;

namespace Calculator
{
public class Calculator
{
private readonly Dictionary<string, Func<decimal, decimal, decimal>> _calculatorOperations =
new Dictionary<string, Func<decimal, decimal, decimal>>()
{
{"+", (a, b) => a + b },
{"-", (a, b) => a - b },
{"*", (a, b) => a * b },
{"/", (a, b) => a / b }
};
public decimal Calc(decimal arg1, decimal arg2, string oper)
{
return _calculatorOperations[oper](arg1, arg2);
}
public decimal GetNumber(string s)
{
const NumberStyles styles = NumberStyles.AllowDecimalPoint;
var provider = new CultureInfo("en-US");
return decimal.Parse(s, styles, provider);
}
public decimal Calc(string s)
{
var str = s.Split();
var arg1 = GetNumber(str[0]);
var arg2 = GetNumber(str[2]);
return Calc(arg1, arg2, str[1]);
}
}
}
19 changes: 19 additions & 0 deletions CalculatorASP/Calculator/Calculator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
23 changes: 23 additions & 0 deletions CalculatorASP/Calculator/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace Calculator
{
[ExcludeFromCodeCoverage]
internal static class Program
{
private static void Main()
{
try
{
var calculator = new Calculator();
var str = Console.ReadLine();
var value = calculator.Calc(str);
Console.WriteLine(value);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
43 changes: 43 additions & 0 deletions CalculatorASP/CalculatorASP.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30523.141
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculatorASP", "CalculatorASP\CalculatorASP.csproj", "{11D5E5E8-8456-4A3D-9038-496437BF33D0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calculator", "..\Calculator\Calculator.csproj", "{84C2F09B-E7D2-4214-AAE0-6E3F20F103F3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExpressionTree", "ExpressionTree\ExpressionTree.csproj", "{4C3EF061-3AF3-41DA-A0AC-1B6F5DFC5EFE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTestCalculatorServer", "XUnitTestCalculatorServer\XUnitTestCalculatorServer.csproj", "{04CDFA1C-36F3-4ABA-BD2E-BC2C2DBDC343}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{11D5E5E8-8456-4A3D-9038-496437BF33D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11D5E5E8-8456-4A3D-9038-496437BF33D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11D5E5E8-8456-4A3D-9038-496437BF33D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11D5E5E8-8456-4A3D-9038-496437BF33D0}.Release|Any CPU.Build.0 = Release|Any CPU
{84C2F09B-E7D2-4214-AAE0-6E3F20F103F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84C2F09B-E7D2-4214-AAE0-6E3F20F103F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84C2F09B-E7D2-4214-AAE0-6E3F20F103F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84C2F09B-E7D2-4214-AAE0-6E3F20F103F3}.Release|Any CPU.Build.0 = Release|Any CPU
{4C3EF061-3AF3-41DA-A0AC-1B6F5DFC5EFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C3EF061-3AF3-41DA-A0AC-1B6F5DFC5EFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C3EF061-3AF3-41DA-A0AC-1B6F5DFC5EFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C3EF061-3AF3-41DA-A0AC-1B6F5DFC5EFE}.Release|Any CPU.Build.0 = Release|Any CPU
{04CDFA1C-36F3-4ABA-BD2E-BC2C2DBDC343}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04CDFA1C-36F3-4ABA-BD2E-BC2C2DBDC343}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04CDFA1C-36F3-4ABA-BD2E-BC2C2DBDC343}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04CDFA1C-36F3-4ABA-BD2E-BC2C2DBDC343}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B882847A-B94B-491F-BB5A-5E7A7C064526}
EndGlobalSection
EndGlobal
15 changes: 15 additions & 0 deletions CalculatorASP/CalculatorASP/CalculatorASP.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.7.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Calculator\Calculator.csproj" />
</ItemGroup>

</Project>
21 changes: 21 additions & 0 deletions CalculatorASP/CalculatorASP/CalculatorMiddleware.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System;
using System.Threading.Tasks;

namespace CalculatorASP
{
public class CalculatorMiddleware
{
private readonly RequestDelegate _next;
public CalculatorMiddleware(RequestDelegate next) => _next = next;
public async Task InvokeAsync(HttpContext context)
{
var value = context.Request.Query["value"];
var calclulator = new Calculator.Calculator();
var ans = calclulator.Calc(value);
await context.Response.WriteAsync(ans.ToString());
await _next.Invoke(context);
}
}
}
26 changes: 26 additions & 0 deletions CalculatorASP/CalculatorASP/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace CalculatorASP
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
27 changes: 27 additions & 0 deletions CalculatorASP/CalculatorASP/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:51963",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"CalculatorASP": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
25 changes: 25 additions & 0 deletions CalculatorASP/CalculatorASP/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace CalculatorASP
{

public class Startup
{
public Startup()
{

}
public void Configure(IApplicationBuilder app)
{
app.UseMiddleware<CalculatorMiddleware>();
}
}
}
9 changes: 9 additions & 0 deletions CalculatorASP/CalculatorASP/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
10 changes: 10 additions & 0 deletions CalculatorASP/CalculatorASP/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
11 changes: 11 additions & 0 deletions CalculatorASP/ClassLibrary/ClassLibrary.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Library.fs" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions CalculatorASP/ClassLibrary/Library.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace ClassLibrary

open System.Net.Http
open System

module Request =
let GiveRequest expression = async{

let client = new HttpClient()
let! response = client.GetAsync("http://localhost:51963?value=" + expression) |> Async.AwaitTask
let! content = response.Content.ReadAsStringAsync() |> Async.AwaitTask

content
}

let output expression =
let result = GiveRequest expression
result
12 changes: 12 additions & 0 deletions CalculatorASP/ExpressionTree/ExpressionTree.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0-rc.2.20475.5" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions CalculatorASP/ExpressionTree/IParseToTree.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Linq.Expressions;

namespace ExpressionTree
{
public interface IParseToTree
{
public Expression ParsingExpression(string exp);
}
}
Loading