You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.2 KiB
86 lines
2.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ProtoCSStruct
|
|
{
|
|
public class ProtoDescriptor
|
|
{
|
|
public string ProtoFile;
|
|
public string NameSpace;
|
|
public string OutPutPath;
|
|
public string OutPutFile;
|
|
public string EnumOutPutFile;
|
|
public string ClassOutPutFile;
|
|
|
|
public List<ProtoEnum> Enums;
|
|
public Dictionary<string, ProtoEnum> EnumsMap;
|
|
|
|
public List<ProtoMessage> Messages;
|
|
public Dictionary<string, ProtoMessage> MessagesMap;
|
|
|
|
public Dictionary<string, ProtoMessage> MessagesMapNeedClassDesc;
|
|
|
|
public ProtoDescriptor()
|
|
{
|
|
Enums = new List<ProtoEnum>();
|
|
EnumsMap = new Dictionary<string, ProtoEnum>();
|
|
Messages = new List<ProtoMessage>();
|
|
MessagesMap = new Dictionary<string, ProtoMessage>();
|
|
MessagesMapNeedClassDesc = new Dictionary<string, ProtoMessage>();
|
|
}
|
|
|
|
|
|
public ProtoEnum GetEnumByName(string name)
|
|
{
|
|
if(EnumsMap.ContainsKey(name))
|
|
{
|
|
return EnumsMap[name];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public ProtoMessage GetMessageByName(string name)
|
|
{
|
|
if (MessagesMap.ContainsKey(name))
|
|
{
|
|
return MessagesMap[name];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public class ProtoDescriptorAll : Singleton<ProtoDescriptorAll>
|
|
{
|
|
public List<ProtoDescriptor> AllProtoDescriptor = new List<ProtoDescriptor>();
|
|
|
|
public ProtoEnum GetEnumByName(string name)
|
|
{
|
|
foreach (var pd in AllProtoDescriptor)
|
|
{
|
|
var protoenum = pd.GetEnumByName(name);
|
|
if (protoenum != null)
|
|
{
|
|
return protoenum;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public ProtoMessage GetMessageByName(string name)
|
|
{
|
|
foreach (var pd in AllProtoDescriptor)
|
|
{
|
|
var message = pd.GetMessageByName(name);
|
|
if (message != null)
|
|
{
|
|
return message;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|