mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
fix 0 init time record
This commit is contained in:
@@ -93,7 +93,7 @@ namespace Wox.Core.Plugin
|
||||
API = api;
|
||||
Parallel.ForEach(AllPlugins, pair =>
|
||||
{
|
||||
var milliseconds = Stopwatch.Normal($"Plugin init: {pair.Metadata.Name}", () =>
|
||||
var milliseconds = Stopwatch.Debug($"Plugin init: {pair.Metadata.Name}", () =>
|
||||
{
|
||||
pair.Plugin.Init(new PluginInitContext
|
||||
{
|
||||
@@ -101,7 +101,8 @@ namespace Wox.Core.Plugin
|
||||
API = API
|
||||
});
|
||||
});
|
||||
pair.Metadata.InitTime = milliseconds;
|
||||
pair.Metadata.InitTime += milliseconds;
|
||||
Log.Info($"Total init for {pair.Metadata.Name}: {pair.Metadata.InitTime}ms");
|
||||
InternationalizationManager.Instance.UpdatePluginMetadataTranslations(pair);
|
||||
});
|
||||
|
||||
|
||||
@@ -33,50 +33,56 @@ namespace Wox.Core.Plugin
|
||||
|
||||
foreach (var metadata in metadatas)
|
||||
{
|
||||
var milliseconds = Stopwatch.Debug($"C# plugin constructor init: {metadata.Name}", () =>
|
||||
{
|
||||
|
||||
#if DEBUG
|
||||
var assembly = Assembly.Load(AssemblyName.GetAssemblyName(metadata.ExecuteFilePath));
|
||||
var types = assembly.GetTypes();
|
||||
var type = types.First(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(typeof(IPlugin)));
|
||||
var plugin = (IPlugin)Activator.CreateInstance(type);
|
||||
var assembly = Assembly.Load(AssemblyName.GetAssemblyName(metadata.ExecuteFilePath));
|
||||
var types = assembly.GetTypes();
|
||||
var type = types.First(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(typeof(IPlugin)));
|
||||
var plugin = (IPlugin)Activator.CreateInstance(type);
|
||||
#else
|
||||
Assembly assembly;
|
||||
try
|
||||
{
|
||||
assembly = Assembly.Load(AssemblyName.GetAssemblyName(metadata.ExecuteFilePath));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(new WoxPluginException(metadata.Name, "Couldn't load assembly", e));
|
||||
continue;
|
||||
}
|
||||
var types = assembly.GetTypes();
|
||||
Type type;
|
||||
try
|
||||
{
|
||||
type = types.First(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(typeof(IPlugin)));
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Log.Exception(new WoxPluginException(metadata.Name, "Can't find class implement IPlugin", e));
|
||||
continue;
|
||||
}
|
||||
IPlugin plugin;
|
||||
try
|
||||
{
|
||||
plugin = (IPlugin)Activator.CreateInstance(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(new WoxPluginException(metadata.Name, "Can't create instance", e));
|
||||
continue;
|
||||
}
|
||||
Assembly assembly;
|
||||
try
|
||||
{
|
||||
assembly = Assembly.Load(AssemblyName.GetAssemblyName(metadata.ExecuteFilePath));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(new WoxPluginException(metadata.Name, "Couldn't load assembly", e));
|
||||
return;
|
||||
}
|
||||
var types = assembly.GetTypes();
|
||||
Type type;
|
||||
try
|
||||
{
|
||||
type = types.First(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(typeof(IPlugin)));
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Log.Exception(new WoxPluginException(metadata.Name, "Can't find class implement IPlugin", e));
|
||||
return;
|
||||
}
|
||||
IPlugin plugin;
|
||||
try
|
||||
{
|
||||
plugin = (IPlugin)Activator.CreateInstance(type);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(new WoxPluginException(metadata.Name, "Can't create instance", e));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
PluginPair pair = new PluginPair
|
||||
{
|
||||
Plugin = plugin,
|
||||
Metadata = metadata
|
||||
};
|
||||
plugins.Add(pair);
|
||||
PluginPair pair = new PluginPair
|
||||
{
|
||||
Plugin = plugin,
|
||||
Metadata = metadata
|
||||
};
|
||||
plugins.Add(pair);
|
||||
});
|
||||
metadata.InitTime += milliseconds;
|
||||
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user