-
Notifications
You must be signed in to change notification settings - Fork 20
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
fedf798
commit 6816cd1
Showing
13 changed files
with
312 additions
and
82 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
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 |
---|---|---|
|
@@ -3,39 +3,17 @@ | |
namespace LEGO.AsyncAPI.Models | ||
{ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using LEGO.AsyncAPI.Models.Interfaces; | ||
using LEGO.AsyncAPI.Writers; | ||
|
||
public class AsyncApiBindings<TBinding> : Dictionary<string, TBinding>, IAsyncApiReferenceable | ||
public class AsyncApiBindings<TBinding> : IDictionary<string, TBinding>, IAsyncApiSerializable | ||
where TBinding : IBinding | ||
{ | ||
public bool UnresolvedReference { get; set; } | ||
private Dictionary<string, TBinding> inner = new Dictionary<string, TBinding>(); | ||
|
||
public AsyncApiReference Reference { get; set; } | ||
|
||
public void Add(TBinding binding) | ||
{ | ||
this[binding.BindingKey] = binding; | ||
} | ||
|
||
public void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
if (writer is null) | ||
{ | ||
throw new ArgumentNullException(nameof(writer)); | ||
} | ||
|
||
if (this.Reference != null && !writer.GetSettings().ShouldInlineReference(this.Reference)) | ||
{ | ||
this.Reference.SerializeV2(writer); | ||
return; | ||
} | ||
|
||
this.SerializeV2WithoutReference(writer); | ||
} | ||
|
||
public void SerializeV2WithoutReference(IAsyncApiWriter writer) | ||
public virtual void SerializeV2(IAsyncApiWriter writer) | ||
{ | ||
if (writer is null) | ||
{ | ||
|
@@ -56,5 +34,79 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer) | |
|
||
writer.WriteEndObject(); | ||
} | ||
|
||
public virtual void Add(TBinding binding) | ||
{ | ||
this[binding.BindingKey] = binding; | ||
} | ||
|
||
public virtual TBinding this[string key] | ||
Check warning on line 43 in src/LEGO.AsyncAPI/Models/AsyncApiBindings{TBinding}.cs
|
||
{ | ||
get => inner[key]; | ||
set => inner[key] = value; | ||
} | ||
|
||
public virtual ICollection<string> Keys => inner.Keys; | ||
|
||
public virtual ICollection<TBinding> Values => inner.Values; | ||
|
||
public virtual int Count => inner.Count; | ||
|
||
public virtual bool IsReadOnly => ((IDictionary<string, TBinding>)inner).IsReadOnly; | ||
|
||
public virtual void Add(string key, TBinding value) | ||
{ | ||
inner.Add(key, value); | ||
} | ||
|
||
public virtual bool ContainsKey(string key) | ||
{ | ||
return inner.ContainsKey(key); | ||
} | ||
|
||
public virtual bool Remove(string key) | ||
{ | ||
return inner.Remove(key); | ||
} | ||
|
||
public virtual bool TryGetValue(string key, out TBinding value) | ||
{ | ||
return inner.TryGetValue(key, out value); | ||
} | ||
|
||
public virtual void Add(KeyValuePair<string, TBinding> item) | ||
{ | ||
((IDictionary<string, TBinding>)inner).Add(item); | ||
} | ||
|
||
public virtual void Clear() | ||
{ | ||
inner.Clear(); | ||
} | ||
|
||
public virtual bool Contains(KeyValuePair<string, TBinding> item) | ||
{ | ||
return ((IDictionary<string, TBinding>)inner).Contains(item); | ||
} | ||
|
||
public virtual void CopyTo(KeyValuePair<string, TBinding>[] array, int arrayIndex) | ||
{ | ||
((IDictionary<string, TBinding>)inner).CopyTo(array, arrayIndex); | ||
} | ||
|
||
public virtual bool Remove(KeyValuePair<string, TBinding> item) | ||
{ | ||
return ((IDictionary<string, TBinding>)inner).Remove(item); | ||
} | ||
|
||
public virtual IEnumerator<KeyValuePair<string, TBinding>> GetEnumerator() | ||
{ | ||
return inner.GetEnumerator(); | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() | ||
{ | ||
return inner.GetEnumerator(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.