private bool WriteFile(AudioInfoData audInfo) { StreamWriter writer = null; try { var sb = new StringBuilder(string.Empty); var safeFilter = audInfo.SearchFilter.Replace("'", "").Replace("\"", ""); sb.Append(string.Format("<Files searchFilter='{0}' sortColumn='{1}' sortDir='{2}'>", safeFilter, audInfo.SortColumn, audInfo.SortDir)); foreach (var aud in audInfo.AudioInfor) { var mono = aud.HasChanged ? aud.ForceMono : aud.OrigForceMono; var loadBG = aud.HasChanged ? aud.LoadBG : aud.OrigLoadBG; var preload = aud.HasChanged ? aud.Preload : aud.OrigPreload; var loadType = aud.HasChanged ? aud.LoadType : aud.OrigLoadType; var compressionFormat = aud.HasChanged ? aud.CompressionFormat : aud.OrigCompressionFormat; var quality = aud.HasChanged ? aud.Quality : aud.OrigQuality; var sampleSetting = aud.HasChanged ? aud.SampleRateSetting : aud.OrigSampleRateSetting; var sampleRate = aud.HasChanged ? aud.SampleRateOverride : aud.OrigSampleRateOverride; sb.Append(string.Format("<File path='{0}' name='{1}' forceMono='{2}' loadBG='{3}' preload='{4}' loadType='{5}' compFormat='{6}' quality='{7}' sampleSetting='{8}' sampleRate='{9}' />", UtilStrings.ReplaceUnsafeChars(aud.FullPath), UtilStrings.ReplaceUnsafeChars(aud.Name), mono, loadBG, preload, loadType, compressionFormat, quality, sampleSetting, sampleRate)); } sb.Append("</Files>"); writer = new StreamWriter(CacheFilePath); writer.WriteLine(sb.ToString()); _clipList.AudioInfor.RemoveAll(delegate(AudioInformation obj) { return(obj.HasChanged); }); _filterClips = null; // re-generate the filtered list. } catch (Exception ex) { Debug.LogError("Error occurred constructing or writing audioImportSettings.xml file: " + ex); return(false); } finally { if (writer != null) { writer.Close(); } } return(true); }
private bool WriteFile(AudioInfoData audInfo) { StreamWriter writer = null; try { var sb = new StringBuilder(string.Empty); var safeFilter = audInfo.SearchFilter.Replace("'", "").Replace("\"", ""); sb.Append(string.Format("<Files searchFilter='{0}' sortColumn='{1}' sortDir='{2}'>", safeFilter, audInfo.SortColumn, audInfo.SortDir)); foreach (var aud in audInfo.AudioInfor) { var is3D = aud.HasChanged ? aud.Is3D : aud.OrigIs3D; var bitrate = aud.HasChanged ? aud.CompressionBitrate : aud.OrigCompressionBitrate; var mono = aud.HasChanged ? aud.ForceMono : aud.OrigForceMono; var fmt = aud.HasChanged ? aud.Format : aud.OrigFormat; var loadType = aud.HasChanged ? aud.LoadType : aud.OrigLoadType; sb.Append(string.Format("<File path='{0}' name='{1}' is3d='{2}' bitRate='{3}' forceMono='{4}' format='{5}' loadType='{6}' />", UtilStrings.ReplaceUnsafeChars(aud.FullPath), UtilStrings.ReplaceUnsafeChars(aud.Name), is3D, bitrate, mono, fmt, loadType)); } sb.Append("</Files>"); writer = new StreamWriter(CacheFilePath); writer.WriteLine(sb.ToString()); _clipList.AudioInfor.RemoveAll(delegate(AudioInformation obj) { return(obj.HasChanged); }); } catch (Exception ex) { Debug.LogError("Error occurred constructing or writing audioImportSettings.xml file: " + ex); return(false); } finally { if (writer != null) { writer.Close(); } } return(true); }
private bool WriteFile(AudioInfoData audInfo) { StreamWriter writer = null; try { var sb = new StringBuilder(string.Empty); var safeFilter = audInfo.searchFilter.Replace("'", "").Replace("\"", ""); sb.Append(string.Format("<Files searchFilter='{0}' sortColumn='{1}' sortDir='{2}'>", safeFilter, audInfo.sortColumn, audInfo.sortDir)); for (var i = 0; i < audInfo.audioInfo.Count; i++) { var aud = audInfo.audioInfo[i]; var is3d = aud._hasChanged ? aud._is3d : aud._origIs3d; var bitrate = aud._hasChanged ? aud._compressionBitrate : aud._origCompressionBitrate; var mono = aud._hasChanged ? aud._forceMono : aud._origForceMono; var fmt = aud._hasChanged ? aud._format : aud._origFormat; var loadType = aud._hasChanged ? aud._loadType : aud._origLoadType; sb.Append(string.Format("<File path='{0}' name='{1}' is3d='{2}' bitRate='{3}' forceMono='{4}' format='{5}' loadType='{6}' />", UtilStrings.ReplaceUnsafeChars(aud._fullPath), UtilStrings.ReplaceUnsafeChars(aud._name), is3d, bitrate, mono, fmt.ToString(), loadType)); } sb.Append("</Files>"); writer = new StreamWriter(CACHE_FILE_PATH); writer.WriteLine(sb.ToString()); clipList.audioInfo.RemoveAll(delegate(AudioInfo obj) { return(obj._hasChanged == true); }); } catch (Exception ex) { Debug.LogError("Error occurred constructing or writing audioImportSettings.xml file: " + ex.ToString()); return(false); } finally { writer.Close(); } return(true); }