scripts
This commit is contained in:
@@ -0,0 +1,233 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Google.Protobuf.Reflection
|
||||
{
|
||||
// Token: 0x0200005E RID: 94
|
||||
public sealed class FileDescriptor : IDescriptor
|
||||
{
|
||||
// Token: 0x06000599 RID: 1433 RVA: 0x0001407C File Offset: 0x0001227C
|
||||
private FileDescriptor(ByteString descriptorData, FileDescriptorProto proto, FileDescriptor[] dependencies, DescriptorPool pool, bool allowUnknownDependencies, GeneratedClrTypeInfo generatedCodeInfo)
|
||||
{
|
||||
FileDescriptor <>4__this = this;
|
||||
this.SerializedData = descriptorData;
|
||||
this.DescriptorPool = pool;
|
||||
this.Proto = proto;
|
||||
this.Dependencies = new ReadOnlyCollection<FileDescriptor>((FileDescriptor[])dependencies.Clone());
|
||||
this.PublicDependencies = FileDescriptor.DeterminePublicDependencies(this, proto, dependencies, allowUnknownDependencies);
|
||||
pool.AddPackage(this.Package, this);
|
||||
this.MessageTypes = DescriptorUtil.ConvertAndMakeReadOnly<DescriptorProto, MessageDescriptor>(proto.MessageType, (DescriptorProto message, int index) => new MessageDescriptor(message, <>4__this, null, index, generatedCodeInfo.NestedTypes[index]));
|
||||
this.EnumTypes = DescriptorUtil.ConvertAndMakeReadOnly<EnumDescriptorProto, EnumDescriptor>(proto.EnumType, (EnumDescriptorProto enumType, int index) => new EnumDescriptor(enumType, <>4__this, null, index, generatedCodeInfo.NestedEnums[index]));
|
||||
this.Services = DescriptorUtil.ConvertAndMakeReadOnly<ServiceDescriptorProto, ServiceDescriptor>(proto.Service, (ServiceDescriptorProto service, int index) => new ServiceDescriptor(service, this, index));
|
||||
}
|
||||
|
||||
// Token: 0x0600059A RID: 1434 RVA: 0x00014145 File Offset: 0x00012345
|
||||
internal string ComputeFullName(MessageDescriptor parent, string name)
|
||||
{
|
||||
if (parent != null)
|
||||
{
|
||||
return parent.FullName + "." + name;
|
||||
}
|
||||
if (this.Package.Length > 0)
|
||||
{
|
||||
return this.Package + "." + name;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
// Token: 0x0600059B RID: 1435 RVA: 0x00014180 File Offset: 0x00012380
|
||||
private static IList<FileDescriptor> DeterminePublicDependencies(FileDescriptor @this, FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies)
|
||||
{
|
||||
Dictionary<string, FileDescriptor> dictionary = new Dictionary<string, FileDescriptor>();
|
||||
foreach (FileDescriptor fileDescriptor in dependencies)
|
||||
{
|
||||
dictionary[fileDescriptor.Name] = fileDescriptor;
|
||||
}
|
||||
List<FileDescriptor> list = new List<FileDescriptor>();
|
||||
for (int j = 0; j < proto.PublicDependency.Count; j++)
|
||||
{
|
||||
int num = proto.PublicDependency[j];
|
||||
if (num < 0 || num >= proto.Dependency.Count)
|
||||
{
|
||||
throw new DescriptorValidationException(@this, "Invalid public dependency index.");
|
||||
}
|
||||
string text = proto.Dependency[num];
|
||||
FileDescriptor fileDescriptor2 = dictionary[text];
|
||||
if (fileDescriptor2 == null)
|
||||
{
|
||||
if (!allowUnknownDependencies)
|
||||
{
|
||||
throw new DescriptorValidationException(@this, "Invalid public dependency: " + text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(fileDescriptor2);
|
||||
}
|
||||
}
|
||||
return new ReadOnlyCollection<FileDescriptor>(list);
|
||||
}
|
||||
|
||||
// Token: 0x1700017F RID: 383
|
||||
// (get) Token: 0x0600059C RID: 1436 RVA: 0x00014247 File Offset: 0x00012447
|
||||
internal FileDescriptorProto Proto { get; }
|
||||
|
||||
// Token: 0x17000180 RID: 384
|
||||
// (get) Token: 0x0600059D RID: 1437 RVA: 0x0001424F File Offset: 0x0001244F
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Proto.Name;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000181 RID: 385
|
||||
// (get) Token: 0x0600059E RID: 1438 RVA: 0x0001425C File Offset: 0x0001245C
|
||||
public string Package
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Proto.Package;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000182 RID: 386
|
||||
// (get) Token: 0x0600059F RID: 1439 RVA: 0x00014269 File Offset: 0x00012469
|
||||
public IList<MessageDescriptor> MessageTypes { get; }
|
||||
|
||||
// Token: 0x17000183 RID: 387
|
||||
// (get) Token: 0x060005A0 RID: 1440 RVA: 0x00014271 File Offset: 0x00012471
|
||||
public IList<EnumDescriptor> EnumTypes { get; }
|
||||
|
||||
// Token: 0x17000184 RID: 388
|
||||
// (get) Token: 0x060005A1 RID: 1441 RVA: 0x00014279 File Offset: 0x00012479
|
||||
public IList<ServiceDescriptor> Services { get; }
|
||||
|
||||
// Token: 0x17000185 RID: 389
|
||||
// (get) Token: 0x060005A2 RID: 1442 RVA: 0x00014281 File Offset: 0x00012481
|
||||
public IList<FileDescriptor> Dependencies { get; }
|
||||
|
||||
// Token: 0x17000186 RID: 390
|
||||
// (get) Token: 0x060005A3 RID: 1443 RVA: 0x00014289 File Offset: 0x00012489
|
||||
public IList<FileDescriptor> PublicDependencies { get; }
|
||||
|
||||
// Token: 0x17000187 RID: 391
|
||||
// (get) Token: 0x060005A4 RID: 1444 RVA: 0x00014291 File Offset: 0x00012491
|
||||
public ByteString SerializedData { get; }
|
||||
|
||||
// Token: 0x17000188 RID: 392
|
||||
// (get) Token: 0x060005A5 RID: 1445 RVA: 0x00014299 File Offset: 0x00012499
|
||||
string IDescriptor.FullName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000189 RID: 393
|
||||
// (get) Token: 0x060005A6 RID: 1446 RVA: 0x000142A1 File Offset: 0x000124A1
|
||||
FileDescriptor IDescriptor.File
|
||||
{
|
||||
get
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018A RID: 394
|
||||
// (get) Token: 0x060005A7 RID: 1447 RVA: 0x000142A4 File Offset: 0x000124A4
|
||||
internal DescriptorPool DescriptorPool { get; }
|
||||
|
||||
// Token: 0x060005A8 RID: 1448 RVA: 0x000142AC File Offset: 0x000124AC
|
||||
public T FindTypeByName<T>(string name) where T : class, IDescriptor
|
||||
{
|
||||
if (name.IndexOf('.') != -1)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
if (this.Package.Length > 0)
|
||||
{
|
||||
name = this.Package + "." + name;
|
||||
}
|
||||
T t = this.DescriptorPool.FindSymbol<T>(name);
|
||||
if (t != null && t.File == this)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
// Token: 0x060005A9 RID: 1449 RVA: 0x00014320 File Offset: 0x00012520
|
||||
private static FileDescriptor BuildFrom(ByteString descriptorData, FileDescriptorProto proto, FileDescriptor[] dependencies, bool allowUnknownDependencies, GeneratedClrTypeInfo generatedCodeInfo)
|
||||
{
|
||||
if (dependencies == null)
|
||||
{
|
||||
dependencies = new FileDescriptor[0];
|
||||
}
|
||||
DescriptorPool descriptorPool = new DescriptorPool(dependencies);
|
||||
FileDescriptor fileDescriptor = new FileDescriptor(descriptorData, proto, dependencies, descriptorPool, allowUnknownDependencies, generatedCodeInfo);
|
||||
if (dependencies.Length != proto.Dependency.Count)
|
||||
{
|
||||
throw new DescriptorValidationException(fileDescriptor, "Dependencies passed to FileDescriptor.BuildFrom() don't match those listed in the FileDescriptorProto.");
|
||||
}
|
||||
fileDescriptor.CrossLink();
|
||||
return fileDescriptor;
|
||||
}
|
||||
|
||||
// Token: 0x060005AA RID: 1450 RVA: 0x00014370 File Offset: 0x00012570
|
||||
private void CrossLink()
|
||||
{
|
||||
foreach (MessageDescriptor messageDescriptor in this.MessageTypes)
|
||||
{
|
||||
messageDescriptor.CrossLink();
|
||||
}
|
||||
foreach (ServiceDescriptor serviceDescriptor in this.Services)
|
||||
{
|
||||
serviceDescriptor.CrossLink();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005AB RID: 1451 RVA: 0x000143F4 File Offset: 0x000125F4
|
||||
public static FileDescriptor FromGeneratedCode(byte[] descriptorData, FileDescriptor[] dependencies, GeneratedClrTypeInfo generatedCodeInfo)
|
||||
{
|
||||
FileDescriptorProto fileDescriptorProto;
|
||||
try
|
||||
{
|
||||
fileDescriptorProto = FileDescriptorProto.Parser.ParseFrom(descriptorData);
|
||||
}
|
||||
catch (InvalidProtocolBufferException ex)
|
||||
{
|
||||
throw new ArgumentException("Failed to parse protocol buffer descriptor for generated code.", ex);
|
||||
}
|
||||
FileDescriptor fileDescriptor;
|
||||
try
|
||||
{
|
||||
fileDescriptor = FileDescriptor.BuildFrom(ByteString.CopyFrom(descriptorData), fileDescriptorProto, dependencies, true, generatedCodeInfo);
|
||||
}
|
||||
catch (DescriptorValidationException ex2)
|
||||
{
|
||||
throw new ArgumentException(string.Format("Invalid embedded descriptor for \"{0}\".", fileDescriptorProto.Name), ex2);
|
||||
}
|
||||
return fileDescriptor;
|
||||
}
|
||||
|
||||
// Token: 0x060005AC RID: 1452 RVA: 0x00014464 File Offset: 0x00012664
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("FileDescriptor for {0}", this.Name);
|
||||
}
|
||||
|
||||
// Token: 0x1700018B RID: 395
|
||||
// (get) Token: 0x060005AD RID: 1453 RVA: 0x00014476 File Offset: 0x00012676
|
||||
public static FileDescriptor DescriptorProtoFileDescriptor
|
||||
{
|
||||
get
|
||||
{
|
||||
return DescriptorReflection.Descriptor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user