PowerToys/Wox.Plugin.SystemPlugins/Program/IProgramSource.cs

51 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
2014-03-30 11:16:44 +08:00
namespace Wox.Plugin.SystemPlugins.Program
{
public interface IProgramSource
{
List<Program> LoadPrograms();
int BonusPoints { get; set; }
}
public abstract class AbstractProgramSource : IProgramSource
{
public abstract List<Program> LoadPrograms();
public int BonusPoints
{
get; set;
}
protected Program CreateEntry(string file)
{
var p = new Program()
{
Title = Path.GetFileNameWithoutExtension(file),
IcoPath = file,
ExecutePath = file
};
switch (Path.GetExtension(file).ToLower())
{
case ".exe":
2014-03-20 04:15:05 +08:00
p.ExecuteName = global::System.IO.Path.GetFileName(file);
try
{
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(file);
if (!string.IsNullOrEmpty(versionInfo.FileDescription))
{
p.Title = versionInfo.FileDescription;
}
}
catch (Exception) { }
break;
}
return p;
}
}
}