|
@@ -38,7 +38,7 @@ using System.Linq;
|
|
|
namespace Google.Protobuf
|
|
|
{
|
|
|
/// <summary>
|
|
|
- /// Provides extensions to messages while parsing
|
|
|
+ /// Provides extensions to messages while parsing. This API is experimental and subject to change.
|
|
|
/// </summary>
|
|
|
public sealed class ExtensionRegistry : ICollection<Extension>, IDeepCloneable<ExtensionRegistry>
|
|
|
{
|
|
@@ -67,9 +67,9 @@ namespace Google.Protobuf
|
|
|
/// </summary>
|
|
|
bool ICollection<Extension>.IsReadOnly => false;
|
|
|
|
|
|
- internal bool ContainsInputField(CodedInputStream stream, Type target, out Extension extension)
|
|
|
- {
|
|
|
- return extensions.TryGetValue(new ObjectIntPair<Type>(target, WireFormat.GetTagFieldNumber(stream.LastTag)), out extension);
|
|
|
+ internal bool ContainsInputField(CodedInputStream stream, Type target, out Extension extension)
|
|
|
+ {
|
|
|
+ return extensions.TryGetValue(new ObjectIntPair<Type>(target, WireFormat.GetTagFieldNumber(stream.LastTag)), out extension);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -82,24 +82,14 @@ namespace Google.Protobuf
|
|
|
extensions.Add(new ObjectIntPair<Type>(extension.TargetType, extension.FieldNumber), extension);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Adds the specified extensions to the registry
|
|
|
- /// </summary>
|
|
|
- public void Add(params Extension[] newExtensions)
|
|
|
- {
|
|
|
- ProtoPreconditions.CheckNotNull(newExtensions, nameof(newExtensions));
|
|
|
-
|
|
|
- Add((IEnumerable<Extension>)newExtensions);
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// Adds the specified extensions to the reigstry
|
|
|
/// </summary>
|
|
|
- public void Add(IEnumerable<Extension> newExtensions)
|
|
|
+ public void AddRange(IEnumerable<Extension> extensions)
|
|
|
{
|
|
|
- ProtoPreconditions.CheckNotNull(newExtensions, nameof(newExtensions));
|
|
|
+ ProtoPreconditions.CheckNotNull(extensions, nameof(extensions));
|
|
|
|
|
|
- foreach (var extension in newExtensions)
|
|
|
+ foreach (var extension in extensions)
|
|
|
Add(extension);
|
|
|
}
|
|
|
|
|
@@ -134,10 +124,10 @@ namespace Google.Protobuf
|
|
|
if (array.Length - arrayIndex < Count)
|
|
|
throw new ArgumentException("The provided array is shorter than the number of elements in the registry");
|
|
|
|
|
|
- for (int i = 0; i < array.Length; i++)
|
|
|
- {
|
|
|
- Extension extension = array[i];
|
|
|
- extensions.Add(new ObjectIntPair<Type>(extension.TargetType, extension.FieldNumber), extension);
|
|
|
+ for (int i = 0; i < array.Length; i++)
|
|
|
+ {
|
|
|
+ Extension extension = array[i];
|
|
|
+ extensions.Add(new ObjectIntPair<Type>(extension.TargetType, extension.FieldNumber), extension);
|
|
|
}
|
|
|
}
|
|
|
|