Browse Source

refactor the code

pull/818/head
LL 8 years ago
parent
commit
ce2cd4bb63
  1. 1
      ILSpy/ILSpy.csproj
  2. 6
      ILSpy/Options/MiscSettings.cs
  3. 34
      ILSpy/Options/MiscSettingsLoader.cs
  4. 25
      ILSpy/Options/MiscSettingsPanel.xaml.cs

1
ILSpy/ILSpy.csproj

@ -170,6 +170,7 @@
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Options\MiscSettings.cs" /> <Compile Include="Options\MiscSettings.cs" />
<Compile Include="Options\MiscSettingsLoader.cs" />
<Compile Include="Options\MiscSettingsPanel.xaml.cs"> <Compile Include="Options\MiscSettingsPanel.xaml.cs">
<DependentUpon>MiscSettingsPanel.xaml</DependentUpon> <DependentUpon>MiscSettingsPanel.xaml</DependentUpon>
</Compile> </Compile>

6
ILSpy/Options/MiscSettings.cs

@ -1,8 +1,4 @@
using System; using System.ComponentModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace ICSharpCode.ILSpy.Options namespace ICSharpCode.ILSpy.Options
{ {

34
ILSpy/Options/MiscSettingsLoader.cs

@ -0,0 +1,34 @@
using System.Xml.Linq;
namespace ICSharpCode.ILSpy.Options
{
public interface IMiscSettingsLoader
{
MiscSettings LoadMiscSettings(ILSpySettings settings);
}
public class MiscSettingsLoader : IMiscSettingsLoader
{
public MiscSettings LoadMiscSettings(ILSpySettings settings)
{
XElement e = settings["MiscSettings"];
MiscSettings s = new MiscSettings();
s.AllowMultipleInstances = (bool?)e.Attribute("allowMultipleInstance") ?? s.AllowMultipleInstances;
return s;
}
}
public static class MiscSettingsInstance
{
private static MiscSettingsLoader current;
public static MiscSettingsLoader Current
{
get
{
current = current ?? new MiscSettingsLoader();
return current;
}
}
}
}

25
ILSpy/Options/MiscSettingsPanel.xaml.cs

@ -1,17 +1,4 @@
using ICSharpCode.Decompiler; using System.Windows.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq; using System.Xml.Linq;
namespace ICSharpCode.ILSpy.Options namespace ICSharpCode.ILSpy.Options
@ -29,15 +16,7 @@ namespace ICSharpCode.ILSpy.Options
public void Load(ILSpySettings settings) public void Load(ILSpySettings settings)
{ {
this.DataContext = LoadDecompilerSettings(settings); this.DataContext = MiscSettingsInstance.Current.LoadMiscSettings(settings);
}
private MiscSettings LoadDecompilerSettings(ILSpySettings settings)
{
XElement e = settings["MiscSettings"];
MiscSettings s = new MiscSettings();
s.AllowMultipleInstances = (bool?)e.Attribute("allowMultipleInstance") ?? s.AllowMultipleInstances;
return s;
} }
public void Save(XElement root) public void Save(XElement root)

Loading…
Cancel
Save