mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
whitespace stylecop fixes for Wox.Infra (#5689)
* Limited to whitespace * removing stylecop again
This commit is contained in:
@@ -37,6 +37,7 @@ namespace Wox.Infrastructure.Storage
|
||||
public T TryLoad(T defaultData)
|
||||
{
|
||||
_storageHelper = new StoragePowerToysVersionInfo(FilePath, BINARY_STORAGE);
|
||||
|
||||
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
|
||||
if (_storageHelper.clearCache)
|
||||
{
|
||||
@@ -72,7 +73,7 @@ namespace Wox.Infrastructure.Storage
|
||||
|
||||
private T Deserialize(FileStream stream, T defaultData)
|
||||
{
|
||||
//http://stackoverflow.com/questions/2120055/binaryformatter-deserialize-gives-serializationexception
|
||||
// http://stackoverflow.com/questions/2120055/binaryformatter-deserialize-gives-serializationexception
|
||||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter
|
||||
{
|
||||
|
||||
@@ -11,15 +11,22 @@ namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
// Events to watch out for
|
||||
event FileSystemEventHandler Created;
|
||||
|
||||
event FileSystemEventHandler Deleted;
|
||||
|
||||
event FileSystemEventHandler Changed;
|
||||
|
||||
event RenamedEventHandler Renamed;
|
||||
|
||||
// Properties of File System watcher
|
||||
Collection<string> Filters { get; set; }
|
||||
|
||||
bool EnableRaisingEvents { get; set; }
|
||||
|
||||
NotifyFilters NotifyFilter { get; set; }
|
||||
|
||||
string Path { get; set; }
|
||||
|
||||
bool IncludeSubdirectories { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,13 @@ namespace Wox.Infrastructure.Storage
|
||||
public interface IRepository<T>
|
||||
{
|
||||
void Add(T insertedItem);
|
||||
|
||||
void Remove(T removedItem);
|
||||
|
||||
bool Contains(T item);
|
||||
|
||||
void Set(IList<T> list);
|
||||
|
||||
bool Any();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
/// <summary>
|
||||
/// Save plugin settings/cache,
|
||||
/// Save plugin settings/cache,
|
||||
/// todo should be merged into a abstract class instead of separate interface
|
||||
/// </summary>
|
||||
public interface ISavable
|
||||
|
||||
@@ -17,10 +17,13 @@ namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
private readonly JsonSerializerSettings _serializerSettings;
|
||||
private T _data;
|
||||
|
||||
// need a new directory name
|
||||
public const string DirectoryName = "Settings";
|
||||
public const string FileSuffix = ".json";
|
||||
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public string DirectoryPath { get; set; }
|
||||
|
||||
// This storage helper returns whether or not to delete the json storage items
|
||||
@@ -41,6 +44,7 @@ namespace Wox.Infrastructure.Storage
|
||||
public T Load()
|
||||
{
|
||||
_storageHelper = new StoragePowerToysVersionInfo(FilePath, JSON_STORAGE);
|
||||
|
||||
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
|
||||
if (_storageHelper.clearCache)
|
||||
{
|
||||
@@ -108,6 +112,7 @@ namespace Wox.Infrastructure.Storage
|
||||
var backupName = $"{originName}-{timestamp}{FileSuffix}";
|
||||
var backupPath = Path.Combine(directory, backupName);
|
||||
File.Copy(FilePath, backupPath, true);
|
||||
|
||||
// todo give user notification for the backup process
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
/// <summary>
|
||||
/// The intent of this class is to provide a basic subset of 'list' like operations, without exposing callers to the internal representation
|
||||
/// of the data structure. Currently this is implemented as a list for it's simplicity.
|
||||
/// of the data structure. Currently this is implemented as a list for it's simplicity.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class ListRepository<T> : IRepository<T>, IEnumerable<T>
|
||||
@@ -24,12 +24,11 @@ namespace Wox.Infrastructure.Storage
|
||||
|
||||
public ListRepository()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Set(IList<T> items)
|
||||
{
|
||||
//enforce that internal representation
|
||||
// enforce that internal representation
|
||||
try
|
||||
{
|
||||
_items = new ConcurrentDictionary<int, T>(items.ToDictionary(i => i.GetHashCode()));
|
||||
@@ -51,7 +50,6 @@ namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
Log.Error($"|ListRepository.Add| Item Already Exists <{insertedItem}>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Remove(T removedItem)
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Wox.Infrastructure.Storage
|
||||
public bool clearCache = false;
|
||||
|
||||
private String currentPowerToysVersion = String.Empty;
|
||||
|
||||
private String FilePath { get; set; } = String.Empty;
|
||||
|
||||
// As of now this information is not pertinent but may be in the future
|
||||
@@ -102,6 +103,7 @@ namespace Wox.Infrastructure.Storage
|
||||
public StoragePowerToysVersionInfo(String AssociatedFilePath, int type)
|
||||
{
|
||||
FilePath = GetFilePath(AssociatedFilePath, type);
|
||||
|
||||
// Get the previous version of PowerToys and cache Storage details from the CacheDetails.json storage file
|
||||
String previousVersion = GetPreviousVersion();
|
||||
currentPowerToysVersion = Microsoft.PowerToys.Settings.UI.Lib.Utilities.Helper.GetProductVersion();
|
||||
|
||||
Reference in New Issue
Block a user