diff options
author | sr55 <[email protected]> | 2012-11-27 16:32:13 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-11-27 16:32:13 +0000 |
commit | f93ce617afdba769738f8be17e3f80391231b822 (patch) | |
tree | c5a73207ada9cba874c5f36d16bb534f3cf3fa44 /win/CS/HandBrake.ApplicationServices/Services | |
parent | 2c09426fd20474250645429d4526c1191f6a8cf4 (diff) |
WinGui: General code tidy-up and fix a couple of possible points that could throw exceptions.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5083 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Services/PresetService.cs | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs index 9e31173ae..5edfb4e1e 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs @@ -19,8 +19,6 @@ namespace HandBrake.ApplicationServices.Services using System.Text.RegularExpressions;
using System.Xml.Serialization;
- using Caliburn.Micro;
-
using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -32,13 +30,6 @@ namespace HandBrake.ApplicationServices.Services /// </summary>
public class PresetService : IPresetService
{
- /**
- * TODO:
- * - Wire this into the Forms and WPF UI's
- * - Note: This is untested so far. It'll likely need fixes before it can be used.
- * - Maybe change the collection to a dictionary to allow easier lookups?
- **/
-
#region Private Variables
/// <summary>
@@ -143,14 +134,10 @@ namespace HandBrake.ApplicationServices.Services // Update the presets file
this.UpdatePresetFiles();
return true;
- }
- else
- {
- this.Update(preset);
- return true;
}
-
- return false;
+
+ this.Update(preset);
+ return true;
}
/// <summary>
@@ -447,15 +434,16 @@ namespace HandBrake.ApplicationServices.Services {
if (File.Exists(this.builtInPresetFile))
{
- StreamReader reader = new StreamReader(this.builtInPresetFile);
- List<Preset> list = (List<Preset>)Ser.Deserialize(reader);
- foreach (Preset preset in list)
+ using (StreamReader reader = new StreamReader(this.builtInPresetFile))
{
- preset.IsBuildIn = true; // Older versions did not have this flag so explicitly make sure it is set.
- this.presets.Add(preset);
+ List<Preset> list = (List<Preset>)Ser.Deserialize(reader);
+ foreach (Preset preset in list)
+ {
+ preset.IsBuildIn = true;
+ // Older versions did not have this flag so explicitly make sure it is set.
+ this.presets.Add(preset);
+ }
}
-
- reader.Close();
}
}
catch (Exception exc)
@@ -470,14 +458,14 @@ namespace HandBrake.ApplicationServices.Services {
if (File.Exists(this.userPresetFile))
{
- StreamReader reader = new StreamReader(this.userPresetFile);
- List<Preset> list = (List<Preset>)Ser.Deserialize(reader);
- foreach (Preset preset in list)
+ using (StreamReader reader = new StreamReader(this.userPresetFile))
{
- this.presets.Add(preset);
+ List<Preset> list = (List<Preset>)Ser.Deserialize(reader);
+ foreach (Preset preset in list)
+ {
+ this.presets.Add(preset);
+ }
}
-
- reader.Close();
}
}
catch (Exception exc)
@@ -503,15 +491,11 @@ namespace HandBrake.ApplicationServices.Services using (FileStream strm = new FileStream(this.builtInPresetFile, FileMode.Create, FileAccess.Write))
{
Ser.Serialize(strm, this.presets.Where(p => p.IsBuildIn).ToList());
- strm.Close();
- strm.Dispose();
}
using (FileStream strm = new FileStream(this.userPresetFile, FileMode.Create, FileAccess.Write))
{
Ser.Serialize(strm, this.presets.Where(p => p.IsBuildIn == false).ToList());
- strm.Close();
- strm.Dispose();
}
}
catch (Exception exc)
|