Skip to content

Commit ae08a6a

Browse files
committed
rename type->schematype
1 parent 66266e6 commit ae08a6a

File tree

17 files changed

+89
-90
lines changed

17 files changed

+89
-90
lines changed

src/DocumentFormat.OpenXml.Framework/Framework/Metadata/ElementFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ internal sealed class ElementFactory
1111
{
1212
private readonly Func<OpenXmlElement> _factory;
1313

14-
public ElementFactory(in OpenXmlType type, Func<OpenXmlElement> factory)
14+
public ElementFactory(in OpenXmlSchemaType type, Func<OpenXmlElement> factory)
1515
{
1616
Type = type;
1717
_factory = factory;
1818
}
1919

20-
public OpenXmlType Type { get; }
20+
public OpenXmlSchemaType Type { get; }
2121

2222
public OpenXmlElement Create() => _factory();
2323

src/DocumentFormat.OpenXml.Framework/Framework/Metadata/ElementMetadata.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal class ElementMetadata : IElementMetadata
1818
private readonly Lazy<ElementFactoryCollection>? _children;
1919

2020
internal ElementMetadata(
21-
OpenXmlType type,
21+
OpenXmlSchemaType type,
2222
ReadOnlyArray<AttributeMetadata> attributes,
2323
ReadOnlyArray<IValidator> validators,
2424
ReadOnlyArray<IValidator> constraints,
@@ -39,7 +39,7 @@ internal ElementMetadata()
3939
{
4040
}
4141

42-
public OpenXmlType Type { get; }
42+
public OpenXmlSchemaType Type { get; }
4343

4444
public ReadOnlyArray<AttributeMetadata> Attributes { get; }
4545

@@ -62,7 +62,7 @@ public class Builder : ValidatorBuilder
6262
private List<IMetadataBuilder<AttributeMetadata>>? _attributes;
6363
private HashSet<IMetadataBuilder<ElementFactory>>? _children;
6464
private List<IValidator>? _constraints;
65-
private OpenXmlType _type;
65+
private OpenXmlSchemaType _type;
6666

6767
public Builder(IOpenXmlNamespaceResolver resolver)
6868
{
@@ -90,7 +90,7 @@ public void AddConstraint(SemanticConstraint constraint)
9090
public OpenXmlQualifiedName CreateQName(string qname)
9191
=> _resolver.ParseQName(qname);
9292

93-
public void SetSchema(in OpenXmlType type)
93+
public void SetSchema(in OpenXmlSchemaType type)
9494
=> _type = type;
9595

9696
public void AddChild<T>()

src/DocumentFormat.OpenXml.Framework/Framework/Metadata/IElementMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace DocumentFormat.OpenXml.Framework.Metadata;
77

88
internal interface IElementMetadata
99
{
10-
OpenXmlType Type { get; }
10+
OpenXmlSchemaType Type { get; }
1111

1212
ReadOnlyArray<AttributeMetadata> Attributes { get; }
1313

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
6+
namespace DocumentFormat.OpenXml.Framework;
7+
8+
internal readonly struct OpenXmlSchemaType(OpenXmlQualifiedName name, OpenXmlQualifiedName type) : IComparable<OpenXmlSchemaType>, IEquatable<OpenXmlSchemaType>
9+
{
10+
public OpenXmlQualifiedName Name => name;
11+
12+
public OpenXmlQualifiedName Type => type;
13+
14+
public int CompareTo(OpenXmlSchemaType other)
15+
{
16+
var nameCompare = Name.CompareTo(other.Name);
17+
18+
if (nameCompare != 0)
19+
{
20+
return nameCompare;
21+
}
22+
23+
return Type.CompareTo(other.Type);
24+
}
25+
26+
public bool Equals(OpenXmlSchemaType other) => Equals(Name, other.Name) && Equals(Type, other.Type);
27+
28+
public override bool Equals(object? obj) => obj is OpenXmlSchemaType t && Equals(t);
29+
30+
public override string ToString() => $"{Type}/{Name}";
31+
32+
public override int GetHashCode()
33+
{
34+
var hc = default(HashCode);
35+
36+
hc.Add(Name);
37+
hc.Add(Type);
38+
39+
return hc.ToHashCode();
40+
}
41+
42+
public static bool operator ==(OpenXmlSchemaType left, OpenXmlSchemaType right) => left.Equals(right);
43+
44+
public static bool operator !=(OpenXmlSchemaType left, OpenXmlSchemaType right) => !left.Equals(right);
45+
46+
public static bool operator <(OpenXmlSchemaType left, OpenXmlSchemaType right) => left.CompareTo(right) < 0;
47+
48+
public static bool operator >(OpenXmlSchemaType left, OpenXmlSchemaType right) => left.CompareTo(right) > 0;
49+
50+
public static bool operator <=(OpenXmlSchemaType left, OpenXmlSchemaType right) => left.CompareTo(right) <= 0;
51+
52+
public static bool operator >=(OpenXmlSchemaType left, OpenXmlSchemaType right) => left.CompareTo(right) >= 0;
53+
}

src/DocumentFormat.OpenXml.Framework/Framework/OpenXmlType.cs

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/DocumentFormat.OpenXml.Framework/Framework/Schema/CompiledParticle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public CompiledParticle(ParticleConstraint? particle)
3333
public ParticlePath? Find(OpenXmlElement? obj)
3434
=> Find(obj?.Metadata.Type);
3535

36-
public ParticlePath? Find(OpenXmlType? type)
36+
public ParticlePath? Find(OpenXmlSchemaType? type)
3737
{
3838
if (type is null)
3939
{

src/DocumentFormat.OpenXml.Framework/Framework/Schema/LookupItem.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ namespace DocumentFormat.OpenXml.Framework;
99
[DebuggerDisplay("[{Type}] - {Path}")]
1010
internal readonly record struct LookupItem
1111
{
12-
public LookupItem(OpenXmlType type, ParticlePath path)
12+
public LookupItem(OpenXmlSchemaType type, ParticlePath path)
1313
{
1414
Type = type;
1515
Path = path;
1616
}
1717

18-
public OpenXmlType Type { get; }
18+
public OpenXmlSchemaType Type { get; }
1919

2020
public ParticlePath Path { get; }
2121

22-
public void Deconstruct(out OpenXmlType type, out ParticlePath path)
22+
public void Deconstruct(out OpenXmlSchemaType type, out ParticlePath path)
2323
{
2424
type = Type;
2525
path = Path;

src/DocumentFormat.OpenXml.Framework/Framework/Schema/ParticleCollection.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ namespace DocumentFormat.OpenXml.Framework.Schema
1313
/// </summary>
1414
internal readonly struct ParticleCollection : IEnumerable<OpenXmlElement>
1515
{
16-
private readonly OpenXmlType _type;
16+
private readonly OpenXmlSchemaType _type;
1717
private readonly OpenXmlCompositeElement _element;
1818
private readonly CompiledParticle _compiled;
1919
private readonly ParticlePath? _elementPath;
2020

21-
internal ParticleCollection(in OpenXmlType type, CompiledParticle compiled, OpenXmlCompositeElement element)
21+
internal ParticleCollection(in OpenXmlSchemaType type, CompiledParticle compiled, OpenXmlCompositeElement element)
2222
{
2323
_type = type;
2424
_element = element;
@@ -156,10 +156,10 @@ public bool Contains(OpenXmlElement item)
156156

157157
public struct Enumerator : IEnumerator<OpenXmlElement>
158158
{
159-
private readonly OpenXmlType _type;
159+
private readonly OpenXmlSchemaType _type;
160160
private OpenXmlElement? _child;
161161

162-
internal Enumerator(OpenXmlElement element, in OpenXmlType type)
162+
internal Enumerator(OpenXmlElement element, in OpenXmlSchemaType type)
163163
{
164164
_type = type;
165165
_child = element.FirstChild;

src/DocumentFormat.OpenXml.Framework/Framework/Schema/ParticleExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ namespace DocumentFormat.OpenXml.Framework
1212
/// </summary>
1313
internal static class ParticleExtensions
1414
{
15-
public static ParticleCollection GetCollection(this CompiledParticle compiled, OpenXmlType type, OpenXmlCompositeElement element)
15+
public static ParticleCollection GetCollection(this CompiledParticle compiled, OpenXmlSchemaType type, OpenXmlCompositeElement element)
1616
=> new(type, compiled, element);
1717

18-
public static OpenXmlElement? Get(this CompiledParticle? compiled, OpenXmlCompositeElement element, OpenXmlType type)
18+
public static OpenXmlElement? Get(this CompiledParticle? compiled, OpenXmlCompositeElement element, OpenXmlSchemaType type)
1919
{
2020
if (compiled is null)
2121
{
@@ -46,7 +46,7 @@ public static ParticleCollection GetCollection(this CompiledParticle compiled, O
4646
public static bool Set(this CompiledParticle? compiled, OpenXmlCompositeElement parent, OpenXmlElement value)
4747
=> Set(compiled, parent, value, value.Metadata.Type);
4848

49-
public static bool Set(this CompiledParticle? compiled, OpenXmlCompositeElement parent, OpenXmlElement? value, OpenXmlType? type)
49+
public static bool Set(this CompiledParticle? compiled, OpenXmlCompositeElement parent, OpenXmlElement? value, OpenXmlSchemaType? type)
5050
{
5151
if (type is null)
5252
{

src/DocumentFormat.OpenXml.Framework/OpenXmlCompositeElement.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,10 @@ private static void RemoveUnnecessaryExtAttr(OpenXmlElement node, OpenXmlElement
770770
}
771771
}
772772

773-
private protected OpenXmlElement? GetElement(in OpenXmlType type)
773+
private protected OpenXmlElement? GetElement(in OpenXmlSchemaType type)
774774
=> Metadata.Particle.Get(this, type);
775775

776-
private protected bool SetElement(OpenXmlElement? value, OpenXmlType type)
776+
private protected bool SetElement(OpenXmlElement? value, OpenXmlSchemaType type)
777777
=> Metadata.Particle.Set(this, value, type);
778778

779779
private void AddANode(OpenXmlElement node)

0 commit comments

Comments
 (0)