aboutsummaryrefslogtreecommitdiff
path: root/csharp/ProtocolBuffers/Descriptors/FileDescriptor.cs
blob: d552d2f0a3f0338071ac849a4368777730a91d58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using Google.ProtocolBuffers.DescriptorProtos;
using System.Collections.Generic;
namespace Google.ProtocolBuffers.Descriptors {
  public class FileDescriptor : DescriptorBase<FileDescriptorProto, FileOptions> {

    private readonly IList<MessageDescriptor> messageTypes;
    private readonly IList<EnumDescriptor> enumTypes;
    private readonly IList<ServiceDescriptor> services;
    private readonly IList<FieldDescriptor> extensions;
    private readonly IList<FileDescriptor> dependencies;
    private readonly DescriptorPool pool;

    public FileDescriptor(FileDescriptorProto proto, FileDescriptor file) : base(proto, file) {
    }

    /// <summary>
    /// The package as declared in the .proto file. This may or may not
    /// be equivalent to the .NET namespace of the generated classes.
    /// </summary>
    public string Package {
      get { return Proto.Package; }
    }

    /// <value>
    /// Unmodifiable list of top-level message types declared in this file.
    /// </value>
    public IList<MessageDescriptor> MessageTypes {
      get { return messageTypes; }
    }

    /// <value>
    /// Unmodifiable list of top-level enum types declared in this file.
    /// </value>
    public IList<EnumDescriptor> EnumTypes {
      get { return enumTypes; }
    }

    /// <value>
    /// Unmodifiable list of top-level services declared in this file.
    /// </value>
    public IList<ServiceDescriptor> Services {
      get { return services; }
    }

    /// <value>
    /// Unmodifiable list of top-level extensions declared in this file.
    /// </value>
    public IList<FieldDescriptor> Extensions {
      get { return extensions; }
    }

    /// <value>
    /// Unmodifiable list of this file's dependencies (imports).
    /// </value>
    public IList<FileDescriptor> Dependencies {
      get { return dependencies; }
    }

    public static FileDescriptor BuildFrom(FileDescriptorProto proto,
        FileDescriptor[] dependencies) {
      throw new NotImplementedException();
    }
    /// <summary>
    /// This method is to be called by generated code only.  It is equivalent
    /// to BuilderFrom except that the FileDescriptorProto is encoded in
    /// protocol buffer wire format.
    /// </summary>
    public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData,
        FileDescriptor[] dependencies) {
      FileDescriptorProto proto = FileDescriptorProto.ParseFrom(descriptorData);
      return BuildFrom(proto, dependencies);      
    }
  }
}