Refactoring Plugin.Feature

This commit is contained in:
bao-qian 2015-11-02 19:27:46 +00:00
parent 7a38143f5e
commit 86da8cbd17
13 changed files with 59 additions and 44 deletions

View file

@ -8,7 +8,6 @@ using WindowsInput;
using WindowsInput.Native; using WindowsInput.Native;
using Wox.Infrastructure.Hotkey; using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Plugin.Features;
using Control = System.Windows.Controls.Control; using Control = System.Windows.Controls.Control;
namespace Wox.Plugin.CMD namespace Wox.Plugin.CMD

View file

@ -7,7 +7,6 @@ using System.Reflection;
using System.ServiceProcess; using System.ServiceProcess;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Plugin.Everything.Everything; using Wox.Plugin.Everything.Everything;
using Wox.Plugin.Features;
namespace Wox.Plugin.Everything namespace Wox.Plugin.Everything
{ {

View file

@ -2,7 +2,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using Wox.Infrastructure;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
{ {

View file

@ -7,7 +7,6 @@ using System.Reflection;
using System.Windows; using System.Windows;
using IWshRuntimeLibrary; using IWshRuntimeLibrary;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Plugin.Features;
using Wox.Plugin.Program.ProgramSources; using Wox.Plugin.Program.ProgramSources;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program

View file

@ -4,7 +4,6 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Wox.Plugin.Features;
using Wox.Plugin.WebSearch.SuggestionSources; using Wox.Plugin.WebSearch.SuggestionSources;
namespace Wox.Plugin.WebSearch namespace Wox.Plugin.WebSearch

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -12,7 +11,6 @@ using Wox.Core.UserSettings;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Plugin; using Wox.Plugin;
using Wox.Plugin.Features;
namespace Wox.Core.Plugin namespace Wox.Core.Plugin
{ {
@ -229,7 +227,7 @@ namespace Wox.Core.Plugin
return AllPlugins.FirstOrDefault(o => o.Metadata.ID == id); return AllPlugins.FirstOrDefault(o => o.Metadata.ID == id);
} }
public static IEnumerable<PluginPair> GetPlugins<T>() where T : class public static IEnumerable<PluginPair> GetPlugins<T>() where T : IFeatures
{ {
return from p in AllPlugins where p.Plugin is T select p; return from p in AllPlugins where p.Plugin is T select p;
} }

View file

@ -3,7 +3,6 @@ using System.Linq;
using System.Windows; using System.Windows;
using Wox.Core.i18n; using Wox.Core.i18n;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Infrastructure;
using Wox.Plugin; using Wox.Plugin;
namespace Wox.Core.UI namespace Wox.Core.UI

37
Wox.Plugin/Feature.cs Normal file
View file

@ -0,0 +1,37 @@
using System.Collections.Generic;
namespace Wox.Plugin
{
public interface IFeatures { }
public interface IContextMenu : IFeatures
{
List<Result> LoadContextMenus(Result selectedResult);
}
public interface IExclusiveQuery : IFeatures
{
bool IsExclusiveQuery(Query query);
}
/// <summary>
/// Represent plugin query will be executed in UI thread directly. Don't do long-running operation in Query method if you implement this interface
/// <remarks>This will improve the performance of instant search like websearch or cmd plugin</remarks>
/// </summary>
public interface IInstantQuery : IFeatures
{
bool IsInstantQuery(string query);
}
/// <summary>
/// Represent plugins that support internationalization
/// </summary>
public interface IPluginI18n : IFeatures
{
string GetLanguagesFolder();
string GetTranslatedPluginTitle();
string GetTranslatedPluginDescription();
}
}

View file

@ -1,9 +1,8 @@
using System.Collections.Generic; using System;
namespace Wox.Plugin.Features namespace Wox.Plugin.Features
{ {
public interface IContextMenu [Obsolete("Delete Wox.Plugin.Features using directive, " +
{ "and use Wox.Plugin.Feature.IContextMenu instead, " +
List<Result> LoadContextMenus(Result selectedResult); "this method will be removed in v1.3.0")]
} public interface IContextMenu { }
} }

View file

@ -1,7 +1,9 @@
namespace Wox.Plugin.Features using System;
namespace Wox.Plugin.Features
{ {
public interface IExclusiveQuery [Obsolete("Delete Wox.Plugin.Features using directive, " +
{ "and use Wox.Plugin.Feature.IInstantQuery instead, " +
bool IsExclusiveQuery(Query query); "this method will be removed in v1.3.0")]
} public interface IExclusiveQuery { }
} }

View file

@ -1,11 +1,9 @@
namespace Wox.Plugin.Features using System;
namespace Wox.Plugin.Features
{ {
/// <summary> [Obsolete("Delete Wox.Plugin.Features using directive, " +
/// Represent plugin query will be executed in UI thread directly. Don't do long-running operation in Query method if you implement this interface "and use Wox.Plugin.Feature.IInstantQuery instead, " +
/// <remarks>This will improve the performance of instant search like websearch or cmd plugin</remarks> "this method will be removed in v1.3.0")]
/// </summary> public interface IInstantQuery { }
public interface IInstantQuery
{
bool IsInstantQuery(string query);
}
} }

View file

@ -1,14 +0,0 @@
namespace Wox.Plugin
{
/// <summary>
/// Represent plugins that support internationalization
/// </summary>
public interface IPluginI18n
{
string GetLanguagesFolder();
string GetTranslatedPluginTitle();
string GetTranslatedPluginDescription();
}
}

View file

@ -40,11 +40,11 @@
<ItemGroup> <ItemGroup>
<Compile Include="AllowedLanguage.cs" /> <Compile Include="AllowedLanguage.cs" />
<Compile Include="EventHandler.cs" /> <Compile Include="EventHandler.cs" />
<Compile Include="Feature.cs" />
<Compile Include="Features\IContextMenu.cs" /> <Compile Include="Features\IContextMenu.cs" />
<Compile Include="Features\IExclusiveQuery.cs" /> <Compile Include="Features\IExclusiveQuery.cs" />
<Compile Include="Features\IInstantQuery.cs" /> <Compile Include="Features\IInstantQuery.cs" />
<Compile Include="IHttpProxy.cs" /> <Compile Include="IHttpProxy.cs" />
<Compile Include="IPluginI18n.cs" />
<Compile Include="IPlugin.cs" /> <Compile Include="IPlugin.cs" />
<Compile Include="IPublicAPI.cs" /> <Compile Include="IPublicAPI.cs" />
<Compile Include="ISettingProvider.cs" /> <Compile Include="ISettingProvider.cs" />
@ -59,6 +59,7 @@
<ItemGroup> <ItemGroup>
<None Include="README.md" /> <None Include="README.md" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.