mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
Add Wox.CrashReporter
This commit is contained in:
14
Wox.Core/APIServer.cs
Normal file
14
Wox.Core/APIServer.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Core
|
||||
{
|
||||
public static class APIServer
|
||||
{
|
||||
private static string BaseAPIURL = "http://api.getwox.com";
|
||||
public static string ErrorReportURL = BaseAPIURL + "/error/";
|
||||
public static string LastestReleaseURL = BaseAPIURL + "/release/latest/";
|
||||
}
|
||||
}
|
||||
99
Wox.Core/Version/SemanticVersion.cs
Normal file
99
Wox.Core/Version/SemanticVersion.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Wox.Core.Exception;
|
||||
|
||||
namespace Wox.Core.Version
|
||||
{
|
||||
public class SemanticVersion : IComparable
|
||||
{
|
||||
public int MAJOR { get; set; }
|
||||
public int MINOR { get; set; }
|
||||
public int PATCH { get; set; }
|
||||
|
||||
public SemanticVersion(System.Version version)
|
||||
{
|
||||
MAJOR = version.Major;
|
||||
MINOR = version.Minor;
|
||||
PATCH = version.Build;
|
||||
}
|
||||
|
||||
public SemanticVersion(int major, int minor, int patch)
|
||||
{
|
||||
MAJOR = major;
|
||||
MINOR = minor;
|
||||
PATCH = patch;
|
||||
}
|
||||
|
||||
public SemanticVersion(string version)
|
||||
{
|
||||
var strings = version.Split('.');
|
||||
if (strings.Length != 3)
|
||||
{
|
||||
throw new WoxException("Invalid semantic version");
|
||||
}
|
||||
MAJOR = int.Parse(strings[0]);
|
||||
MINOR = int.Parse(strings[1]);
|
||||
PATCH = int.Parse(strings[2]);
|
||||
}
|
||||
|
||||
public static bool operator >(SemanticVersion v1, SemanticVersion v2)
|
||||
{
|
||||
return v1.CompareTo(v2) > 0;
|
||||
}
|
||||
|
||||
public static bool operator <(SemanticVersion v1, SemanticVersion v2)
|
||||
{
|
||||
return v1.CompareTo(v2) < 0;
|
||||
}
|
||||
|
||||
public static bool operator ==(SemanticVersion v1, SemanticVersion v2)
|
||||
{
|
||||
if (ReferenceEquals(v1, null))
|
||||
{
|
||||
return ReferenceEquals(v2, null);
|
||||
}
|
||||
if (ReferenceEquals(v2, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return v1.Equals(v2);
|
||||
}
|
||||
|
||||
public static bool operator !=(SemanticVersion v1, SemanticVersion v2)
|
||||
{
|
||||
return !(v1 == v2);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}.{1}.{2}", MAJOR, MINOR, PATCH);
|
||||
}
|
||||
|
||||
public override bool Equals(object version)
|
||||
{
|
||||
var v2 = (SemanticVersion)version;
|
||||
return MAJOR == v2.MAJOR && MINOR == v2.MINOR && PATCH == v2.PATCH;
|
||||
}
|
||||
|
||||
public int CompareTo(object version)
|
||||
{
|
||||
var v2 = (SemanticVersion)version;
|
||||
if (MAJOR == v2.MAJOR)
|
||||
{
|
||||
if (MINOR == v2.MINOR)
|
||||
{
|
||||
if (PATCH == v2.PATCH)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return PATCH - v2.PATCH;
|
||||
}
|
||||
return MINOR - v2.MINOR;
|
||||
}
|
||||
return MAJOR - v2.MAJOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Wox.Core/Version/VersionManager.cs
Normal file
36
Wox.Core/Version/VersionManager.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace Wox.Core.Version
|
||||
{
|
||||
public class VersionManager
|
||||
{
|
||||
private static VersionManager versionManager;
|
||||
private static SemanticVersion currentVersion;
|
||||
|
||||
public static VersionManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (versionManager == null)
|
||||
{
|
||||
versionManager = new VersionManager();
|
||||
}
|
||||
return versionManager;
|
||||
}
|
||||
}
|
||||
|
||||
private VersionManager() { }
|
||||
|
||||
public SemanticVersion CurrentVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (currentVersion == null)
|
||||
{
|
||||
currentVersion = new SemanticVersion(Assembly.GetExecutingAssembly().GetName().Version);
|
||||
}
|
||||
return currentVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="APIServer.cs" />
|
||||
<Compile Include="Exception\ExceptionFormatter.cs" />
|
||||
<Compile Include="Exception\WoxCritialException.cs" />
|
||||
<Compile Include="Exception\WoxException.cs" />
|
||||
@@ -89,6 +90,8 @@
|
||||
<Compile Include="UserSettings\PluginHotkey.cs" />
|
||||
<Compile Include="UserSettings\UserSettingStorage.cs" />
|
||||
<Compile Include="UserSettings\WebSearch.cs" />
|
||||
<Compile Include="Version\SemanticVersion.cs" />
|
||||
<Compile Include="Version\VersionManager.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Plugin\README.md" />
|
||||
|
||||
Reference in New Issue
Block a user