/// <summary> /// Loads the manifest and returns true if it permits the loading of the plugin. If it prohibits /// the load then <see cref="IgnoredPlugins"/> is updated. /// </summary> /// <param name="manifestStorage"></param> /// <param name="applicationVersion"></param> /// <param name="dllFileName"></param> /// <returns></returns> private bool ManifestAllowsLoad(IPluginManifestStorage manifestStorage, Version applicationVersion, string dllFileName) { PluginManifest manifest = null; try { manifest = manifestStorage.LoadForPlugin(dllFileName); if (manifest == null) { IgnoredPlugins.Add(dllFileName, Strings.CouldNotFindManifest); } } catch (Exception ex) { IgnoredPlugins.Add(dllFileName, String.Format(Strings.CouldNotParseManifest, ex.Message)); } var result = manifest != null; if (result && !String.IsNullOrEmpty(manifest.MinimumVersion)) { result = CompareManifestVersions(manifest.MinimumVersion, applicationVersion, dllFileName, true); } if (result && !String.IsNullOrEmpty(manifest.MaximumVersion)) { result = CompareManifestVersions(manifest.MaximumVersion, applicationVersion, dllFileName, false); } return(result); }
public void TestInitialise() { _Provider = new Mock<IPluginManifestStorageProvider>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _Provider.Setup(p => p.FileExists(It.IsAny<string>())).Returns(() => { return _FileExists; }); _Provider.Setup(p => p.ReadAllText(It.IsAny<string>())).Returns(() => { return _FileContent; }); _FileContent = ""; _FileExists = true; _Storage = Factory.Singleton.Resolve<IPluginManifestStorage>(); _Storage.Provider = _Provider.Object; }
public void TestInitialise() { _Provider = new Mock <IPluginManifestStorageProvider>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _Provider.Setup(p => p.FileExists(It.IsAny <string>())).Returns(() => { return(_FileExists); }); _Provider.Setup(p => p.ReadAllText(It.IsAny <string>())).Returns(() => { return(_FileContent); }); _FileContent = ""; _FileExists = true; _Storage = Factory.Singleton.Resolve <IPluginManifestStorage>(); _Storage.Provider = _Provider.Object; }
/// <summary> /// Loads the manifest and returns true if it permits the loading of the plugin. If it prohibits /// the load then <see cref="IgnoredPlugins"/> is updated. /// </summary> /// <param name="manifestStorage"></param> /// <param name="applicationVersion"></param> /// <param name="dllFileName"></param> /// <returns></returns> private bool ManifestAllowsLoad(IPluginManifestStorage manifestStorage, Version applicationVersion, string dllFileName) { PluginManifest manifest = null; try { manifest = manifestStorage.LoadForPlugin(dllFileName); if(manifest == null) IgnoredPlugins.Add(dllFileName, Strings.CouldNotFindManifest); } catch(Exception ex) { IgnoredPlugins.Add(dllFileName, String.Format(Strings.CouldNotParseManifest, ex.Message)); } bool result = manifest != null; if(result && !String.IsNullOrEmpty(manifest.MinimumVersion)) result = CompareManifestVersions(manifest.MinimumVersion, applicationVersion, dllFileName, true); if(result && !String.IsNullOrEmpty(manifest.MaximumVersion)) result = CompareManifestVersions(manifest.MaximumVersion, applicationVersion, dllFileName, false); return result; }