-
Notifications
You must be signed in to change notification settings - Fork 18
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
1 parent
37ee652
commit 59fef05
Showing
16 changed files
with
448 additions
and
12 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
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,14 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models.Avro.LogicalTypes | ||
{ | ||
public class AvroDate : AvroLogicalType | ||
{ | ||
public AvroDate() | ||
: base(AvroPrimitiveType.Int) | ||
{ | ||
} | ||
|
||
public override LogicalType LogicalType => LogicalType.Date; | ||
} | ||
} |
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,26 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models.Avro.LogicalTypes | ||
{ | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public class AvroDecimal : AvroLogicalType | ||
{ | ||
public AvroDecimal() | ||
: base(AvroPrimitiveType.Bytes) | ||
{ | ||
} | ||
|
||
public override LogicalType LogicalType => LogicalType.Decimal; | ||
|
||
public int? Scale { get; set; } | ||
|
||
public int? Precision { get; set; } | ||
|
||
public override void SerializeV2Core(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteOptionalProperty("scale", this.Scale); | ||
writer.WriteOptionalProperty("precision", this.Precision); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/LEGO.AsyncAPI/Models/Avro/LogicalTypes/AvroDuration.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,42 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models.Avro.LogicalTypes | ||
{ | ||
using System.Linq; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public class AvroDuration : AvroFixed | ||
{ | ||
public LogicalType LogicalType { get; } = LogicalType.Duration; | ||
|
||
public new int Size { get; } = 12; | ||
|
||
public override void SerializeV2WithoutReference(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteStartObject(); | ||
writer.WriteOptionalProperty("type", this.Type); | ||
writer.WriteOptionalProperty("logicalType", this.LogicalType.GetDisplayName()); | ||
writer.WriteRequiredProperty("name", this.Name); | ||
writer.WriteOptionalProperty("namespace", this.Namespace); | ||
writer.WriteOptionalCollection("aliases", this.Aliases, (w, s) => w.WriteValue(s)); | ||
writer.WriteRequiredProperty("size", this.Size); | ||
if (this.Metadata.Any()) | ||
{ | ||
foreach (var item in this.Metadata) | ||
{ | ||
writer.WritePropertyName(item.Key); | ||
if (item.Value == null) | ||
{ | ||
writer.WriteNull(); | ||
} | ||
else | ||
{ | ||
writer.WriteAny(item.Value); | ||
} | ||
} | ||
} | ||
|
||
writer.WriteEndObject(); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/LEGO.AsyncAPI/Models/Avro/LogicalTypes/AvroLogicalType.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,48 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models.Avro.LogicalTypes | ||
{ | ||
using System.Linq; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public abstract class AvroLogicalType : AvroPrimitive | ||
{ | ||
protected AvroLogicalType(AvroPrimitiveType type) | ||
: base(type) | ||
{ | ||
} | ||
|
||
public abstract LogicalType LogicalType { get; } | ||
|
||
public virtual void SerializeV2Core(IAsyncApiWriter writer) | ||
{ | ||
} | ||
|
||
public override void SerializeV2WithoutReference(IAsyncApiWriter writer) | ||
{ | ||
writer.WriteStartObject(); | ||
writer.WriteOptionalProperty("type", this.Type); | ||
writer.WriteOptionalProperty("logicalType", this.LogicalType.GetDisplayName()); | ||
|
||
this.SerializeV2Core(writer); | ||
|
||
if (this.Metadata.Any()) | ||
{ | ||
foreach (var item in this.Metadata) | ||
{ | ||
writer.WritePropertyName(item.Key); | ||
if (item.Value == null) | ||
{ | ||
writer.WriteNull(); | ||
} | ||
else | ||
{ | ||
writer.WriteAny(item.Value); | ||
} | ||
} | ||
} | ||
|
||
writer.WriteEndObject(); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/LEGO.AsyncAPI/Models/Avro/LogicalTypes/AvroTimeMicros.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,14 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models.Avro.LogicalTypes | ||
{ | ||
public class AvroTimeMicros : AvroLogicalType | ||
{ | ||
public AvroTimeMicros() | ||
: base(AvroPrimitiveType.Long) | ||
{ | ||
} | ||
|
||
public override LogicalType LogicalType => LogicalType.Time_Micros; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/LEGO.AsyncAPI/Models/Avro/LogicalTypes/AvroTimeMillis.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,14 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models.Avro.LogicalTypes | ||
{ | ||
public class AvroTimeMillis : AvroLogicalType | ||
{ | ||
public AvroTimeMillis() | ||
: base(AvroPrimitiveType.Int) | ||
{ | ||
} | ||
|
||
public override LogicalType LogicalType => LogicalType.Time_Millis; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/LEGO.AsyncAPI/Models/Avro/LogicalTypes/AvroTimestampMicros.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,14 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Models.Avro.LogicalTypes | ||
{ | ||
public class AvroTimestampMicros : AvroLogicalType | ||
{ | ||
public AvroTimestampMicros() | ||
: base(AvroPrimitiveType.Long) | ||
{ | ||
} | ||
|
||
public override LogicalType LogicalType => LogicalType.Timestamp_Micros; | ||
} | ||
} |
Oops, something went wrong.