Learn_CSS
Changes
.gitignore 7(+6 -1)
DLL/Tools.SingletonTool.dll 0(+0 -0)
DLL/Tools.SingletonTool.pdb 0(+0 -0)
Learn_CSS/Learn_CSS.APP.Web/Global.asax.cs 56(+56 -0)
Learn_CSS/Learn_CSS.APP.Web/Learn_CSS.APP.Web.csproj 112(+59 -53)
Learn_CSS/Learn_CSS.APP.Web/Web.config 56(+30 -26)
Learn_CSS/Learn_CSS.sln 14(+14 -0)
Learn_CSS/Learn_CSS.Test.Unit/app.config 19(+19 -0)
Details
.gitignore 7(+6 -1)
diff --git a/.gitignore b/.gitignore
index ada6cae..e41aeb9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,9 @@ Learn_CSS/Learn_CSS.APP.Web/Scripts/*
!Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/
Learn_CSS/Learn_CSS.APP.Web/Content/*
-!Learn_CSS/Learn_CSS.APP.Web/Content/Site/
\ No newline at end of file
+!Learn_CSS/Learn_CSS.APP.Web/Content/Site/
+
+
+
+Learn_CSS/Learn_CSS.Test.Unit/bin/
+Learn_CSS/Learn_CSS.Test.Unit/obj/
DLL/Tools.SingletonTool.dll 0(+0 -0)
diff --git a/DLL/Tools.SingletonTool.dll b/DLL/Tools.SingletonTool.dll
new file mode 100644
index 0000000..a4983fb
Binary files /dev/null and b/DLL/Tools.SingletonTool.dll differ
DLL/Tools.SingletonTool.pdb 0(+0 -0)
diff --git a/DLL/Tools.SingletonTool.pdb b/DLL/Tools.SingletonTool.pdb
new file mode 100644
index 0000000..28de211
Binary files /dev/null and b/DLL/Tools.SingletonTool.pdb differ
diff --git a/Learn_CSS/Learn_CSS.APP.Web/App_Data/Task 0.txt b/Learn_CSS/Learn_CSS.APP.Web/App_Data/Task 0.txt
new file mode 100644
index 0000000..0a80abb
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/App_Data/Task 0.txt
@@ -0,0 +1,40 @@
+|HTML_Text
+<p>
+ Set row color:<br />
+ Row1 - RED<br />
+ Row2 - GREEN<br />
+ Row3 - BLUE<br />
+</p>
+|HTML_Template
+<p id="Row1" class="Row1">Row1</p>
+<p id="Row2" class="Row2">Row2</p>
+<p id="Row3" class="Row3">Row3</p>
+|CSS_Template
+/*[placeholder] Enter your css:*/
+
+ .Row1 {
+ color: red
+ }
+
+ .Row2 {
+ color: green
+ }
+
+ .Row3 {
+ color: blue
+ }
+|JSON_Result
+{
+ Row1:
+ {
+ color: "rgb(255, 0, 0)"
+ },
+ Row2:
+ {
+ color: "rgb(0, 128, 0)"
+ },
+ Row3:
+ {
+ color: "rgb(0, 0, 255)"
+ }
+}
diff --git a/Learn_CSS/Learn_CSS.APP.Web/App_Data/Task 1.txt b/Learn_CSS/Learn_CSS.APP.Web/App_Data/Task 1.txt
new file mode 100644
index 0000000..94399ab
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/App_Data/Task 1.txt
@@ -0,0 +1,22 @@
+|HTML_Text
+<p>
+ Установите линейный градиентный фон для элемента div, <br />
+ двигаясь сверху вниз, переходя от белого (white) к чёрному (black).<br />
+</p>
+|HTML_Template
+<div class="elem1">
+ <br />
+ <br />
+ <br />
+</div>
+|CSS_Template
+/*[placeholder] Enter your css:*/
+.elem1 {
+ background-image: linear-gradient(white, black);
+ }
+|JSON_Result
+{
+ "elem1": {
+ "background-image": "linear-gradient(rgb(255, 255, 255), rgb(0, 0, 0))"
+ }
+}
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Controllers/ApiTaskController.cs b/Learn_CSS/Learn_CSS.APP.Web/Controllers/ApiTaskController.cs
new file mode 100644
index 0000000..7ef273a
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Controllers/ApiTaskController.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+
+using Newtonsoft.Json.Linq;
+
+using Tools.SingletonTool.Manager;
+
+using Learn_CSS.APP.Web.Models.Entities;
+using Learn_CSS.APP.Web.Models.ViewEntity;
+using Learn_CSS.APP.Web.Models.Services;
+
+namespace Learn_CSS.APP.Web.Controllers
+{
+ public class ApiTaskController : Controller
+ {
+ private readonly JsonIncludeService jsonIncludeService
+ = new JsonIncludeService();
+
+ private readonly Storage Storage
+ = new SignlethonWithParamsManager<Storage, StorageParams>().Get();
+
+ private readonly TaskService taskService
+ = new TaskService(new JsonIncludeService());
+
+
+ [HttpGet]
+ public JsonResult Count()
+ {
+ return Json(Storage.data.Count, JsonRequestBehavior.AllowGet);
+ }
+
+
+ [HttpPost]
+ public JsonResult GetTask(int ID)
+ {
+ var task = Storage.data[ID];
+
+ return Json(new { HTML_Text = task.HTML_Text, } task, JsonRequestBehavior.AllowGet);
+ }
+
+
+
+ [HttpPost]
+ public JsonResult Validate(ValidateEntity entity)
+ {
+ var task = Storage.data[entity.ID];
+
+ var result = taskService.Validate(task, entity);
+
+ return Json(result);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Controllers/AppController.cs b/Learn_CSS/Learn_CSS.APP.Web/Controllers/AppController.cs
index d6947dd..dd3e742 100644
--- a/Learn_CSS/Learn_CSS.APP.Web/Controllers/AppController.cs
+++ b/Learn_CSS/Learn_CSS.APP.Web/Controllers/AppController.cs
@@ -6,16 +6,32 @@ using System.Web.Mvc;
using System.Web.Routing;
using System.Web.SessionState;
+using Newtonsoft.Json.Linq;
+
+using Learn_CSS.APP.Web.Models.Services;
+
namespace Learn_CSS.APP.Web.Controllers
{
public class AppController : Controller
{
+ private readonly JsonIncludeService jsonIncludeService
+ = new JsonIncludeService();
+
+
// GET: App
public ActionResult Index()
{
return View();
}
+
+ [HttpPost]
+ public JsonResult Validate_CSS(JObject model)
+ {
+ var result = jsonIncludeService.Include(model, model);
+
+ return Json(result);
+ }
}
}
\ No newline at end of file
Learn_CSS/Learn_CSS.APP.Web/Global.asax.cs 56(+56 -0)
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Global.asax.cs b/Learn_CSS/Learn_CSS.APP.Web/Global.asax.cs
index d968c2b..5cdcf62 100644
--- a/Learn_CSS/Learn_CSS.APP.Web/Global.asax.cs
+++ b/Learn_CSS/Learn_CSS.APP.Web/Global.asax.cs
@@ -6,16 +6,72 @@ using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
+using System.IO;
+
+using Newtonsoft.Json.Linq;
+
+using Tools.SingletonTool.Manager;
+
+using Learn_CSS.APP.Web.Models.Entities;
+using Learn_CSS.APP.Web.Models.ViewEntity;
+using Learn_CSS.APP.Web.Models.ModelBinders;
+using Learn_CSS.APP.Web.Models.Services;
+
namespace Learn_CSS.APP.Web
{
public class MvcApplication : System.Web.HttpApplication
{
+ static readonly string TaskDirectory = "Tasks";
+
+ public string GetPath_App_Data => Server.MapPath("~/App_Data");
+
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
+
+
+
+
+ RegisterModelBinders();
+ RegisterTaskStorage();
+
}
+
+ private void RegisterModelBinders()
+ {
+ ModelBinders.Binders.Add(typeof(JObject), new JsonModelBinder());
+ ModelBinders.Binders.Add(typeof(ValidateEntity), new ValidateEntityBinder());
+ }
+
+ private void RegisterTaskStorage()
+ {
+ var stor =
+ new SignlethonWithParamsManager<Storage, StorageParams>(new StorageParams()
+ {
+ Directory = Server.MapPath("~/App_Data"),
+ TaskSerializerService = new TaskSerializerService('|')
+ }).Get();
+
+ stor.Load();
+
+ if (stor.data.Count == 0)
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ stor.data.Add(new TaskEntity()
+ {
+ HTML_Text = "Text " + i,
+ HTML_Template = "Template " + i,
+ JSON_Result = "Result " + i
+ });
+ }
+ }
+
+ stor.Save();
+ }
+
}
}
Learn_CSS/Learn_CSS.APP.Web/Learn_CSS.APP.Web.csproj 112(+59 -53)
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Learn_CSS.APP.Web.csproj b/Learn_CSS/Learn_CSS.APP.Web/Learn_CSS.APP.Web.csproj
index 204b2b2..f7cba6f 100644
--- a/Learn_CSS/Learn_CSS.APP.Web/Learn_CSS.APP.Web.csproj
+++ b/Learn_CSS/Learn_CSS.APP.Web/Learn_CSS.APP.Web.csproj
@@ -45,7 +45,19 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
+ <HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
+ </Reference>
<Reference Include="Microsoft.CSharp" />
+ <Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
+ </Reference>
+ <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
@@ -55,78 +67,71 @@
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Web" />
- <Reference Include="System.Web.Extensions" />
- <Reference Include="System.Web.Abstractions" />
- <Reference Include="System.Web.Routing" />
- <Reference Include="System.Xml" />
- <Reference Include="System.Configuration" />
- <Reference Include="System.Web.Services" />
- <Reference Include="System.EnterpriseServices" />
- <Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <Private>True</Private>
- <HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
- </Reference>
- <Reference Include="System.Net.Http">
- </Reference>
- <Reference Include="System.Net.Http.WebRequest">
- </Reference>
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
- <Reference Include="System.Web.Optimization">
+ <Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
- <Reference Include="Newtonsoft.Json">
- <HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Web.Extensions" />
+ <Reference Include="System.Web.Abstractions" />
+ <Reference Include="System.Web.Routing" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Web.Services" />
+ <Reference Include="System.EnterpriseServices" />
+ <Reference Include="System.Net.Http">
</Reference>
- <Reference Include="WebGrease">
- <Private>True</Private>
- <HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
+ <Reference Include="System.Net.Http.WebRequest">
</Reference>
- <Reference Include="Antlr3.Runtime">
- <Private>True</Private>
- <HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
+ <Reference Include="Tools.SingletonTool, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\DLL\Tools.SingletonTool.dll</HintPath>
</Reference>
- </ItemGroup>
- <ItemGroup>
- <Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
- <HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
+ <Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
+ <Compile Include="Controllers\ApiTaskController.cs" />
<Compile Include="Controllers\AppController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
+ <Compile Include="Models\Entities\Storage.cs" />
+ <Compile Include="Models\Entities\TaskEntity.cs" />
+ <Compile Include="Models\ModelBinders\JsonModelBinder.cs" />
+ <Compile Include="Models\ModelBinders\ValidateEntityBinder.cs" />
+ <Compile Include="Models\Services\JsonIncludeService.cs" />
+ <Compile Include="Models\Services\TaskSerializerService.cs" />
+ <Compile Include="Models\Services\TaskService.cs" />
+ <Compile Include="Models\Tools\ListExtensions.cs" />
+ <Compile Include="Models\ViewEntity\ValidateEntity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
+ <Content Include="App_Data\Task 0.txt" />
+ <Content Include="App_Data\Task 1.txt" />
<Content Include="Content\bootstrap-theme.css" />
<Content Include="Content\bootstrap-theme.min.css" />
<Content Include="Content\bootstrap.css" />
@@ -135,10 +140,19 @@
<Content Include="fonts\glyphicons-halflings-regular.svg" />
<Content Include="Global.asax" />
<Content Include="Content\Site\Site.css" />
- <Content Include="Scripts\bootstrap.js" />
- <Content Include="Scripts\bootstrap.min.js" />
+ <Content Include="fonts\glyphicons-halflings-regular.woff2" />
+ <Content Include="fonts\glyphicons-halflings-regular.woff" />
+ <Content Include="fonts\glyphicons-halflings-regular.ttf" />
+ <Content Include="fonts\glyphicons-halflings-regular.eot" />
+ <Content Include="Content\bootstrap.min.css.map" />
+ <Content Include="Content\bootstrap.css.map" />
+ <Content Include="Content\bootstrap-theme.min.css.map" />
+ <Content Include="Content\bootstrap-theme.css.map" />
+ <None Include="packages.config" />
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
<None Include="Scripts\jquery-3.3.1.intellisense.js" />
+ <Content Include="Scripts\bootstrap.js" />
+ <Content Include="Scripts\bootstrap.min.js" />
<Content Include="Scripts\jquery-3.3.1.js" />
<Content Include="Scripts\jquery-3.3.1.min.js" />
<Content Include="Scripts\jquery-3.3.1.slim.js" />
@@ -149,6 +163,10 @@
<Content Include="Scripts\jquery.validate.unobtrusive.js" />
<Content Include="Scripts\jquery.validate.unobtrusive.min.js" />
<Content Include="Scripts\modernizr-2.8.3.js" />
+ <Content Include="Scripts\Site\ApiProvider.js" />
+ <Content Include="Scripts\Site\AppPage.js" />
+ <Content Include="Scripts\Site\StringExtensions.js" />
+ <Content Include="Scripts\Site\TaskMenuControl.js" />
<Content Include="Scripts\Site\SiteScript.js" />
<Content Include="Web.config" />
<Content Include="Web.Debug.config">
@@ -162,24 +180,12 @@
<Content Include="Views\Shared\Error.cshtml" />
<Content Include="Views\Shared\_Layout.cshtml" />
<Content Include="Views\App\Index.cshtml" />
- </ItemGroup>
- <ItemGroup>
- <Folder Include="App_Data\" />
- <Folder Include="Models\" />
- </ItemGroup>
- <ItemGroup>
- <Content Include="fonts\glyphicons-halflings-regular.woff2" />
- <Content Include="fonts\glyphicons-halflings-regular.woff" />
- <Content Include="fonts\glyphicons-halflings-regular.ttf" />
- <Content Include="fonts\glyphicons-halflings-regular.eot" />
- <Content Include="Content\bootstrap.min.css.map" />
- <Content Include="Content\bootstrap.css.map" />
- <Content Include="Content\bootstrap-theme.min.css.map" />
- <Content Include="Content\bootstrap-theme.css.map" />
- <None Include="packages.config" />
<Content Include="Scripts\jquery-3.3.1.slim.min.map" />
<Content Include="Scripts\jquery-3.3.1.min.map" />
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Views\ApiTask\" />
+ </ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Models/Entities/Storage.cs b/Learn_CSS/Learn_CSS.APP.Web/Models/Entities/Storage.cs
new file mode 100644
index 0000000..4884027
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Models/Entities/Storage.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+using System.IO;
+using System.Text;
+
+using Tools.SingletonTool.Base;
+
+using Learn_CSS.APP.Web.Models.Services;
+
+namespace Learn_CSS.APP.Web.Models.Entities
+{
+ public class StorageParams
+ {
+ public string Directory { set; get; }
+
+ public TaskSerializerService TaskSerializerService { set; get; }
+ }
+
+ public class Storage : ISignlethonWithParams<StorageParams>
+ {
+ StorageParams param;
+
+
+ public List<TaskEntity> data { private set; get; }
+ = new List<TaskEntity>();
+
+ public void SetParams(StorageParams param)
+ {
+ this.param = param;
+ }
+
+
+ public void Load()
+ {
+ DirectoryInfo dir = new DirectoryInfo(param.Directory);
+
+ if (!dir.Exists)
+ {
+ dir.Create();
+ return;
+ }
+
+ data.Clear();
+
+ var files = dir.GetFiles();
+ foreach (var elem in files)
+ {
+ data.Add(param.TaskSerializerService.Load(elem.FullName));
+ }
+ }
+ public void Save()
+ {
+ DirectoryInfo dir = new DirectoryInfo(param.Directory);
+
+ if (!dir.Exists)
+ {
+ dir.Delete(true);
+ }
+
+ dir.Create();
+
+ for (int i = 0; i< data.Count; i++)
+ {
+ var elem = data[i];
+ param.TaskSerializerService.Save(elem, Path.Combine(dir.FullName, "Task " + i + ".txt"));
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Models/Entities/TaskEntity.cs b/Learn_CSS/Learn_CSS.APP.Web/Models/Entities/TaskEntity.cs
new file mode 100644
index 0000000..1cb4bed
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Models/Entities/TaskEntity.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Learn_CSS.APP.Web.Models.Entities
+{
+ public class TaskEntity
+ {
+ public string HTML_Text { set; get; }
+ public string HTML_Template { set; get; }
+ public string CSS_Template { set; get; }
+ public string JSON_Result { set; get; }
+ }
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Models/ModelBinders/JsonModelBinder.cs b/Learn_CSS/Learn_CSS.APP.Web/Models/ModelBinders/JsonModelBinder.cs
new file mode 100644
index 0000000..2aa8e44
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Models/ModelBinders/JsonModelBinder.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+using System.Text;
+using System.IO;
+using System.Web.Mvc;
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+namespace Learn_CSS.APP.Web.Models.ModelBinders
+{
+ public class JsonModelBinder : IModelBinder
+ {
+ public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
+ {
+ return Bind(controllerContext, bindingContext);
+ }
+
+ private JObject Bind(ControllerContext controllerContext, ModelBindingContext bindingContext)
+ {
+ var request = controllerContext.RequestContext.HttpContext.Request;
+ var stream = request.InputStream;
+ stream.Position = 0;
+
+ string jsonText = "";
+
+ StringBuilder stringBuilder = new StringBuilder();
+ using (StreamReader reader = new StreamReader(stream))
+ {
+ jsonText = reader.ReadToEnd();
+ }
+
+ return (JObject)JsonConvert.DeserializeObject(jsonText);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Models/ModelBinders/ValidateEntityBinder.cs b/Learn_CSS/Learn_CSS.APP.Web/Models/ModelBinders/ValidateEntityBinder.cs
new file mode 100644
index 0000000..3268346
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Models/ModelBinders/ValidateEntityBinder.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+using System.Text;
+using System.IO;
+using System.Web.Mvc;
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+using Learn_CSS.APP.Web.Models.ViewEntity;
+
+namespace Learn_CSS.APP.Web.Models.ModelBinders
+{
+ public class ValidateEntityBinder : IModelBinder
+ {
+ public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
+ {
+ return Bind(controllerContext, bindingContext);
+ }
+
+ private ValidateEntity Bind(ControllerContext controllerContext, ModelBindingContext bindingContext)
+ {
+ var request = controllerContext.RequestContext.HttpContext.Request;
+ var stream = request.InputStream;
+ stream.Position = 0;
+
+ string jsonText = "";
+
+ StringBuilder stringBuilder = new StringBuilder();
+ using (StreamReader reader = new StreamReader(stream))
+ {
+ jsonText = reader.ReadToEnd();
+ }
+
+
+ var json = (JObject)JsonConvert.DeserializeObject(jsonText);
+
+
+ return new ValidateEntity()
+ {
+ ID = json["ID"].Value<int>(),
+ Elements = json["Elements"]
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Models/Services/JsonIncludeService.cs b/Learn_CSS/Learn_CSS.APP.Web/Models/Services/JsonIncludeService.cs
new file mode 100644
index 0000000..f23aad7
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Models/Services/JsonIncludeService.cs
@@ -0,0 +1,157 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+using Newtonsoft.Json.Linq;
+
+using Learn_CSS.APP.Web.Models.Tools;
+
+namespace Learn_CSS.APP.Web.Models.Services
+{
+ public class JsonIncludeService
+ {
+
+ /// <summary>
+ /// Содержит ли main в себе subobject
+ /// </summary>
+ /// <param name="main"></param>
+ /// <param name="subobject"></param>
+ /// <returns></returns>
+ public bool Include(JToken main, JToken subobject)
+ {
+ return RecursivInclude(main, subobject);
+ }
+
+
+ protected bool RecursivInclude(JToken main, JToken sub)
+ {
+ //Если у элементов разные типы то
+ if (main.Type != sub.Type)
+ return false;
+
+ if (main.Type == JTokenType.Property)
+ throw new Exception("Error type");
+
+
+ if (main is JValue)
+ {
+ return Include_Values((JValue)main, (JValue)sub, RecursivInclude);
+ }
+ if (main is JObject)
+ {
+ return Include_Object((JObject)main, (JObject)sub, RecursivInclude);
+ }
+ if (main is JArray)
+ {
+ return Include_Array_IgnorePosition((JArray)main, (JArray)sub, RecursivInclude);
+ }
+
+ throw new Exception("Unknow type");
+ }
+
+
+
+ #region Include
+
+ /// <summary>
+ /// Сравнивает элементы значимого типа
+ /// </summary>
+ protected bool Include_Values(JValue main, JValue sub, Func<JToken, JToken, bool> IncludeFunction)
+ {
+ return main.Value<string>() == sub.Value<string>();
+ }
+
+
+ /// <summary>
+ /// Сравнивает объекты по ключам
+ /// </summary>
+ protected bool Include_Object(JObject main, JObject sub, Func<JToken, JToken, bool> IncludeFunction)
+ {
+ //Получить все ключи
+ var main_childrens_properties = main.Properties().ToList();
+ var sub_childrens_properties = sub.Properties().ToList();
+
+ if (sub_childrens_properties.Count > main_childrens_properties.Count)
+ {
+ return false;
+ }
+
+ foreach (var sub_elem in sub_childrens_properties)
+ {
+ var main_elem = main_childrens_properties
+ .FirstOrDefault(e => e.Name == sub_elem.Name);
+
+ //В основном объекте нет ключа
+ if (main_elem == null)
+ {
+ return false;
+ }
+
+ if (!IncludeFunction(main_elem.First(), sub_elem.First()))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+ /// <summary>
+ /// Сравнение вхождения по массиву, со строгим учетом позиции main[i] = sub[i]
+ /// </summary>
+ protected bool Include_Array_WithPosition(JArray main, JArray sub, Func<JToken, JToken, bool> IncludeFunction)
+ {
+ var main_children = main.Children().ToList();
+ var sub_children = sub.Children().ToList();
+
+ if (sub_children.Count > main_children.Count)
+ {
+ return false;
+ }
+
+ for (int i = 0; i < sub_children.Count(); i++)
+ {
+ if (!IncludeFunction(main_children[i], sub_children[i]))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /// <summary>
+ /// Сравнение вхождение по массиву, без строго учета позиции main.contains(sub[i])
+ /// </summary>
+ protected bool Include_Array_IgnorePosition(JArray main, JArray sub, Func<JToken, JToken, bool> IncludeFunction)
+ {
+ var main_children = main.Children().ToList();
+ var sub_children = sub.Children().ToList();
+
+ if (sub_children.Count > main_children.Count)
+ {
+ return false;
+ }
+
+ while (sub_children.Count() > 0)
+ {
+ var find_main = main_children.FirstOrDefaultWithPosition(e => IncludeFunction(e, sub_children[0]));
+
+ if (find_main == null)
+ {
+ return false;
+ }
+
+ sub_children.RemoveAt(0);
+ main_children.RemoveAt(find_main.Index);
+ }
+
+ return true;
+ }
+
+ #endregion
+
+ }
+}
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Models/Services/TaskSerializerService.cs b/Learn_CSS/Learn_CSS.APP.Web/Models/Services/TaskSerializerService.cs
new file mode 100644
index 0000000..293b7ff
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Models/Services/TaskSerializerService.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+using System.IO;
+using System.Text;
+
+using Learn_CSS.APP.Web.Models.Entities;
+
+namespace Learn_CSS.APP.Web.Models.Services
+{
+ public class TaskSerializerService
+ {
+ readonly char SplitChar;
+
+ public TaskSerializerService(char SplitChar)
+ {
+ this.SplitChar = SplitChar;
+ }
+
+ public TaskEntity Load(string file)
+ {
+ TaskEntity res = new TaskEntity();
+
+ var type = typeof(TaskEntity);
+ var properties = type.GetProperties()
+ .Where(e => e.CanWrite)
+ .ToList();
+
+ string text;
+
+ using (FileStream stream = new FileStream(file, FileMode.Open))
+ {
+ using (StreamReader reader = new StreamReader(stream))
+ {
+ text = reader.ReadToEnd();
+ }
+ }
+
+ var data = text.Split(SplitChar)
+ .Where(e => !string
+ .IsNullOrEmpty(e)).ToList();
+
+ foreach (var elem in data)
+ {
+ using (StringReader reader = new StringReader(elem))
+ {
+ var elem_key = reader.ReadLine().Trim();
+ var elem_text = reader.ReadToEnd().Trim();
+
+ var property = properties.FirstOrDefault(e => e.Name == elem_key);
+ if (property == null)
+ {
+ continue;
+ }
+
+ property.SetValue(res, elem_text);
+ }
+ }
+
+ return res;
+ }
+ public void Save(TaskEntity entity, string file)
+ {
+ var type = typeof(TaskEntity);
+ var properties = type.GetProperties()
+ .Where(e => e.CanWrite)
+ .ToList();
+
+
+ StringBuilder text = new StringBuilder();
+ foreach (var elem in properties)
+ {
+ text.Append(SplitChar + elem.Name + "\n" + elem.GetValue(entity) + "\n");
+ }
+
+ using (FileStream stream = new FileStream(file, FileMode.Create))
+ {
+ using (StreamWriter writer = new StreamWriter(stream))
+ {
+ writer.Write(text.ToString());
+ }
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Models/Services/TaskService.cs b/Learn_CSS/Learn_CSS.APP.Web/Models/Services/TaskService.cs
new file mode 100644
index 0000000..f7eb0dd
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Models/Services/TaskService.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+using Learn_CSS.APP.Web.Models.Entities;
+using Learn_CSS.APP.Web.Models.ViewEntity;
+using Learn_CSS.APP.Web.Models.Services;
+
+namespace Learn_CSS.APP.Web.Models.Services
+{
+ public class TaskService
+ {
+ private readonly JsonIncludeService jsonIncludeService;
+
+ public TaskService(JsonIncludeService jsonIncludeService)
+ {
+ this.jsonIncludeService = jsonIncludeService;
+ }
+
+ public bool Validate(TaskEntity task, ValidateEntity entity)
+ {
+ var sub_style = (JObject)JsonConvert.DeserializeObject(task.JSON_Result);
+ var sub_properties = sub_style.Properties().ToList();
+
+ var main_styles = (JArray)entity.Elements;
+
+ for (int i = 0; i < sub_properties.Count; i++)
+ {
+ var sub_elem = sub_properties[i].First();
+ var main_style = main_styles.Children().ToList()[i];
+
+
+ if (!jsonIncludeService.Include(main_style, sub_elem))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+ //public bool ValidateEntity()
+ //{
+
+ //}
+ }
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Models/Tools/ListExtensions.cs b/Learn_CSS/Learn_CSS.APP.Web/Models/Tools/ListExtensions.cs
new file mode 100644
index 0000000..b19f6da
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Models/Tools/ListExtensions.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Learn_CSS.APP.Web.Models.Tools
+{
+ public class ElementWithPositionEntity<T>
+ {
+ public T Element { set; get; }
+ public int Index { set; get; }
+ }
+
+
+ public static class ListExtensions
+ {
+
+ /// <summary>
+ /// Поиск элемента с сохранением позиции
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="list"></param>
+ /// <param name="predicate"></param>
+ /// <returns>Сущность обертку или null</returns>
+ public static ElementWithPositionEntity<T> FirstOrDefaultWithPosition<T>(this IList<T> list, Func<T, bool> predicate)
+ {
+ for (int i = 0; i < list.Count; i++)
+ {
+ var elem = list[i];
+
+ if (predicate(elem))
+ {
+ return new ElementWithPositionEntity<T>()
+ {
+ Element = elem,
+ Index = i
+ };
+ }
+ }
+
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Models/ViewEntity/ValidateEntity.cs b/Learn_CSS/Learn_CSS.APP.Web/Models/ViewEntity/ValidateEntity.cs
new file mode 100644
index 0000000..af6923f
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Models/ViewEntity/ValidateEntity.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+using Newtonsoft.Json.Linq;
+
+namespace Learn_CSS.APP.Web.Models.ViewEntity
+{
+ public class ValidateEntity
+ {
+ public int ID { set; get; }
+ public JToken Elements { set; get; }
+ }
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/packages.config b/Learn_CSS/Learn_CSS.APP.Web/packages.config
index 904dd88..1579155 100644
--- a/Learn_CSS/Learn_CSS.APP.Web/packages.config
+++ b/Learn_CSS/Learn_CSS.APP.Web/packages.config
@@ -16,6 +16,6 @@
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.11" targetFramework="net472" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net472" />
<package id="Modernizr" version="2.8.3" targetFramework="net472" />
- <package id="Newtonsoft.Json" version="11.0.1" targetFramework="net472" />
+ <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="WebGrease" version="1.6.0" targetFramework="net472" />
</packages>
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Properties/PublishProfiles/FolderProfile.pubxml.user b/Learn_CSS/Learn_CSS.APP.Web/Properties/PublishProfiles/FolderProfile.pubxml.user
index fef4278..7360f48 100644
--- a/Learn_CSS/Learn_CSS.APP.Web/Properties/PublishProfiles/FolderProfile.pubxml.user
+++ b/Learn_CSS/Learn_CSS.APP.Web/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -6,9 +6,15 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TimeStampOfAssociatedLegacyPublishXmlFile />
- <_PublishTargetUrl>C:\Data\Projects\Learn_CSS\Learn_CSS.APP.Web\bin\Release\Publish</_PublishTargetUrl>
+ <_PublishTargetUrl>C:\Data\Projects\Learn_CSS\Learn_CSS\Learn_CSS.APP.Web\bin\Release\Publish</_PublishTargetUrl>
</PropertyGroup>
<ItemGroup>
+ <File Include="App_Data/Task 0.txt">
+ <publishTime>12/24/2019 00:01:10</publishTime>
+ </File>
+ <File Include="App_Data/Task 1.txt">
+ <publishTime>12/24/2019 00:01:10</publishTime>
+ </File>
<File Include="bin/Antlr3.Runtime.dll">
<publishTime>09/10/2013 16:29:20</publishTime>
</File>
@@ -16,16 +22,16 @@
<publishTime>09/10/2013 16:29:20</publishTime>
</File>
<File Include="bin/App_global.asax.compiled">
- <publishTime>12/10/2019 21:40:58</publishTime>
+ <publishTime>12/24/2019 00:01:57</publishTime>
</File>
<File Include="bin/App_global.asax.dll">
- <publishTime>12/10/2019 21:40:58</publishTime>
+ <publishTime>12/24/2019 00:01:57</publishTime>
</File>
<File Include="bin/Learn_CSS.APP.Web.dll">
- <publishTime>12/10/2019 21:40:55</publishTime>
+ <publishTime>12/24/2019 00:01:53</publishTime>
</File>
<File Include="bin/Learn_CSS.APP.Web.pdb">
- <publishTime>12/10/2019 21:40:55</publishTime>
+ <publishTime>12/24/2019 00:01:53</publishTime>
</File>
<File Include="bin/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll">
<publishTime>05/24/2018 13:38:22</publishTime>
@@ -34,7 +40,7 @@
<publishTime>07/25/2012 11:48:56</publishTime>
</File>
<File Include="bin/Newtonsoft.Json.dll">
- <publishTime>02/18/2018 09:44:54</publishTime>
+ <publishTime>11/09/2019 00:56:44</publishTime>
</File>
<File Include="bin/roslyn/csc.exe">
<publishTime>05/24/2018 13:38:22</publishTime>
@@ -216,101 +222,125 @@
<File Include="bin/System.Web.WebPages.Razor.dll">
<publishTime>11/28/2018 13:04:24</publishTime>
</File>
+ <File Include="bin/Tools.SingletonTool.dll">
+ <publishTime>12/22/2019 23:00:16</publishTime>
+ </File>
+ <File Include="bin/Tools.SingletonTool.pdb">
+ <publishTime>12/22/2019 23:00:16</publishTime>
+ </File>
<File Include="bin/WebGrease.dll">
<publishTime>01/23/2014 13:57:34</publishTime>
</File>
<File Include="Content/bootstrap-theme.css">
- <publishTime>12/10/2019 20:09:49</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Content/bootstrap-theme.css.map">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Content/bootstrap-theme.min.css">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Content/bootstrap-theme.min.css.map">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Content/bootstrap.css">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Content/bootstrap.css.map">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Content/bootstrap.min.css">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Content/bootstrap.min.css.map">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Content/Site.css">
<publishTime>12/10/2019 20:09:46</publishTime>
</File>
+ <File Include="Content/Site/Site.css">
+ <publishTime>12/10/2019 20:09:46</publishTime>
+ </File>
<File Include="favicon.ico">
<publishTime>12/10/2019 20:09:46</publishTime>
</File>
<File Include="fonts/glyphicons-halflings-regular.eot">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="fonts/glyphicons-halflings-regular.svg">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="fonts/glyphicons-halflings-regular.ttf">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="fonts/glyphicons-halflings-regular.woff">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="fonts/glyphicons-halflings-regular.woff2">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="PrecompiledApp.config">
- <publishTime>12/10/2019 21:40:55</publishTime>
+ <publishTime>12/24/2019 00:01:54</publishTime>
</File>
<File Include="Scripts/bootstrap.js">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Scripts/bootstrap.min.js">
- <publishTime>12/10/2019 20:09:48</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Scripts/jquery-3.3.1.js">
- <publishTime>12/10/2019 20:09:49</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Scripts/jquery-3.3.1.min.js">
- <publishTime>12/10/2019 20:09:49</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Scripts/jquery-3.3.1.min.map">
- <publishTime>12/10/2019 20:09:49</publishTime>
+ <publishTime>12/21/2019 19:19:11</publishTime>
</File>
<File Include="Scripts/jquery-3.3.1.slim.js">
- <publishTime>12/10/2019 20:09:49</publishTime>
+ <publishTime>12/21/2019 19:19:10</publishTime>
</File>
<File Include="Scripts/jquery-3.3.1.slim.min.js">
- <publishTime>12/10/2019 20:09:49</publishTime>
+ <publishTime>12/21/2019 19:19:10</publishTime>
</File>
<File Include="Scripts/jquery-3.3.1.slim.min.map">
- <publishTime>12/10/2019 20:09:49</publishTime>
+ <publishTime>12/21/2019 19:19:10</publishTime>
</File>
<File Include="Scripts/jquery.validate.js">
- <publishTime>12/10/2019 20:09:51</publishTime>
+ <publishTime>12/21/2019 19:19:12</publishTime>
</File>
<File Include="Scripts/jquery.validate.min.js">
- <publishTime>12/10/2019 20:09:51</publishTime>
+ <publishTime>12/21/2019 19:19:12</publishTime>
</File>
<File Include="Scripts/jquery.validate.unobtrusive.js">
- <publishTime>12/10/2019 20:09:51</publishTime>
+ <publishTime>12/21/2019 19:19:12</publishTime>
</File>
<File Include="Scripts/jquery.validate.unobtrusive.min.js">
- <publishTime>12/10/2019 20:09:51</publishTime>
+ <publishTime>12/21/2019 19:19:12</publishTime>
</File>
<File Include="Scripts/modernizr-2.8.3.js">
- <publishTime>12/10/2019 20:09:50</publishTime>
+ <publishTime>12/21/2019 19:19:13</publishTime>
+ </File>
+ <File Include="Scripts/Site/ApiProvider.js">
+ <publishTime>12/23/2019 22:56:10</publishTime>
+ </File>
+ <File Include="Scripts/Site/AppPage.js">
+ <publishTime>12/23/2019 23:59:58</publishTime>
</File>
<File Include="Scripts/Site/JavaScript.js">
<publishTime>12/10/2019 21:38:42</publishTime>
</File>
+ <File Include="Scripts/Site/SiteScript.js">
+ <publishTime>12/23/2019 23:01:24</publishTime>
+ </File>
+ <File Include="Scripts/Site/StringExtensions.js">
+ <publishTime>12/23/2019 23:23:36</publishTime>
+ </File>
+ <File Include="Scripts/Site/TaskMenuControl.js">
+ <publishTime>12/23/2019 23:42:51</publishTime>
+ </File>
<File Include="Views/App/Index.cshtml">
- <publishTime>12/10/2019 21:40:13</publishTime>
+ <publishTime>12/23/2019 23:36:18</publishTime>
</File>
<File Include="Views/Home/About.cshtml">
<publishTime>12/10/2019 20:09:46</publishTime>
@@ -325,16 +355,16 @@
<publishTime>12/10/2019 20:09:46</publishTime>
</File>
<File Include="Views/Shared/_Layout.cshtml">
- <publishTime>12/10/2019 21:40:09</publishTime>
+ <publishTime>12/23/2019 23:33:26</publishTime>
</File>
<File Include="Views/Web.config">
- <publishTime>12/10/2019 20:09:46</publishTime>
+ <publishTime>12/23/2019 02:09:42</publishTime>
</File>
<File Include="Views/_ViewStart.cshtml">
<publishTime>12/10/2019 20:09:46</publishTime>
</File>
<File Include="Web.config">
- <publishTime>12/10/2019 21:40:55</publishTime>
+ <publishTime>12/24/2019 00:01:54</publishTime>
</File>
</ItemGroup>
</Project>
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/ApiProvider.js b/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/ApiProvider.js
new file mode 100644
index 0000000..0fb325f
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/ApiProvider.js
@@ -0,0 +1,76 @@
+
+
+class ApiProvider {
+
+ constructor() {
+ this.URL_Count = "/ApiTask/Count";
+ this.URL_GetTask = "/ApiTask/GetTask";
+ this.URL_Validate = "/ApiTask/Validate";
+
+ this.URL = "/App/Validate_CSS";
+ }
+
+
+
+ async Count() {
+
+ console.log("Api request:" + this.URL_Count);
+
+ let response = await fetch(this.URL_Count,
+ {
+ method: 'GET',
+ headers: {
+ "Content-Type": "application/json"
+ }
+ }
+ );
+ let json = await response.json();
+
+
+ return json;
+ }
+
+ async GetTask(ID) {
+
+ console.log("Api request:" + this.URL_GetTask);
+
+ let response = await fetch(this.URL_GetTask,
+ {
+ method: 'POST',
+ headers: {
+ "Content-Type": "application/json"
+ },
+ body: JSON.stringify(
+ {
+ ID: ID
+ })
+ }
+ );
+ let json = await response.json();
+
+ return json;
+ }
+
+ async Validate(ID, styles) {
+
+ console.log("Api request:" + this.URL_Validate);
+
+ let response = await fetch(this.URL_Validate,
+ {
+ method: 'POST',
+ headers: {
+ "Content-Type": "application/json"
+ },
+ body: JSON.stringify({
+ ID: ID,
+ Elements: styles
+ })
+ }
+ );
+ let json = await response.json();
+
+
+ return json;
+ }
+
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/AppPage.js b/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/AppPage.js
new file mode 100644
index 0000000..e39bdb8
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/AppPage.js
@@ -0,0 +1,93 @@
+class AppPage {
+ constructor() {
+
+ this.TaskNumber = 0;
+
+ this.api = new ApiProvider();
+
+
+
+ this.div_task = document.getElementById('div_Task');
+ this.div_UserView = document.getElementById('View_User');
+ this.text_UserCss = document.getElementById('User_CSS');
+ this.block_style = document.getElementById('style');
+ this.block_result = document.getElementById('Validate');
+
+ this._OnClick_ButtonSet = this._OnClick_ButtonSet.bind(this);
+ this._OnClick_ButtonValidate = this._OnClick_ButtonValidate.bind(this);
+ this._OnClick_ButtonTask = this._OnClick_ButtonTask.bind(this);
+
+ document.getElementById('Button_SetCss').onclick = this._OnClick_ButtonSet;
+ document.getElementById('Button_Validate').onclick = this._OnClick_ButtonValidate;
+
+ this.LoadTask();
+
+ this.taskMenuControl = new TaskMenuControl(this._OnClick_ButtonTask);
+ }
+
+
+ LoadTask() {
+ this.api.GetTask(this.TaskNumber).then(e => {
+
+ this.div_task.innerHTML = e.HTML_Text;
+ this.div_UserView.innerHTML = e.HTML_Template;
+ this.text_UserCss.value = e.CSS_Template;
+
+ });
+ }
+
+
+
+ //Костыльный конвертер
+ ConvertCSS(css) {
+ let res = {};
+
+ for (let i = 0; i < css.length; i++) {
+ let key = css[i];
+ let value = css[key];
+
+ res[key] = value;
+ }
+
+ return res;
+ }
+
+ _OnClick_ButtonTask(ID) {
+ if (this.TaskNumber === ID)
+ {
+ return;
+ }
+
+ this.block_result.value = "";
+ this.TaskNumber = ID;
+ this.LoadTask();
+ }
+
+ _OnClick_ButtonSet() {
+
+ this.block_style.innerHTML = this.text_UserCss.value;
+ }
+
+ _OnClick_ButtonValidate() {
+ let elements = this.div_UserView.children;
+ let elem_styles = [];
+
+ for (let i = 0; i < elements.length; i++) {
+ let elem_style = window.getComputedStyle(elements[i]);
+ elem_styles.push(this.ConvertCSS(elem_style));
+ }
+
+ this.api.Validate(this.TaskNumber, elem_styles)
+ .then(e => {
+
+ if (e) {
+ this.block_result.value = "Решение верно";
+ }
+ else {
+ this.block_result.value = "Решение не верно";
+ }
+
+ });
+ }
+
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/SiteScript.js b/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/SiteScript.js
index 892304b..498843c 100644
--- a/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/SiteScript.js
+++ b/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/SiteScript.js
@@ -1,55 +1,9 @@
-
-
-function SetStyle(element, style) {
- for (const [key, value] of Object.entries(style)) {
- element.style[key] = value;
- }
-}
-
-function Validate(elements, styles){
-
- for (let i = 0; i < elements.length; i++) {
- let elem_style = window.getComputedStyle(elements[i]);
-
- for (const [key, value] of Object.entries(styles[i])) {
- let elem_style_value = elem_style[key];
-
- if (elem_style_value !== value)
- return false
- }
- }
-
- return true;
-}
-
-
-function CSS_IT() {
- document.getElementById("style").innerHTML = document.getElementById("User_CSS").value;
-}
-
-function Click_Validate() {
- let elements = document.getElementById("View_User").children;
- let styles =
- [
- {
- color: "rgb(255, 0, 0)"
- },
- {
- color: "rgb(0, 128, 0)"
- },
- {
- color: "rgb(0, 0, 255)"
- }
- ];
-
- let res = Validate(elements, styles);
- document.getElementById("Validate").value = res;
-}
+var Page;
function ready() {
- document.getElementById("B").onclick = CSS_IT;
- document.getElementById("V").onclick = Click_Validate;
+
+ Page = new AppPage();
}
document.addEventListener("DOMContentLoaded", ready);
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/StringExtensions.js b/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/StringExtensions.js
new file mode 100644
index 0000000..0797bf3
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/StringExtensions.js
@@ -0,0 +1,8 @@
+
+String.prototype.format = function () {
+ var formatted = this;
+ for (var arg in arguments) {
+ formatted = formatted.replace("{" + arg + "}", arguments[arg]);
+ }
+ return formatted;
+};
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/TaskMenuControl.js b/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/TaskMenuControl.js
new file mode 100644
index 0000000..7efc760
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.APP.Web/Scripts/Site/TaskMenuControl.js
@@ -0,0 +1,41 @@
+
+class TaskMenuControl {
+
+ //clickFunction(TaskID)
+ constructor(clickFunction) {
+ this.api = new ApiProvider();
+
+ this.TaskMenu = document.getElementById('TaskMenu');
+ this.ClickFunction = clickFunction;
+
+ this.LoadMenu();
+ }
+
+
+ LoadMenu() {
+
+ let menu_line_template = '<li><a id="{0}" href="#">{1}</a></li>';
+ let button_name_template = 'TaskButton{0}';
+ let button_text_template = 'Task {0}';
+
+ this.api.Count()
+ .then(e =>
+ {
+ let menu_html = "";
+
+ for (let i = 0; i < e; i++) {
+ menu_html += menu_line_template.format(button_name_template.format(i), button_text_template.format(i+1));
+ }
+
+ this.TaskMenu.innerHTML = menu_html;
+
+ for (let i = 0; i < e; i++) {
+ document.getElementById(button_name_template.format(i))
+ .onclick = () => {
+ this.ClickFunction(i);
+ };
+ }
+ });
+ }
+
+}
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Views/App/Index.cshtml b/Learn_CSS/Learn_CSS.APP.Web/Views/App/Index.cshtml
index b4efff6..c74a144 100644
--- a/Learn_CSS/Learn_CSS.APP.Web/Views/App/Index.cshtml
+++ b/Learn_CSS/Learn_CSS.APP.Web/Views/App/Index.cshtml
@@ -3,53 +3,29 @@
ViewBag.Title = "Index";
}
-<script type="text/javascript" src="~/Scripts/Site/SiteScript.js"></script>
+<script type="text/javascript" src="~/Scripts/Site/StringExtensions.js?@DateTime.Now"></script>
+<script type="text/javascript" src="~/Scripts/Site/ApiProvider.js?@DateTime.Now"></script>
+<script type="text/javascript" src="~/Scripts/Site/TaskMenuControl.js?@DateTime.Now"></script>
+<script type="text/javascript" src="~/Scripts/Site/AppPage.js?@DateTime.Now"></script>
+<script type="text/javascript" src="~/Scripts/Site/SiteScript.js?@DateTime.Now"></script>
<h2>Index</h2>
<hr />
-<style id="style">
- /*.Row1 {
- color: red
- }
-
- .Row2 {
- color: green
- }
-
- .Row3 {
- color: blue
- }*/
+<style id="style">
</style>
<div description="Task" class="col-md-3">
<h3>Task:</h3>
- <p>
- Set row color:<br />
- Row1 - RED<br />
- Row2 - GREEN<br />
- Row3 - BLUE<br />
- </p>
+ <div id="div_Task">
+ </div>
</div>
<div description="Input" class="col-md-3">
<h2>CSS</h2>
<textarea id="User_CSS" rows="14" style="width:100%;">
- /*[placeholder] Enter your css:*/
-
- .Row1 {
- color: red
- }
-
- .Row2 {
- color: green
- }
-
- .Row3 {
- color: blue
- }
</textarea>
</div>
@@ -57,16 +33,13 @@
<h2>Render page</h2>
<div id="View_User">
- <p id="Row1" class="Row1">Row1</p>
- <p id="Row2" class="Row2">Row2</p>
- <p id="Row3" class="Row3">Row3</p>
</div>
</div>
<div class="col-md-12">
- <button id="B">css it</button>
- <button id="V">Validate</button>
+ <button id="Button_SetCss">css it</button>
+ <button id="Button_Validate">Validate</button>
<input id="Validate" readonly="readonly" />
</div>
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Views/Shared/_Layout.cshtml b/Learn_CSS/Learn_CSS.APP.Web/Views/Shared/_Layout.cshtml
index 16a5a63..5829699 100644
--- a/Learn_CSS/Learn_CSS.APP.Web/Views/Shared/_Layout.cshtml
+++ b/Learn_CSS/Learn_CSS.APP.Web/Views/Shared/_Layout.cshtml
@@ -9,6 +9,7 @@
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
+
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
@@ -22,15 +23,25 @@
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
@*<li>@Html.ActionLink("Домашняя страница", "Index", "Home")</li>
- <li>@Html.ActionLink("Информация", "About", "Home")</li>
- <li>@Html.ActionLink("Связаться", "Contact", "Home")</li>*@
+ <li>@Html.ActionLink("Информация", "About", "Home")</li>
+ <li>@Html.ActionLink("Связаться", "Contact", "Home")</li>*@
</ul>
</div>
</div>
</div>
+
+ <br /><br /><br />
+ <div class="col-md-2">
+ <ul id="TaskMenu" class="nav" style="background: #333;">
+ <li><a id="qwe" href="#">Задание1</a></li>
+ <li><a href="#">Задание1</a></li>
+ <li><a href="#">Задание1</a></li>
+ </ul>
+ </div>
+
<div class="container body-content">
@RenderBody()
-
+
<footer class="col-md-12">
<hr />
<p>© @DateTime.Now.Year - мое приложение ASP.NET</p>
Learn_CSS/Learn_CSS.APP.Web/Web.config 56(+30 -26)
diff --git a/Learn_CSS/Learn_CSS.APP.Web/Web.config b/Learn_CSS/Learn_CSS.APP.Web/Web.config
index 0cf304d..c85a2af 100644
--- a/Learn_CSS/Learn_CSS.APP.Web/Web.config
+++ b/Learn_CSS/Learn_CSS.APP.Web/Web.config
@@ -5,55 +5,59 @@
-->
<configuration>
<appSettings>
- <add key="webpages:Version" value="3.0.0.0"/>
- <add key="webpages:Enabled" value="false"/>
- <add key="ClientValidationEnabled" value="true"/>
- <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
+ <add key="webpages:Version" value="3.0.0.0" />
+ <add key="webpages:Enabled" value="false" />
+ <add key="ClientValidationEnabled" value="true" />
+ <add key="UnobtrusiveJavaScriptEnabled" value="true" />
+ <add key="aspnet:MaxJsonDeserializerMembers" value="150000" />
</appSettings>
+ <!--<system.web.extensions>
+ <scripting>
+ <webServices>
+ <jsonSerialization maxJsonLength="2147483644"/>
+ </webServices>
+ </scripting>
+ </system.web.extensions>-->
<system.web>
- <compilation debug="true" targetFramework="4.7.2"/>
- <httpRuntime targetFramework="4.7.2"/>
+ <compilation debug="true" targetFramework="4.7.2" />
+ <httpRuntime targetFramework="4.7.2" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
- <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f"/>
- <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
+ <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" />
+ <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>
- <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0"/>
+ <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
+ <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35"/>
- <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0"/>
+ <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
- <bindingRedirect oldVersion="1.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
+ <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
- <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
+ <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
- <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
+ <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
- <bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
+ <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
- <compiler language="c#;cs;csharp" extension=".cs"
- type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
- warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
- <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
- type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
- warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
+ <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
+ <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
</configuration>
Learn_CSS/Learn_CSS.sln 14(+14 -0)
diff --git a/Learn_CSS/Learn_CSS.sln b/Learn_CSS/Learn_CSS.sln
index 214d5e4..07241f2 100644
--- a/Learn_CSS/Learn_CSS.sln
+++ b/Learn_CSS/Learn_CSS.sln
@@ -5,6 +5,12 @@ VisualStudioVersion = 16.0.29326.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Learn_CSS.APP.Web", "Learn_CSS.APP.Web\Learn_CSS.APP.Web.csproj", "{9D1AD116-63AC-4CB5-93DA-F2BFDA099411}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Learn_CSS.Test.Unit", "Learn_CSS.Test.Unit\Learn_CSS.Test.Unit.csproj", "{921E8330-5992-43D5-ADAC-C26CCFDB7062}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{CF445768-C4A0-4ACB-B781-8539EADA367A}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "App", "App", "{216AAF78-0476-4BB3-889E-11C350A5641E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,10 +21,18 @@ Global
{9D1AD116-63AC-4CB5-93DA-F2BFDA099411}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D1AD116-63AC-4CB5-93DA-F2BFDA099411}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D1AD116-63AC-4CB5-93DA-F2BFDA099411}.Release|Any CPU.Build.0 = Release|Any CPU
+ {921E8330-5992-43D5-ADAC-C26CCFDB7062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {921E8330-5992-43D5-ADAC-C26CCFDB7062}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {921E8330-5992-43D5-ADAC-C26CCFDB7062}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {921E8330-5992-43D5-ADAC-C26CCFDB7062}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {9D1AD116-63AC-4CB5-93DA-F2BFDA099411} = {216AAF78-0476-4BB3-889E-11C350A5641E}
+ {921E8330-5992-43D5-ADAC-C26CCFDB7062} = {CF445768-C4A0-4ACB-B781-8539EADA367A}
+ EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9209A9FE-5DF5-4037-9E0D-2BAF13F46410}
EndGlobalSection
Learn_CSS/Learn_CSS.Test.Unit/app.config 19(+19 -0)
diff --git a/Learn_CSS/Learn_CSS.Test.Unit/app.config b/Learn_CSS/Learn_CSS.Test.Unit/app.config
new file mode 100644
index 0000000..26adfb1
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.Test.Unit/app.config
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
diff --git a/Learn_CSS/Learn_CSS.Test.Unit/Learn_CSS.Test.Unit.csproj b/Learn_CSS/Learn_CSS.Test.Unit/Learn_CSS.Test.Unit.csproj
new file mode 100644
index 0000000..3416667
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.Test.Unit/Learn_CSS.Test.Unit.csproj
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" />
+ <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>{921E8330-5992-43D5-ADAC-C26CCFDB7062}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Learn_CSS.Test.Unit</RootNamespace>
+ <AssemblyName>Learn_CSS.Test.Unit</AssemblyName>
+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
+ <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+ <IsCodedUITest>False</IsCodedUITest>
+ <TestProjectType>UnitTest</TestProjectType>
+ <NuGetPackageImportStamp>
+ </NuGetPackageImportStamp>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <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' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Test\Json\Test_IncludeService.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Learn_CSS.APP.Web\Learn_CSS.APP.Web.csproj">
+ <Project>{9d1ad116-63ac-4cb5-93da-f2bfda099411}</Project>
+ <Name>Learn_CSS.APP.Web</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+ <PropertyGroup>
+ <ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
+ </PropertyGroup>
+ <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props'))" />
+ <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" />
+ </Target>
+ <Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" />
+</Project>
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.Test.Unit/packages.config b/Learn_CSS/Learn_CSS.Test.Unit/packages.config
new file mode 100644
index 0000000..ac575ac
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.Test.Unit/packages.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net46" />
+ <package id="MSTest.TestFramework" version="1.3.2" targetFramework="net46" />
+ <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net46" />
+</packages>
\ No newline at end of file
diff --git a/Learn_CSS/Learn_CSS.Test.Unit/Properties/AssemblyInfo.cs b/Learn_CSS/Learn_CSS.Test.Unit/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..70fa4e1
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.Test.Unit/Properties/AssemblyInfo.cs
@@ -0,0 +1,20 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Learn_CSS.Test.Unit")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("EPAM Systems")]
+[assembly: AssemblyProduct("Learn_CSS.Test.Unit")]
+[assembly: AssemblyCopyright("Copyright © EPAM Systems 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("921e8330-5992-43d5-adac-c26ccfdb7062")]
+
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Learn_CSS/Learn_CSS.Test.Unit/Test/Json/Test_IncludeService.cs b/Learn_CSS/Learn_CSS.Test.Unit/Test/Json/Test_IncludeService.cs
new file mode 100644
index 0000000..310ca81
--- /dev/null
+++ b/Learn_CSS/Learn_CSS.Test.Unit/Test/Json/Test_IncludeService.cs
@@ -0,0 +1,110 @@
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+using Learn_CSS.APP.Web.Models.Services;
+
+
+namespace Learn_CSS.Test.Unit
+{
+ [TestClass]
+ public class Test_IncludeService
+ {
+ private readonly JsonIncludeService JsonIncludeService
+ = new JsonIncludeService();
+
+ #region
+
+ string TestData1 = @"
+{
+ a: {
+ a1:10,
+ a2:20
+ },
+ b:""b1"",
+ ar:
+ [
+ 1,
+ 2,
+ 3
+ ]
+}";
+
+ string TestData2 = @"
+{
+ a: {
+ a1:10,
+ a2:20
+ },
+}";
+
+ string TestData3 = @"
+{
+ b:""b1"",
+}";
+
+ string TestData4 = @"
+{
+ ar:
+ [
+ 1,
+ 2,
+ 3
+ ]
+}";
+
+ #endregion
+
+
+ [TestMethod]
+ public void Test1()
+ {
+ var json = (JObject)JsonConvert.DeserializeObject(TestData1);
+
+ var res = JsonIncludeService.Include(json, json);
+
+ if (!res)
+ throw new Exception();
+ }
+
+ [TestMethod]
+ public void Test2()
+ {
+ var json_main = (JObject)JsonConvert.DeserializeObject(TestData1);
+ var json_sub = (JObject)JsonConvert.DeserializeObject(TestData2);
+
+ var res = JsonIncludeService.Include(json_main, json_sub);
+
+ if (!res)
+ throw new Exception();
+ }
+
+ [TestMethod]
+ public void Test3()
+ {
+ var json_main = (JObject)JsonConvert.DeserializeObject(TestData1);
+ var json_sub = (JObject)JsonConvert.DeserializeObject(TestData3);
+
+ var res = JsonIncludeService.Include(json_main, json_sub);
+
+ if (!res)
+ throw new Exception();
+ }
+
+ [TestMethod]
+ public void Test4()
+ {
+ var json_main = (JObject)JsonConvert.DeserializeObject(TestData1);
+ var json_sub = (JObject)JsonConvert.DeserializeObject(TestData4);
+
+ var res = JsonIncludeService.Include(json_main, json_sub);
+
+ if (!res)
+ throw new Exception();
+ }
+
+
+ }
+}