-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
101 additions
and
90 deletions.
There are no files selected for viewing
5 changes: 1 addition & 4 deletions
5
src/PetroglyphTools/PG.StarWarsGame.Engine/Xml/IPetroglyphXmlFileParserFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
using System; | ||
using PG.StarWarsGame.Files.XML.Parsers; | ||
using PG.StarWarsGame.Files.XML.Parsers; | ||
|
||
namespace PG.StarWarsGame.Engine.Xml; | ||
|
||
public interface IPetroglyphXmlFileParserFactory | ||
{ | ||
IPetroglyphXmlFileParser<T> GetFileParser<T>(); | ||
|
||
IPetroglyphXmlFileParser GetFileParser(Type type); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/PetroglyphTools/PG.StarWarsGame.Engine/Xml/ParserNotFoundException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
|
||
namespace PG.StarWarsGame.Engine.Xml; | ||
|
||
public sealed class ParserNotFoundException : Exception | ||
{ | ||
public override string Message { get; } | ||
|
||
public ParserNotFoundException(Type type) | ||
{ | ||
Message = $"The parser for the type {type} was not found."; | ||
} | ||
|
||
public ParserNotFoundException(string tag) | ||
{ | ||
Message = $"The parser for the tag {tag} was not found."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 3 additions & 14 deletions
17
src/PetroglyphTools/PG.StarWarsGame.Files.XML/Parsers/IPetroglyphXmlElementParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,5 @@ | ||
using System.Xml.Linq; | ||
using PG.Commons.Hashing; | ||
namespace PG.StarWarsGame.Files.XML.Parsers; | ||
|
||
namespace PG.StarWarsGame.Files.XML.Parsers; | ||
public interface IPetroglyphXmlElementParser : IPetroglyphXmlParser; | ||
|
||
public interface IPetroglyphXmlElementParser | ||
{ | ||
public object Parse(XElement element); | ||
} | ||
|
||
public interface IPetroglyphXmlElementParser<T> : IPetroglyphXmlElementParser | ||
{ | ||
public new T Parse(XElement element); | ||
|
||
public T Parse(XElement element, IReadOnlyValueListDictionary<Crc32, T> parsedElements, out Crc32 nameCrc); | ||
} | ||
public interface IPetroglyphXmlElementParser<T> : IPetroglyphXmlElementParser, IPetroglyphXmlParser<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/PetroglyphTools/PG.StarWarsGame.Files.XML/Parsers/IPetroglyphXmlParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Xml.Linq; | ||
|
||
namespace PG.StarWarsGame.Files.XML.Parsers; | ||
|
||
public interface IPetroglyphXmlParser | ||
{ | ||
public object Parse(XElement element); | ||
} | ||
|
||
public interface IPetroglyphXmlParser<T> : IPetroglyphXmlParser | ||
{ | ||
public new T Parse(XElement element); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/PetroglyphTools/PG.StarWarsGame.Files.XML/Parsers/PetroglyphXmlElementParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
using System.Linq; | ||
using System.Xml.Linq; | ||
using PG.Commons.Hashing; | ||
|
||
namespace PG.StarWarsGame.Files.XML.Parsers; | ||
|
||
public abstract class PetroglyphXmlElementParser<T> : PetroglyphXmlParser<T> | ||
{ | ||
protected string GetTagName(XElement element) | ||
{ | ||
return element.Name.LocalName; | ||
} | ||
|
||
protected string GetNameAttributeValue(XElement element) | ||
{ | ||
var nameAttribute = element.Attributes() | ||
.FirstOrDefault(a => a.Name.LocalName == "Name"); | ||
return nameAttribute is null ? string.Empty : nameAttribute.Value; | ||
} | ||
|
||
public abstract T Parse(XElement element, IReadOnlyValueListDictionary<Crc32, T> parsedElements, out Crc32 nameCrc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
src/PetroglyphTools/PG.StarWarsGame.Files.XML/Parsers/PetroglyphXmlParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/PetroglyphTools/PG.StarWarsGame.Files.XML/Parsers/PetroglyphXmlPrimitiveElementParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace PG.StarWarsGame.Files.XML.Parsers; | ||
|
||
public abstract class PetroglyphXmlPrimitiveElementParser<T> : PetroglyphXmlParser<T>, IPetroglyphXmlElementParser<T>; |
14 changes: 0 additions & 14 deletions
14
src/PetroglyphTools/PG.StarWarsGame.Files.XML/Parsers/PetroglyphXmlPrimitiveParser.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters