// Token: 0x06000E4F RID: 3663 RVA: 0x00060C88 File Offset: 0x0005EE88
        public static T Deserialize <T>(string content, bool validate, string fileName, int lineOffset, Type serializerType = null) where T : Element
        {
            T result;

            try
            {
                XmlSerializer serializer;
                if (serializerType == null)
                {
                    serializer = new XmlSerializer(typeof(T));
                }
                else
                {
                    serializer = new XmlSerializer(serializerType);
                }
                XDocument xDoc = XDocument.Load(new StringReader(content), LoadOptions.SetLineInfo);
                result = ModXmlLoader.Deserialize <T>(xDoc, serializer, validate, fileName, lineOffset);
            }
            catch (Exception ex)
            {
                Assemblies.MLog.Error("Error loading mod XML file: " + fileName);
                Assemblies.MLog.Error(ex.ToString());
                result = (T)((object)null);
            }
            return(result);
        }
        // Token: 0x06000E50 RID: 3664 RVA: 0x00060D28 File Offset: 0x0005EF28
        private static T Deserialize <T>(XDocument xDoc, XmlSerializer serializer, bool validate, string fileName, int lineOffset) where T : Element
        {
            ModXmlLoader.PreProcess(xDoc.Root, fileName, lineOffset);
            serializer.UnknownNode += delegate(object sender, XmlNodeEventArgs args)
            {
                if (args.Text == ">")
                {
                    Assemblies.MLog.WarnFormat("In {0}: There appears to be an extraneous '>' character somewhere in the file.This can cause deserialization of some elements to silently fail!", new object[]
                    {
                        fileName
                    });
                }
            };
            T t = (T)((object)serializer.Deserialize(xDoc.CreateReader()));

            if (t == null)
            {
                return((T)((object)null));
            }
            if (validate && !t.InvokeValidate())
            {
                Assemblies.MLog.Error("Error loading " + fileName);
                return((T)((object)null));
            }
            return(t);
        }
        // Token: 0x06000E4E RID: 3662 RVA: 0x00060B84 File Offset: 0x0005ED84
        public static T Deserialize <T>(string path, bool validate) where T : Element
        {
            T result;

            try
            {
                using (FileStream fileStream = new FileStream(path, FileMode.Open))
                {
                    using (StreamReader streamReader = new StreamReader(fileStream))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(T));
                        XDocument     xDoc       = XDocument.Load(streamReader, LoadOptions.SetLineInfo);
                        string        name       = new FileInfo(path).Name;
                        result = ModXmlLoader.Deserialize <T>(xDoc, serializer, validate, name, 0);
                    }
                }
            }
            catch (Exception ex)
            {
                Assemblies.MLog.Error("Error loading mod XML file: " + new FileInfo(path).Name);
                Assemblies.MLog.Error(ex.ToString());
                result = (T)((object)null);
            }
            return(result);
        }
 // Token: 0x06000E51 RID: 3665 RVA: 0x00060DC0 File Offset: 0x0005EFC0
 private static void PreProcess(XElement element, string fileName, int lineOffset = 0)
 {
     string[] array = (from a in element.Attributes()
                       select a.Name.LocalName).ToArray <string>();
     string[] array2 = (from e in element.Elements()
                        select e.Name.LocalName).ToArray <string>();
     if (!string.IsNullOrEmpty(element.Value))
     {
         if (element.Value == "True")
         {
             element.Value = "true";
         }
         else if (element.Value == "False")
         {
             element.Value = "false";
         }
         string text = element.Value.TrimStart(new char[]
         {
             '\n',
             '\r'
         }).TrimEnd(new char[0]);
         if (text != element.Value)
         {
             element.Value = text;
         }
     }
     foreach (XAttribute xattribute in element.Attributes())
     {
         if (xattribute.Value == "True")
         {
             xattribute.Value = "true";
         }
         else if (xattribute.Value == "False")
         {
             element.Value = "false";
         }
     }
     foreach (XElement element2 in element.Elements())
     {
         ModXmlLoader.PreProcess(element2, fileName, lineOffset);
     }
     element.SetAttributeValue("lineNumber", ((IXmlLineInfo)element).LineNumber + lineOffset);
     element.SetAttributeValue("linePosition", ((IXmlLineInfo)element).LinePosition);
     element.SetAttributeValue("fileName", fileName);
     if (array2.Length > 0)
     {
         element.SetAttributeValue("elementsUsed", string.Join("|", array2));
     }
     if (array.Length > 0)
     {
         element.SetAttributeValue("attributesUsed", string.Join("|", array));
     }
 }
        // Token: 0x0600100B RID: 4107 RVA: 0x0006883C File Offset: 0x00066A3C
        public static ModInfo LoadFromFile(string path, bool debugInfo)
        {
            ModInfo modInfo = ModXmlLoader.Deserialize <ModInfo>(path, false);

            if (modInfo == null)
            {
                InternalModding.Assemblies.MLog.Error("Could not load " + new FileInfo(path));
                return(null);
            }
            modInfo.Directory = new FileInfo(path).Directory.FullName;
            for (int i = 0; i < modInfo.Events.Count; i++)
            {
                ModInfo.EventInfo eventInfo = modInfo.Events[i];
                if (!eventInfo.Validate("Event"))
                {
                    InternalModding.Assemblies.MLog.Error("Not loading the mod manifest.");
                    return(null);
                }
                if (!string.IsNullOrEmpty(eventInfo.Path))
                {
                    modInfo.Events[i] = ModXmlLoader.Deserialize <ModInfo.EventInfo>(ModPaths.GetFilePath(modInfo, eventInfo.Path, false), false);
                    if (modInfo.Events[i] == null)
                    {
                        InternalModding.Assemblies.MLog.Error("Not loading the mod manifest.");
                        return(null);
                    }
                }
            }
            foreach (ModInfo.EventInfo eventInfo2 in modInfo.Events)
            {
                //eventInfo2.CreateProperties();
            }
            if (modInfo.IdFromFileSpecified)
            {
                modInfo.Id = new Guid(modInfo.IdFromFile);
            }
            else
            {
                modInfo.Id = Guid.NewGuid();
                InternalModding.Assemblies.MLog.Info(string.Concat(new object[]
                {
                    "Generated an ID for ",
                    modInfo.Name,
                    " (",
                    modInfo.Id,
                    "), writing it to the file."
                }));
                ModInfo.WriteIdElement(modInfo);
            }
            if (!modInfo.Validate())
            {
                InternalModding.Assemblies.MLog.Error("There was an error loading the mod manifest: " + path);
                return(null);
            }
            modInfo.Description = modInfo.Description.Trim();
            foreach (ModInfo.AssemblyInfo assemblyInfo in modInfo.Assemblies)
            {
                assemblyInfo.Path = ModPaths.GetFilePath(modInfo, assemblyInfo.Path, false);
            }
            foreach (ModInfo.BlockInfo blockInfo in modInfo.Blocks)
            {
                blockInfo.Path = ModPaths.GetFilePath(modInfo, blockInfo.Path, false);
            }
            foreach (ModInfo.EntityInfo entityInfo in modInfo.Entities)
            {
                entityInfo.Path = ModPaths.GetFilePath(modInfo, entityInfo.Path, false);
            }
            if (modInfo.ResourceChoices.Resources == null)
            {
                modInfo.ResourceChoices.Resources = new ModInfo.ResourceInfo[0];
                //modInfo.ResourceChoices.ResourceTypes = new ModResource.ResourceType[0];
            }
            for (int j = 0; j < modInfo.ResourceChoices.Resources.Length; j++)
            {
                ModInfo.ResourceInfo resourceInfo = modInfo.ResourceChoices.Resources[j];
                resourceInfo.Path = ModPaths.GetFilePath(modInfo, resourceInfo.Path, true);
                //resourceInfo.Type = modInfo.ResourceChoices.ResourceTypes[j];
            }
            return(modInfo);
        }