YED

- Смена культуры вынесена в методы чтения/записи, теперь не

10/6/2019 6:38:11 PM

Details

diff --git a/YED/Build/Graph.Converter.dll b/YED/Build/Graph.Converter.dll
index 7ae56d1..fd1bee0 100644
Binary files a/YED/Build/Graph.Converter.dll and b/YED/Build/Graph.Converter.dll differ
diff --git a/YED/Build/Graph.Converter.pdb b/YED/Build/Graph.Converter.pdb
index 95c4982..2a7fa74 100644
Binary files a/YED/Build/Graph.Converter.pdb and b/YED/Build/Graph.Converter.pdb differ
diff --git a/YED/Build/Graph.Simple.dll b/YED/Build/Graph.Simple.dll
index 573b6d7..0cd134c 100644
Binary files a/YED/Build/Graph.Simple.dll and b/YED/Build/Graph.Simple.dll differ
diff --git a/YED/Build/Graph.Simple.pdb b/YED/Build/Graph.Simple.pdb
index 12452de..a83d4dd 100644
Binary files a/YED/Build/Graph.Simple.pdb and b/YED/Build/Graph.Simple.pdb differ
diff --git a/YED/Build/yEd.XGML.dll b/YED/Build/yEd.XGML.dll
index fdc50eb..31ad4ee 100644
Binary files a/YED/Build/yEd.XGML.dll and b/YED/Build/yEd.XGML.dll differ
diff --git a/YED/Build/yEd.XGML.pdb b/YED/Build/yEd.XGML.pdb
index 0b26f41..4cb1e2d 100644
Binary files a/YED/Build/yEd.XGML.pdb and b/YED/Build/yEd.XGML.pdb differ
diff --git a/YED/YED.Console/App.config b/YED/YED.Console/App.config
index 8e15646..d1428ad 100644
--- a/YED/YED.Console/App.config
+++ b/YED/YED.Console/App.config
@@ -1,6 +1,6 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
 <configuration>
     <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
     </startup>
-</configuration>
\ No newline at end of file
+</configuration>
diff --git a/YED/YED.Console/Program.cs b/YED/YED.Console/Program.cs
index 68180e4..21d0cfb 100644
--- a/YED/YED.Console/Program.cs
+++ b/YED/YED.Console/Program.cs
@@ -4,9 +4,6 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-using System.Threading;
-using System.Globalization;
-
 using YED.Console.Test;
 
 namespace YED
@@ -15,9 +12,6 @@ namespace YED
     {        
         static void Main(string[] args)
         {
-            //Необходимо для того, чтобы double и float парсились из формата 10.10, а не 10,10
-            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
-
             new Test1_ReadWrite().Test(true, true);
             new Test2_CreateGraph_and_ExportToYed().Test(true);            
         }
diff --git a/YED/YED.Console/Test/Test1_ReadWrite.cs b/YED/YED.Console/Test/Test1_ReadWrite.cs
index f1b71c5..95f1c66 100644
--- a/YED/YED.Console/Test/Test1_ReadWrite.cs
+++ b/YED/YED.Console/Test/Test1_ReadWrite.cs
@@ -28,7 +28,7 @@ namespace YED.Console.Test
             //var xgml_model = new XGML_Reader().Read(TestFile_Src);
             //new XGML_Writer().Write(xgml_model, TestFile_Dst);
 
-            Document xgml_model = Document.Load(TestFile_Src);
+            Document xgml_model = Document.Load(TestFile_Src);//new XGML_Reader().Read(TestFile_Src);
             xgml_model.SaveAs(TestFile_Dst);
 
             if (OpenSrc)
diff --git a/YED/YED.Console/YED.Console.csproj b/YED/YED.Console/YED.Console.csproj
index bf67fcf..24edf81 100644
--- a/YED/YED.Console/YED.Console.csproj
+++ b/YED/YED.Console/YED.Console.csproj
@@ -11,6 +11,7 @@
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <Deterministic>true</Deterministic>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
diff --git a/YED/yEd.XGML/DocumentEntities/Document.cs b/YED/yEd.XGML/DocumentEntities/Document.cs
index e899f4b..e184541 100644
--- a/YED/yEd.XGML/DocumentEntities/Document.cs
+++ b/YED/yEd.XGML/DocumentEntities/Document.cs
@@ -4,6 +4,8 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
+using System.IO;
+
 using yEd.XGML.DocumentEntities.Base;
 using yEd.XGML.IO;
 using yEd.XGML.DocumentEntities.NodeEntitie;
@@ -45,6 +47,7 @@ namespace yEd.XGML.DocumentEntities
             XGML_Reader.DropEncodingAttribute(file);
             return new XGML_Reader().Read(file);
         }
+
         public void SaveAs(string file)
         {
             new XGML_Writer().Write(this, file);
diff --git a/YED/yEd.XGML/IO/BaseIO.cs b/YED/yEd.XGML/IO/BaseIO.cs
new file mode 100644
index 0000000..d33ddbe
--- /dev/null
+++ b/YED/yEd.XGML/IO/BaseIO.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using System.Globalization;
+using System.Threading;
+
+namespace yEd.XGML.IO
+{
+    /// <summary>
+    /// Используется для того, чтобы выполнять парсинг чисел с разделителем точкой 10.10
+    /// </summary>
+    public abstract class BaseIO
+    {
+        private CultureInfo ThreadCulture;
+
+        protected BaseIO()
+        {
+            ThreadCulture = Thread.CurrentThread.CurrentCulture;
+        }
+
+        protected void SetCulture_en_US()
+        {
+            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
+        }
+        protected void RestoreCulture()
+        {
+            Thread.CurrentThread.CurrentCulture = ThreadCulture;
+        }
+
+    }
+}
diff --git a/YED/yEd.XGML/IO/XGML_Reader.cs b/YED/yEd.XGML/IO/XGML_Reader.cs
index df89a37..3abb4cb 100644
--- a/YED/yEd.XGML/IO/XGML_Reader.cs
+++ b/YED/yEd.XGML/IO/XGML_Reader.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
 
 using System.IO;
 using System.Xml.Linq;
+using System.Xml;
 
 using yEd.XGML.IO.Read;
 using yEd.XGML.DocumentEntities;
@@ -15,11 +16,13 @@ namespace yEd.XGML.IO
     /// <summary>
     /// Класс для считывагия yed XGML файла в модель Document
     /// </summary>
-    public class XGML_Reader
+    public class XGML_Reader : BaseIO
     {
         public Document Read(XDocument xdoc)
         {
             Document res = new Document();
+            base.SetCulture_en_US();
+
 
             XElement root = xdoc.Element("section");
 
@@ -58,11 +61,13 @@ namespace yEd.XGML.IO
                 }
             }
 
+            base.RestoreCulture();
             return res;
         }
 
-        public Document Read(string file) =>
-            Read(XDocument.Load(file));
+        public Document Read(string file) =>        
+            Read(XDocument.Load(file));        
+        
         public Document Read(Stream stream) =>
             Read(XDocument.Load(stream));
 
diff --git a/YED/yEd.XGML/IO/XGML_Writer.cs b/YED/yEd.XGML/IO/XGML_Writer.cs
index 7c3f6b0..80473d6 100644
--- a/YED/yEd.XGML/IO/XGML_Writer.cs
+++ b/YED/yEd.XGML/IO/XGML_Writer.cs
@@ -18,11 +18,13 @@ namespace yEd.XGML.IO
     /// <summary>
     /// Класс для записи Document в yed XGML файл
     /// </summary>
-    public class XGML_Writer
+    public class XGML_Writer : BaseIO
     {
         public XDocument Write(Document document)
         {
             XDocument res = new XDocument();
+            base.SetCulture_en_US();
+            
 
             XElement root = XElement_Tools.CreateSection("xgml");
             res.Add(root);
@@ -57,6 +59,7 @@ namespace yEd.XGML.IO
 
             root.Add(graph);
 
+            base.RestoreCulture();
             return res;
         }
 
diff --git a/YED/yEd.XGML/yEd.XGML.csproj b/YED/yEd.XGML/yEd.XGML.csproj
index 8840512..b2068f9 100644
--- a/YED/yEd.XGML/yEd.XGML.csproj
+++ b/YED/yEd.XGML/yEd.XGML.csproj
@@ -44,6 +44,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="IO\BaseIO.cs" />
     <Compile Include="IO\XGML_Reader.cs" />
     <Compile Include="IO\Read\EdgeReader.cs" />
     <Compile Include="IO\Read\IReader.cs" />