using FishNet.CodeGenerating.Helping;
using FishNet.Object.Helping;
using MonoFN.Cecil;
using System.Collections.Generic;
namespace FishNet.CodeGenerating.Processing.Rpc
{
internal static class AttributeDataExtensions
{
///
/// Returns RpcTypes in datas.
///
public static List GetRpcTypes(this List datas)
{
//RpcTypes for originalMd.
List rpcTypes = new List();
foreach (AttributeData ad in datas)
rpcTypes.Add(ad.RpcType);
return rpcTypes;
}
///
/// Gets CustomAttribute for rpcType
///
public static CustomAttribute GetAttribute(this List datas, CodegenSession session, RpcType rpcType)
{
for (int i = 0; i < datas.Count; i++)
{
if (datas[i].RpcType == rpcType)
return datas[i].Attribute;
}
session.LogError($"RpcType {rpcType} not found in datas.");
return null;
}
///
/// Returns RpcType as flag through combining datas.
///
///
///
public static RpcType GetCombinedRpcType(this List datas)
{
RpcType result = RpcType.None;
for (int i = 0; i < datas.Count; i++)
result |= datas[i].RpcType;
return result;
}
}
internal class AttributeData
{
public readonly CustomAttribute Attribute;
public readonly RpcType RpcType;
public AttributeData(CustomAttribute attribute, RpcType rpcType)
{
Attribute = attribute;
RpcType = rpcType;
}
}
}