Fix dependency references issue of c# plugins.

This commit is contained in:
qianlifeng
2014-02-23 13:32:28 +08:00
parent 67fd2b4ac0
commit 2ade16a87a
12 changed files with 210 additions and 44 deletions

View File

@@ -23,53 +23,36 @@ namespace Wox.Plugin.Doc
List<Result> results = new List<Result>();
if (query.ActionParameters.Count == 0)
{
results.Add(new Result()
{
Title = "Current supported docs:"
});
results.AddRange(docs.Select(o => new Result()
{
Title = o.Name.Replace(".docset", ""),
Title = o.Name.Replace(".docset", "").Replace(" ",""),
IcoPath = o.IconPath
}).ToList());
return results;
}
foreach (Doc doc in docs)
if (query.ActionParameters.Count >= 2)
{
results.AddRange(QuerySqllite(doc, query.ActionParameters[0]));
Doc firstOrDefault = docs.FirstOrDefault(o => o.Name.Replace(".docset", "").Replace(" ","").ToLower() == query.ActionParameters[0]);
if (firstOrDefault != null)
{
results.AddRange(QuerySqllite(firstOrDefault, query.ActionParameters[1]));
}
}
else
{
foreach (Doc doc in docs)
{
results.AddRange(QuerySqllite(doc, query.ActionParameters[0]));
}
}
return results;
}
public void Init(PluginInitContext context)
{
//todo:move to common place
var otherCompanyDlls = new DirectoryInfo(context.PluginMetadata.PluginDirecotry).GetFiles("*.dll");
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
var dll = otherCompanyDlls.FirstOrDefault(fi =>
{
try
{
Assembly assembly = Assembly.LoadFile(fi.FullName);
return assembly.FullName == args.Name;
}
catch
{
return false;
}
});
if (dll == null)
{
return null;
}
return Assembly.LoadFile(dll.FullName);
};
docsetBasePath = context.PluginMetadata.PluginDirecotry + @"Docset";
if (!Directory.Exists(docsetBasePath))
Directory.CreateDirectory(docsetBasePath);
@@ -110,7 +93,6 @@ namespace Wox.Plugin.Doc
}
}
}
}
return imagePath;
}

View File

@@ -0,0 +1,5 @@
How to use?
1. Docset download link:[http://kapeli.com/docset_links](http://kapeli.com/docset_links)
2. Unzip doc zip into "Plugins\Doc\Docset\{docname}"
3. Restart Wox

View File

@@ -83,6 +83,7 @@
<None Include="plugin.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
@@ -101,7 +102,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy /Y /E $(TargetDir)*.* $(SolutionDir)Wox\bin\Debug\Plugins\Doc\</PostBuildEvent>
<PostBuildEvent>xcopy /Y /E $(TargetDir)*.* $(SolutionDir)Wox\bin\Debug\Plugins\$(ProjectName)\</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.