private static void ProcessPackageProvider(IPackageProvider provider, YieldPackageProvider yieldPackageProvider, FourPartVersion asmVersion, IRequest request) { try { provider.InitializeProvider(DynamicInterface.Instance, request); FourPartVersion ver = provider.GetProviderVersion(); yieldPackageProvider(provider.GetPackageProviderName(), provider, ver == 0 ? asmVersion : ver, request); } catch (Exception e) { e.Dump(); } }
private PackageProvider RegisterPackageProvider(IPackageProvider provider, FourPartVersion asmVersion, IHostApi request) { string name = null; try { FourPartVersion ver = provider.GetProviderVersion(); var version = ver == 0 ? asmVersion : ver; name = provider.GetPackageProviderName(); if (string.IsNullOrWhiteSpace(name)) { return(null); } // Initialize the provider before locking the collection // that way we're not blocking others on non-deterministic actions. request.Debug("Initializing provider '{0}'".format(name)); provider.InitializeProvider(request.As <IRequest>()); request.Debug("Provider '{0}' Initialized".format(name)); lock (_packageProviders) { if (_packageProviders.ContainsKey(name)) { if (version > _packageProviders[name].Version) { // remove the old provider first. // todo: this won't remove the plugin domain and unload the code yet // we'll have to do that later. _packageProviders.Remove(name); } else { return(null); } } request.Debug("Using Package Provider {0}".format(name)); var packageProvider = new PackageProvider(provider) { Version = version }; _packageProviders.AddOrSet(name, packageProvider); packageProvider.Initialize(request); return(packageProvider); } } catch (Exception e) { request.Debug("Provider '{0}' Failed".format(name)); e.Dump(); } return(null); }
private static bool ProcessPackageProvider(IPackageProvider provider, YieldPackageProvider yieldPackageProvider, FourPartVersion asmVersion, IRequest request) { try { // provider.InitializeProvider(DynamicInterface.Instance, request); FourPartVersion ver = provider.GetProviderVersion(); if (yieldPackageProvider(provider.GetPackageProviderName(), provider, ver == 0 ? asmVersion : ver, request)) { // provider.InitializeProvider(request); return(true); } } catch (Exception e) { e.Dump(); } return(false); }
private bool RegisterPackageProvider(IPackageProvider provider, FourPartVersion asmVersion, IHostApi request) { try { FourPartVersion ver = provider.GetProviderVersion(); var version = ver == 0 ? asmVersion : ver; var name = provider.GetPackageProviderName(); lock (_packageProviders) { if (_packageProviders.ContainsKey(name)) { if (version > _packageProviders[name].Version) { // remove the old provider first. // todo: this won't remove the plugin domain and unload the code yet // we'll have to do that later. _packageProviders.Remove(name); } else { return(false); } } request.Debug("Loading provider {0}".format(name, provider.GetPackageProviderName())); provider.InitializeProvider(request.As <IRequest>()); _packageProviders.AddOrSet(name, new PackageProvider(provider) { Version = version }).Initialize(request); } return(true); } catch (Exception e) { e.Dump(); } return(false); }
private PackageProvider RegisterPackageProvider(IPackageProvider provider, string name, FourPartVersion asmVersion, IHostApi request) { // string name = null; try { FourPartVersion ver = provider.GetProviderVersion(); var version = ver == 0 ? asmVersion : ver; //TODO: Need to write a blog file name is the provider name. Provider is no longer required to impl ProvierName property //name = provider.GetPackageProviderName(); //if (String.IsNullOrWhiteSpace(name)) { // return null; //} // Initialize the provider before locking the collection // that way we're not blocking others on non-deterministic actions. request.Debug("Initializing provider '{0}'".format(name)); provider.InitializeProvider(request.As<IRequest>()); request.Debug("Provider '{0}' Initialized".format(name)); lock (_packageProviders) { if (_packageProviders.ContainsKey(name)) { if (version > _packageProviders[name].Version) { // remove the old provider first. // todo: this won't remove the plugin domain and unload the code yet // we'll have to do that later. _packageProviders.Remove(name); } else { return null; } } } request.Debug("Using Package Provider {0}".format(name)); var packageProvider = new PackageProvider(provider) { Version = version, IsLoaded = true }; packageProvider.Initialize(request); // addOrSet locks the collection anyway. _packageProviders.AddOrSet(name, packageProvider); return packageProvider; } catch (Exception e) { request.Debug("Provider '{0}' Failed".format(name)); e.Dump(); } return null; }
/// <summary> /// Register the package provider /// </summary> /// <param name="provider">Package provider object</param> /// <param name="asmVersion">assembly version info</param> /// <param name="request"></param> /// <param name="shouldRefreshCache">should refresh the internal provider list</param> /// <returns></returns> private PackageProvider RegisterPackageProvider(IPackageProvider provider, FourPartVersion asmVersion, IHostApi request, bool shouldRefreshCache) { string name = null; try { if (provider == null) { return null; } FourPartVersion ver = provider.GetProviderVersion(); var version = ver == 0 ? asmVersion : ver; name = provider.GetPackageProviderName(); if (string.IsNullOrWhiteSpace(name)) { return null; } // Initialize the provider before locking the collection // that way we're not blocking others on non-deterministic actions. request.Debug("Initializing provider '{0}'".format(name)); provider.InitializeProvider(request.As<IRequest>()); request.Debug("Provider '{0}' Initialized".format(name)); lock (_packageProviders) { //Check if the provider is loaded already. if (_packageProviders.ContainsKey(name)) { //if no -force, do nothing if (!shouldRefreshCache) { request.Verbose(string.Format(CultureInfo.CurrentCulture, Resources.Messages.SkipPreviousProcessedProvider, name)); //add the provider to the list var pkgprovider = new PackageProvider(provider) { Version = version, IsLoaded = true }; AddToProviderCacheTable(name, pkgprovider); return pkgprovider; } else { //looks like -force is used, we need to remove the old provider first. // this won't remove the plugin domain and unload the code yet _packageProviders.Remove(name); } } } request.Debug("Using Package Provider {0}".format(name)); var packageProvider = new PackageProvider(provider) { Version = version }; //initialize the package provider packageProvider.Initialize(request); // addOrSet locks the collection anyway. _packageProviders.AddOrSet(name, packageProvider); packageProvider.IsLoaded = true; request.Debug("The provider '{0}' is imported".format(name)); //add the provider to the list AddToProviderCacheTable(name, packageProvider); return packageProvider; } catch (Exception e) { request.Debug("Provider '{0}' Failed to import".format(name)); e.Dump(); } return null; }