using System; using System.Collections.Generic; using System.Text; using Google.ProtocolBuffers.DescriptorProtos; namespace Google.ProtocolBuffers.Descriptors { /// /// Describes a service type. /// public class ServiceDescriptor : IndexedDescriptorBase { private readonly IList methods; public ServiceDescriptor(ServiceDescriptorProto proto, FileDescriptor file, int index) : base(proto, file, ComputeFullName(file, null, proto.Name), index) { methods = DescriptorUtil.ConvertAndMakeReadOnly(proto.MethodList, (method, i) => new MethodDescriptor(method, file, this, i)); file.DescriptorPool.AddSymbol(this); } /// /// An unmodifiable list of methods in this service. /// public IList Methods { get { return methods; } } /// /// Finds a method by name. /// /// The unqualified name of the method (e.g. "Foo"). /// The method's decsriptor, or null if not found. public MethodDescriptor FindMethodByName(String name) { return File.DescriptorPool.FindSymbol(FullName + "." + name); } internal void CrossLink() { foreach (MethodDescriptor method in methods) { method.CrossLink(); } } } }