Esempio n. 1
0
        public static AssetManifest LoadFromString(string pText, out string pErrorText)
        {
            pErrorText = null;
            if (string.IsNullOrEmpty(pText = pText?.Trim()))
            {
                pErrorText = "AssetManifest.LoadFromString(): No input text";
                return(null);
            }

            AssetManifest assetManifest = new AssetManifest();

            try
            {
                XmlSerializer serializer = new XmlSerializer(assetManifest.GetType());
                using (TextReader reader = new StringReader(pText))
                {
                    assetManifest = (AssetManifest)serializer.Deserialize(reader);
                    reader.Close();
                }
            }
            catch (Exception exception)
            {
                pErrorText    = $"EXCEPTION while deserializing AssetManifest: {exception.Message} - {exception.InnerException?.Message}";
                assetManifest = null;
            }

            return(assetManifest);
        }
Esempio n. 2
0
        public static AssetManifest Load(string pFilename, out string pErrorText)
        {
            pErrorText = null;
            if (!File.Exists(pFilename))
            {
                pErrorText = "AssetManifest.Load(): File not found";
                return(null);
            }

            AssetManifest assetManifest = new AssetManifest();

            try
            {
                XmlSerializer serializer = new XmlSerializer(assetManifest.GetType());
                using (StreamReader reader = new StreamReader(pFilename))
                {
                    assetManifest = (AssetManifest)serializer.Deserialize(reader);
                    reader.Close();
                }
            }
            catch (Exception exception)
            {
                pErrorText    = $"EXCEPTION while deserializing AssetManifest: {exception.Message} - {exception.InnerException?.Message}";
                assetManifest = null;
            }

            return(assetManifest);
        }