Skip to content

Commit

Permalink
Merge pull request #3 from emoacht/develop
Browse files Browse the repository at this point in the history
Fixed exception when loading settings file
  • Loading branch information
emoacht committed Dec 1, 2015
2 parents 6be2871 + 9141018 commit 69d924a
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 31 deletions.
4 changes: 4 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
##History

Ver 1.1.2 2015-12-2

- Fixed exception when loading settings file

Ver 1.1.1 2015-11-18

- Added flyout to notification area icon
Expand Down
Binary file modified Images/Screenshot_Win10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Screenshot_Win81.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ WLAN Profile Viewer is a Windows desktop app to manage wireless LAN profiles. It

##Download

[Download](https://github.com/emoacht/WlanProfileViewer/releases/download/1.1.1/WlanProfileViewer111.zip)
[Download](https://github.com/emoacht/WlanProfileViewer/releases/download/1.1.2/WlanProfileViewer112.zip)

##Install

Expand Down
2 changes: 1 addition & 1 deletion README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ WLAN Profile Viewerは無線LANプロファイルを管理するためのWindows

##ダウンロード

[ダウンロード](https://github.com/emoacht/WlanProfileViewer/releases/download/1.1.1/WlanProfileViewer111.zip)
[ダウンロード](https://github.com/emoacht/WlanProfileViewer/releases/download/1.1.2/WlanProfileViewer112.zip)

##インストール

Expand Down
6 changes: 3 additions & 3 deletions ReactivePropertyTest/ReactivePropertyTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="ReactiveProperty, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ReactiveProperty.2.2.8\lib\net45\ReactiveProperty.dll</HintPath>
<HintPath>..\packages\ReactiveProperty.2.3\lib\net45\ReactiveProperty.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ReactiveProperty.DataAnnotations, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ReactiveProperty.2.2.8\lib\net45\ReactiveProperty.DataAnnotations.dll</HintPath>
<HintPath>..\packages\ReactiveProperty.2.3\lib\net45\ReactiveProperty.DataAnnotations.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ReactiveProperty.NET45, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ReactiveProperty.2.2.8\lib\net45\ReactiveProperty.NET45.dll</HintPath>
<HintPath>..\packages\ReactiveProperty.2.3\lib\net45\ReactiveProperty.NET45.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion ReactivePropertyTest/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ReactiveProperty" version="2.2.8" targetFramework="net452" />
<package id="ReactiveProperty" version="2.3" targetFramework="net452" />
<package id="Rx-Core" version="2.2.5" targetFramework="net452" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net452" />
<package id="Rx-Linq" version="2.2.5" targetFramework="net452" />
Expand Down
9 changes: 5 additions & 4 deletions WlanProfileViewer/Models/LanguageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ private static Dictionary<string, string> RetrieveLanguageContent(string languag
var sources = Properties.Resources.ResourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, true)
.Cast<DictionaryEntry>()
.Where(x => x.Key.ToString().StartsWith("language_")) // language_en, language_ja, etc.
.ToDictionary(x => x.Key.ToString().Substring(9), x => x.Value.ToString());
.ToDictionary(x => x.Key.ToString().Substring(9), x => x.Value.ToString()); // 9 means "language_".

var source = sources.ContainsKey(languageName)
? sources[languageName]
: sources["en"]; // language_en as fallback

return source.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => new { Index = x.IndexOf(_delimiter), Line = x })
.Where(x => (0 < x.Index) && (x.Index + 1 < x.Line.Length)) // Both key and value are not empty.
.ToDictionary(x => x.Line.Substring(0, x.Index), x => x.Line.Substring(x.Index + 1));
.Select(x => x.Split(new[] { _delimiter }, 2))
.Select(x => x.Select(y => y.Trim()).Where(y => !string.IsNullOrEmpty(y)).ToArray())
.Where(x => x.Length == 2) // Both key and value are not empty.
.ToDictionary(x => x[0], x => x[1]);
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion WlanProfileViewer/Models/LogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class LogService

public static void RecordException(object sender, Exception exception)
{
var content = string.Format("[Date: {0} Sender: {1}]", DateTime.Now, sender) + Environment.NewLine
var content = $"[Date: {DateTime.Now} Sender: {sender}]" + Environment.NewLine
+ exception + Environment.NewLine + Environment.NewLine;

RecordAppData(_exceptionFileName, content);
Expand Down
33 changes: 19 additions & 14 deletions WlanProfileViewer/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Xml;
using System.Xml.Serialization;
using static System.Math;

Expand Down Expand Up @@ -49,29 +50,33 @@ public int AutoReloadInterval

public static void Load()
{
IsLoaded = true;

if (!File.Exists(_settingsFilePath))
return;

try
{
if (File.Exists(_settingsFilePath))
using (var fs = new FileStream(_settingsFilePath, FileMode.Open, FileAccess.Read))
{
using (var fs = new FileStream(_settingsFilePath, FileMode.Open, FileAccess.Read))
{
var serializer = new XmlSerializer(typeof(Settings));
var loaded = (Settings)serializer.Deserialize(fs);

typeof(Settings)
.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
.Where(x => x.CanWrite)
.ToList()
.ForEach(x => x.SetValue(Current, x.GetValue(loaded)));
}
var serializer = new XmlSerializer(typeof(Settings));
var loaded = (Settings)serializer.Deserialize(fs);

typeof(Settings)
.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
.Where(x => x.CanWrite)
.ToList()
.ForEach(x => x.SetValue(Current, x.GetValue(loaded)));
}
}
catch (InvalidOperationException ex) when (ex.InnerException is XmlException)
{
// Ignore broken settings file.
}
catch (Exception ex)
{
throw new Exception("Failed to load settings.", ex);
}

IsLoaded = true;
}

public static void Save()
Expand Down
4 changes: 2 additions & 2 deletions WlanProfileViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.6")]
[assembly: AssemblyFileVersion("1.1.1.6")]
[assembly: AssemblyVersion("1.1.2.8")]
[assembly: AssemblyFileVersion("1.1.2.8")]
6 changes: 3 additions & 3 deletions WlanProfileViewer/WlanProfileViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
<HintPath>Library\MonitorAware.dll</HintPath>
</Reference>
<Reference Include="ReactiveProperty, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ReactiveProperty.2.2.8\lib\net45\ReactiveProperty.dll</HintPath>
<HintPath>..\packages\ReactiveProperty.2.3\lib\net45\ReactiveProperty.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ReactiveProperty.DataAnnotations, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ReactiveProperty.2.2.8\lib\net45\ReactiveProperty.DataAnnotations.dll</HintPath>
<HintPath>..\packages\ReactiveProperty.2.3\lib\net45\ReactiveProperty.DataAnnotations.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ReactiveProperty.NET45, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ReactiveProperty.2.2.8\lib\net45\ReactiveProperty.NET45.dll</HintPath>
<HintPath>..\packages\ReactiveProperty.2.3\lib\net45\ReactiveProperty.NET45.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion WlanProfileViewer/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ReactiveProperty" version="2.2.8" targetFramework="net452" />
<package id="ReactiveProperty" version="2.3" targetFramework="net452" />
<package id="Rx-Core" version="2.2.5" targetFramework="net452" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net452" />
<package id="Rx-Linq" version="2.2.5" targetFramework="net452" />
Expand Down

0 comments on commit 69d924a

Please sign in to comment.