示例#1
0
        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());
        }
示例#2
0
        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);
        }
示例#3
0
 private ModInfo[] ReadFromInfoFile()
 {
     return(ModInfoStruct.ToInfo(ModInfoStruct.Load(this.ReadFileText("mcmod.info")), this));
 }
示例#4
0
        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);
            }
        }