public static ModInfo[] ToInfo(ModInfoStruct[] structs, Analyzer analyzer) { if (structs == null) { return(null); } List <ModInfo> list = new List <ModInfo>(); foreach (ModInfoStruct target in structs) { if (target.Structs != null) { list.AddRange(ModInfoStruct.ToInfo(target.Structs, analyzer)); } if (target.ID == null && target.Name == null) { continue; } if (target.ID == null) { target.ID = target.Name; } else if (target.Name == null) { target.Name = target.ID; } list.Add(target.ToInfo(analyzer)); } return(list.ToArray()); }
private static ModInfoStruct[] LoadArray(MemoryStream stream) { ModInfoStruct[] array = (ModInfoStruct[])ModInfoStruct.DeseralizerArray.ReadObject(stream); if (array.Length < 1) { stream.Seek(0, SeekOrigin.Begin); array = new ModInfoStruct[] { (ModInfoStruct)ModInfoStruct.Deseralizer.ReadObject(stream) }; } return(array); }
private ModInfo[] ReadFromInfoFile() { return(ModInfoStruct.ToInfo(ModInfoStruct.Load(this.ReadFileText("mcmod.info")), this)); }
public static ModInfoStruct[] Load(string json) { if (json == null) { return(null); } try { using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json))) return(ModInfoStruct.LoadArray(stream)); } catch { return(null); } }