예제 #1
0
 /// <summary>
 /// Deletes Easy Resolutions XML file.
 /// </summary>
 public static void Delete(this XmlFile xmlFile)
 {
     try
     {
         var path = XmlFileHelper.GetFilePathForDelete();
         File.Delete(path);
         if (File.Exists(path))
         {
             Log.Warning(string.Format("Failed to delete availbale Easy Resolutions XML file ('{0}').", path));
         }
         else
         {
             Log.Info(string.Format("Availbale Easy Resolutions XML file ('{0}') was deleted.", path));
         }
     }
     catch (System.Exception ex)
     {
         if (ex is IOException ||
             ex is PathTooLongException ||
             ex is DirectoryNotFoundException ||
             ex is System.NotSupportedException ||
             ex is System.UnauthorizedAccessException ||
             ex is System.FormatException ||
             ex is System.ArgumentException ||
             ex is System.InvalidOperationException)
         {
             Log.Warning(string.Format("Failed to delete availbale Easy Resolutions XML file.\nException: {0}", ex.Message));
         }
         else
         {
             throw;
         }
     }
 }
예제 #2
0
        /// <summary>
        /// Saves the specified <see cref="System.Xml.Linq.XElement"/>
        /// to Easy Resolutions XML file.
        /// </summary>
        /// <param name="xmlFile"><see cref="EasyResolutions.XmlFile"/> object.</param>
        /// <param name="xml"><see cref="System.Xml.Linq.XElement"/>  to save.</param>
        /// <returns><c>true</c> on success, <c>false</c> on failure.</returns>
        public static bool Save(this XmlFile xmlFile, XElement xml)
        {
            try
            {
                var path = XmlFileHelper.GetFilePathForSave();
                xml.Save(path);
                AssetDatabase.ImportAsset(XmlFileHelper.GetRelativeFilePathForSave());
                Log.Info(string.Format("Availbale scenes and resolutions were written to '{0}'.", path));
                return(true);
            }
            catch (System.Exception ex)
            {
                if (ex is IOException ||
                    ex is PathTooLongException ||
                    ex is DirectoryNotFoundException ||
                    ex is System.NotSupportedException ||
                    ex is System.UnauthorizedAccessException ||
                    ex is System.FormatException ||
                    ex is System.ArgumentException ||
                    ex is System.InvalidOperationException ||
                    ex is XmlException)
                {
                    Log.Warning(string.Format("Failed to write availbale scenes and resolutions to file.\nException: {0}", ex.Message));
                    return(false);
                }

                throw;
            }
        }