From ad1f0bc2e8a69c2c4e542f8c468707e8552113ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20F=C3=A9lix?= <felixantoine67@yahoo.fr>
Date: Wed, 1 Apr 2020 13:27:05 +0200
Subject: [PATCH] Ajout de NewtonSoft pour gerer les fichiers JSON ainsi que d
 une classe Config dans "Config.js".

---
 psychorientation/psychorientation/Config.cs   | 56 +++++++++++++++++++
 .../psychorientation/packages.config          |  4 ++
 .../psychorientation/psychorientation.csproj  |  5 ++
 3 files changed, 65 insertions(+)
 create mode 100644 psychorientation/psychorientation/Config.cs
 create mode 100644 psychorientation/psychorientation/packages.config

diff --git a/psychorientation/psychorientation/Config.cs b/psychorientation/psychorientation/Config.cs
new file mode 100644
index 0000000..16b19f6
--- /dev/null
+++ b/psychorientation/psychorientation/Config.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+
+namespace psychorientation
+{
+    class Config
+    {
+        private static Config instance;
+
+        public double coeffEffortOral;
+        public double coeffCompetenceOral;
+
+        public double coeffCompetenceEcrit;
+        public double coeffEffortEcrit;
+
+        public static Config getInstance()
+        {
+            if (Config.instance == null)
+            {
+
+                Config.instance = JsonConvert.DeserializeObject<Config>(File.ReadAllText("config.json"));
+                Console.WriteLine(Config.instance.coeffEffortOral);
+                return Config.instance;
+            }
+            else
+            {
+                return Config.instance;
+            }
+        }
+
+        public double getCoeffEffortOral()
+        {
+            return this.coeffEffortOral;
+        }
+
+        public double getCoeffCompetenceOral()
+        {
+            return this.coeffCompetenceOral;
+        }
+
+        public double getCoeffCompetenceEcrit()
+        {
+            return this.coeffCompetenceOral;
+        }
+
+        public double getCoeffEffortEcrit()
+        {
+            return this.coeffEffortEcrit;
+        }
+    }
+}
diff --git a/psychorientation/psychorientation/packages.config b/psychorientation/psychorientation/packages.config
new file mode 100644
index 0000000..8ab13a9
--- /dev/null
+++ b/psychorientation/psychorientation/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
+</packages>
\ No newline at end of file
diff --git a/psychorientation/psychorientation/psychorientation.csproj b/psychorientation/psychorientation/psychorientation.csproj
index 19cb37f..842cf6f 100644
--- a/psychorientation/psychorientation/psychorientation.csproj
+++ b/psychorientation/psychorientation/psychorientation.csproj
@@ -33,6 +33,9 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <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" />
     <Reference Include="System.Xml.Linq" />
@@ -46,6 +49,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Config.cs" />
     <Compile Include="Eleve.cs" />
     <Compile Include="Form1.cs">
       <SubType>Form</SubType>
@@ -85,6 +89,7 @@
       <AutoGen>True</AutoGen>
       <DependentUpon>Resources.resx</DependentUpon>
     </Compile>
+    <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
-- 
GitLab