-
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.
refactor: privatize the avro schema property and add helpers
- Loading branch information
1 parent
a9d501d
commit 8598935
Showing
2 changed files
with
30 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,30 +4,43 @@ namespace LEGO.AsyncAPI.Models | |
{ | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
using System; | ||
Check warning on line 7 in src/LEGO.AsyncAPI/Models/AsyncApiAvroSchemaPayload.cs GitHub Actions / build (macos-latest)
Check warning on line 7 in src/LEGO.AsyncAPI/Models/AsyncApiAvroSchemaPayload.cs GitHub Actions / Publish NuGet packages (LEGO.AsyncAPI.Readers)
Check warning on line 7 in src/LEGO.AsyncAPI/Models/AsyncApiAvroSchemaPayload.cs GitHub Actions / Publish NuGet packages (LEGO.AsyncAPI)
Check warning on line 7 in src/LEGO.AsyncAPI/Models/AsyncApiAvroSchemaPayload.cs GitHub Actions / Publish NuGet packages (LEGO.AsyncAPI.Bindings)
Check warning on line 7 in src/LEGO.AsyncAPI/Models/AsyncApiAvroSchemaPayload.cs GitHub Actions / build (windows-latest)
|
||
|
||
public class AsyncApiAvroSchemaPayload : IAsyncApiMessagePayload | ||
{ | ||
public AvroSchema Schema { get; set; } | ||
private readonly AvroSchema schema; | ||
|
||
public AsyncApiAvroSchemaPayload(AvroSchema schema) | ||
{ | ||
this.Schema = schema; | ||
this.schema = schema; | ||
} | ||
|
||
public AsyncApiAvroSchemaPayload() | ||
{ | ||
this.schema = new AvroRecord(); | ||
} | ||
|
||
public bool TryGetAs<T>(out T schema) | ||
where T : AvroSchema | ||
{ | ||
schema = this.Schema as T; | ||
schema = this.schema as T; | ||
return schema != null; | ||
} | ||
|
||
public bool UnresolvedReference { get => this.Schema.UnresolvedReference; set => this.Schema.UnresolvedReference = value; } | ||
public bool Is<T>() | ||
where T : AvroSchema | ||
{ | ||
return this.schema is T; | ||
} | ||
|
||
public Type GetSchemaType() | ||
{ | ||
return this.schema.GetType(); | ||
} | ||
|
||
public bool UnresolvedReference { get => this.schema.UnresolvedReference; set => this.schema.UnresolvedReference = value; } | ||
|
||
public AsyncApiReference Reference { get => this.Schema.Reference; set => this.Schema.Reference = value; } | ||
public AsyncApiReference Reference { get => this.schema.Reference; set => this.schema.Reference = value; } | ||
|
||
public void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
|
@@ -47,7 +60,7 @@ public void SerializeV2(IAsyncApiWriter writer) | |
|
||
public void SerializeV2WithoutReference(IAsyncApiWriter writer) | ||
{ | ||
this.Schema.SerializeV2(writer); | ||
this.schema.SerializeV2(writer); | ||
} | ||
} | ||
} |
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