Skip to content

Commit

Permalink
Move common methods to dll. Fix compilation errors in ServerCore.
Browse files Browse the repository at this point in the history
  • Loading branch information
JetStream96 committed Oct 12, 2017
1 parent 4733d93 commit 0c52b75
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 39 deletions.
26 changes: 26 additions & 0 deletions src/CommonLibrary/LibraryExtension/Xmls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Linq;
using System.Xml;

namespace CommonLibrary.LibraryExtension
{
public static class Xmls
{
public static string RemoveIllegalXmlChar(this string s)
{
return new string(s.CastStr().Where(c => IsValidXmlChar(c)).ToArray());
}

public static bool IsValidXmlChar(this char c)
{
try
{
XmlConvert.VerifyXmlChars(new string(c, 1));
return true;
}
catch
{
return false;
}
}
}
}
6 changes: 3 additions & 3 deletions src/FixTypeAnalyzer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using CommonLibrary.LibraryExtension;
using QSP.RouteFinding;
using System;
using System.IO;
using System.Linq;
using System.Text;
using QSP.LibraryExtension;
using QSP.RouteFinding;

namespace FixTypeAnalyzer
{
Expand Down
2 changes: 1 addition & 1 deletion src/FixTypeAnalyzer/Report.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QSP.LibraryExtension;
using CommonLibrary.LibraryExtension;
using CommonLibrary.LibraryExtension.Sets;

namespace FixTypeAnalyzer
Expand Down
4 changes: 4 additions & 0 deletions src/FuelProfileConversion/B748F/B748F.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CommonLibrary\CommonLibrary.csproj">
<Project>{56c3bd11-e518-4454-8f74-94156b04ebad}</Project>
<Name>CommonLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\..\QSP\QSP.csproj">
<Project>{182ca73b-6911-4d37-ba34-c86232fe37f1}</Project>
<Name>QSP</Name>
Expand Down
7 changes: 4 additions & 3 deletions src/FuelProfileConversion/B748F/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CommonLibrary.LibraryExtension;
using QSP.LibraryExtension;
using QSP.MathTools.Tables;
using QSP.MathTools.Tables.Readers;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B748F
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public static class SerializationHelper
{
public static XElement Serialize(this string value, string key)
{
return new XElement(key, value.ToValidXmlString());
// The XElement escapes the chars automatically.
return new XElement(key, value);
}

public static XElement Serialize(this int value, string key)
Expand Down
13 changes: 0 additions & 13 deletions src/QSP/LibraryExtension/Xmls.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/QSP/QSP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@
<Compile Include="LibraryExtension\LinkedLists.cs" />
<Compile Include="LibraryExtension\Locator.cs" />
<Compile Include="LibraryExtension\WebRequests.cs" />
<Compile Include="LibraryExtension\Xmls.cs" />
<Compile Include="LibraryExtension\XmlSerialization\Interfaces.cs" />
<Compile Include="LibraryExtension\XmlSerialization\SerializationHelper.cs" />
<Compile Include="MathTools\EarthGeometry.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/QSP/RouteFinding/Tracks/Ausots/AusotsMessage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using QSP.RouteFinding.Tracks.Common;
using CommonLibrary.LibraryExtension;
using QSP.RouteFinding.Tracks.Common;
using System.Xml.Linq;
using QSP.LibraryExtension;
using static CommonLibrary.LibraryExtension.Strings;

namespace QSP.RouteFinding.Tracks.Ausots
Expand All @@ -15,7 +15,7 @@ public class AusotsMessage : ITrackMessage

public AusotsMessage(string HtmlSource)
{
AllText = HtmlSource.RemoveHtmlTags().ToValidXmlString();
AllText = HtmlSource.RemoveHtmlTags().RemoveIllegalXmlChar();
}

public AusotsMessage(XDocument doc)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CommonLibrary.LibraryExtension;
using QSP.LibraryExtension;
using System.Collections.Generic;
using System.Text.RegularExpressions;

Expand All @@ -15,7 +14,7 @@ public class MessageSplitter

public MessageSplitter(string html)
{
this.html = html.ToValidXmlString();
this.html = html.RemoveIllegalXmlChar();
}

public List<IndividualNatsMessage> Split()
Expand Down
4 changes: 2 additions & 2 deletions src/QSP/RouteFinding/Tracks/Pacots/PacotsMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using QSP.LibraryExtension;
using CommonLibrary.LibraryExtension;

namespace QSP.RouteFinding.Tracks.Pacots
{
Expand Down Expand Up @@ -48,7 +48,7 @@ public PacotsMessage(string htmlFile) : this()
{
try
{
ParseHtml(htmlFile.ToValidXmlString());
ParseHtml(htmlFile.RemoveIllegalXmlChar());
}
catch (Exception ex)
{
Expand Down
6 changes: 0 additions & 6 deletions src/QSimPlanner.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "Tests\UnitTest\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0F086D96-14AE-45B8-B9E1-CBA61B11E6DC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{623B608B-3455-4042-8955-D7D2643D9E6D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTest", "Tests\IntegrationTest\IntegrationTest.csproj", "{F56577DD-5BFA-472B-B67C-38F4977029CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstallerBuilder", "Installer\InstallerBuilder\InstallerBuilder.csproj", "{AEB07B76-B123-4395-AF28-EC8746D5141D}"
Expand Down Expand Up @@ -43,10 +41,6 @@ Global
{1301576E-314F-437F-AC78-60F1434D7B63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1301576E-314F-437F-AC78-60F1434D7B63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1301576E-314F-437F-AC78-60F1434D7B63}.Release|Any CPU.Build.0 = Release|Any CPU
{623B608B-3455-4042-8955-D7D2643D9E6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{623B608B-3455-4042-8955-D7D2643D9E6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{623B608B-3455-4042-8955-D7D2643D9E6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{623B608B-3455-4042-8955-D7D2643D9E6D}.Release|Any CPU.Build.0 = Release|Any CPU
{F56577DD-5BFA-472B-B67C-38F4977029CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F56577DD-5BFA-472B-B67C-38F4977029CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F56577DD-5BFA-472B-B67C-38F4977029CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
6 changes: 3 additions & 3 deletions src/ServerCore/Nats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public Nats(IHostingEnvironment env)
shared = SharedData.GetInstance(env);
}

private static string DownloadNats()
private static List<IndividualNatsMessage> DownloadNats()
{
var wc = new WebClient();
var str=wc.DownloadString("https://www.notams.faa.gov/common/nat.html?");

return new MessageSplitter(str).Split();
}

// @Throws
private void SaveNats()
{
var result = new NatsDownloader().DownloadFromNotam();
var result = DownloadNats();
Directory.CreateDirectory(shared.MapPath("nats"));
bool westUpdated = false;
bool eastUpdated = false;
Expand Down
3 changes: 2 additions & 1 deletion src/ServerCore/NatsLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using CommonLibrary.LibraryExtension;

namespace ServerCore
{
Expand Down Expand Up @@ -147,7 +148,7 @@ public class MessageSplitter

public MessageSplitter(string html)
{
this.html = html.ToValidXmlString();
this.html = html.RemoveIllegalXmlChar();
}

public List<IndividualNatsMessage> Split()
Expand Down

0 comments on commit 0c52b75

Please sign in to comment.