diff options
author | Jie Luo <anandolee@gmail.com> | 2015-04-28 16:26:19 -0700 |
---|---|---|
committer | Jie Luo <anandolee@gmail.com> | 2015-04-28 16:26:19 -0700 |
commit | 8bae6c09bc8c8be808f0acc9b2ad4c9811493060 (patch) | |
tree | 9819ef25dbe807e4e7f0d6c7dbff7f553b1a8723 /csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs | |
parent | 8a3ec53e862cffd310caf434c2c0898782c952f7 (diff) | |
parent | 32ead755d1f97e414f4a50edb7d9f1ebd9cab562 (diff) | |
download | protobuf-8bae6c09bc8c8be808f0acc9b2ad4c9811493060.tar.gz protobuf-8bae6c09bc8c8be808f0acc9b2ad4c9811493060.tar.bz2 protobuf-8bae6c09bc8c8be808f0acc9b2ad4c9811493060.zip |
Merge pull request #1 from google/csharp
Csharp update
Diffstat (limited to 'csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs')
-rw-r--r-- | csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs index ae819801..30718709 100644 --- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs +++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs @@ -50,14 +50,15 @@ namespace Google.ProtocolBuffers.Descriptors private readonly IDictionary<DescriptorIntPair, EnumValueDescriptor> enumValuesByNumber =
new Dictionary<DescriptorIntPair, EnumValueDescriptor>();
- private readonly DescriptorPool[] dependencies;
+ private readonly HashSet<FileDescriptor> dependencies;
internal DescriptorPool(FileDescriptor[] dependencyFiles)
{
- dependencies = new DescriptorPool[dependencyFiles.Length];
+ dependencies = new HashSet<FileDescriptor>();
for (int i = 0; i < dependencyFiles.Length; i++)
{
- dependencies[i] = dependencyFiles[i].DescriptorPool;
+ dependencies.Add(dependencyFiles[i]);
+ ImportPublicDependencies(dependencyFiles[i]);
}
foreach (FileDescriptor dependency in dependencyFiles)
@@ -66,6 +67,17 @@ namespace Google.ProtocolBuffers.Descriptors }
}
+ private void ImportPublicDependencies(FileDescriptor file)
+ {
+ foreach (FileDescriptor dependency in file.PublicDependencies)
+ {
+ if (dependencies.Add(dependency))
+ {
+ ImportPublicDependencies(dependency);
+ }
+ }
+ }
+
/// <summary>
/// Finds a symbol of the given name within the pool.
/// </summary>
@@ -83,9 +95,9 @@ namespace Google.ProtocolBuffers.Descriptors return descriptor;
}
- foreach (DescriptorPool dependency in dependencies)
+ foreach (FileDescriptor dependency in dependencies)
{
- dependency.descriptorsByName.TryGetValue(fullName, out result);
+ dependency.DescriptorPool.descriptorsByName.TryGetValue(fullName, out result);
descriptor = result as T;
if (descriptor != null)
{
|