-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed reference + attribute-based deserialization issues (#503)
The XmlReader was setting an improper state when reading attribute values. Now the current attribute index is maintained when accessing another attribute value.
- Loading branch information
1 parent
7563d44
commit e2c435a
Showing
68 changed files
with
3,346 additions
and
37 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
src/ExtendedXmlSerializer/ContentModel/Content/Contains.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,29 @@ | ||
using ExtendedXmlSerializer.ContentModel.Format; | ||
using ExtendedXmlSerializer.ContentModel.Identification; | ||
using ExtendedXmlSerializer.Core.Specifications; | ||
using System.Xml; | ||
|
||
namespace ExtendedXmlSerializer.ContentModel.Content | ||
{ | ||
sealed class Contains : ISpecification<(IFormatReader Reader, IIdentity Identity)> | ||
{ | ||
public static Contains Default { get; } = new Contains(); | ||
|
||
Contains() {} | ||
|
||
public bool IsSatisfiedBy((IFormatReader Reader, IIdentity Identity) parameter) | ||
{ | ||
var (format, identity) = parameter; | ||
|
||
var reader = format.Get().To<XmlReader>(); | ||
var name = reader.NodeType == XmlNodeType.Attribute ? format.Name : null; | ||
var result = format.IsSatisfiedBy(identity); | ||
if (name != null) | ||
{ | ||
reader.MoveToAttribute(name); | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/ExtendedXmlSerializer/ContentModel/Content/IsElement.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,37 @@ | ||
using ExtendedXmlSerializer.ContentModel.Format; | ||
using ExtendedXmlSerializer.Core.Specifications; | ||
using System; | ||
using System.Xml; | ||
|
||
namespace ExtendedXmlSerializer.ContentModel.Content | ||
{ | ||
sealed class IsElement : ISpecification<IFormatReader> | ||
{ | ||
public static IsElement Default { get; } = new IsElement(); | ||
|
||
IsElement() : this(MemberProperty.Default.Get) {} | ||
|
||
readonly Func<IFormatReader, bool> _member; | ||
|
||
public IsElement(Func<IFormatReader, bool> member) => _member = member; | ||
|
||
public bool IsSatisfiedBy(IFormatReader parameter) | ||
{ | ||
var reader = parameter.Get().To<XmlReader>(); | ||
switch (reader.NodeType) | ||
{ | ||
case XmlNodeType.Attribute: | ||
var name = parameter.Name; | ||
var result = _member(parameter); | ||
if (result) | ||
{ | ||
reader.MoveToAttribute(name); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace VweCore.Abstractions | ||
{ | ||
public interface ICustomDelete | ||
{ | ||
void DeleteFromMap(Map map); | ||
|
||
void RestoreBackToMap(Map map); | ||
} | ||
} |
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,30 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using VweCore.Geometry; | ||
|
||
namespace VweCore.Abstractions | ||
{ | ||
public interface IEntity : IEquatable<IEntity>, IComparable<IEntity> | ||
{ | ||
int Id { get; set; } | ||
|
||
Guid InternalId { get; set; } | ||
|
||
string DisplayString { get; } | ||
|
||
void SetAssociatedDiagramItem(object diagramItem); | ||
|
||
EntityOrderIndex OrderIndex { get; } | ||
|
||
bool TryGetAssociatedDiagramItem<TDiagramItem>([NotNullWhen(true)] out TDiagramItem? diagramItem) | ||
where TDiagramItem : class; | ||
|
||
TDiagramItem GetAssociatedDiagramItem<TDiagramItem>() | ||
where TDiagramItem : class; | ||
|
||
TDiagramItem DisconnectDiagramItem<TDiagramItem>() | ||
where TDiagramItem : class; | ||
|
||
LeveledRectangle GetBounds(); | ||
} | ||
} |
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,11 @@ | ||
using VweCore.Geometry; | ||
|
||
namespace VweCore.Abstractions | ||
{ | ||
public interface ILineSegment : IEntity | ||
{ | ||
Point2D Point1 { get; set; } | ||
|
||
Point2D Point2 { get; set; } | ||
} | ||
} |
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,9 @@ | ||
using VweCore.Geometry; | ||
|
||
namespace VweCore.Abstractions | ||
{ | ||
public interface IMovable : IEntity | ||
{ | ||
void Move(Point2D moveVector); | ||
} | ||
} |
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,9 @@ | ||
using VweCore.Geometry; | ||
|
||
namespace VweCore.Abstractions | ||
{ | ||
public interface IPositionable : IMovable | ||
{ | ||
Point2D Position { get; set; } | ||
} | ||
} |
Oops, something went wrong.