private Archiver RegisterArchiver(IArchiver provider, FourPartVersion asmVersion, IHostApi request)
        {
            string name = null;

            try {
                FourPartVersion ver     = provider.GetProviderVersion();
                var             version = ver == 0 ? asmVersion : ver;
                name = provider.GetArchiverName();
                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 (Archivers) {
                    if (Archivers.ContainsKey(name))
                    {
                        if (version > Archivers[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.

                            Archivers.Remove(name);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    request.Debug("Using Archiver Provider {0}".format(name));
                    var archiver = new Archiver(provider)
                    {
                        Version = version
                    };

                    archiver.Initialize(request);
                    Archivers.AddOrSet(name, archiver);
                    return(archiver);
                }
            }
            catch (Exception e) {
                request.Debug("Provider '{0}' Failed".format(name));
                e.Dump();
            }
            return(null);
        }
Beispiel #2
0
 private static bool ProcessArchiver(IArchiver provider, YieldArchiver yieldArchiver, FourPartVersion asmVersion, IRequest request)
 {
     try {
         FourPartVersion ver = provider.GetProviderVersion();
         if (yieldArchiver(provider.GetArchiverName(), provider, ver == 0 ? asmVersion : ver, request))
         {
             // provider.InitializeProvider(request);
             return(true);
         }
     } catch (Exception e) {
         e.Dump();
     }
     return(false);
 }
Beispiel #3
0
        private bool RegisterArchiver(IArchiver provider, FourPartVersion asmVersion, IHostApi request)
        {
            try {
                FourPartVersion ver     = provider.GetProviderVersion();
                var             version = ver == 0 ? asmVersion : ver;
                var             name    = provider.GetArchiverName();

                lock (Archivers) {
                    if (Archivers.ContainsKey(name))
                    {
                        if (version > Archivers[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.

                            Archivers.Remove(name);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    request.Debug("Loading Archiver {0}".format(name, provider.GetArchiverName()));
                    provider.InitializeProvider(request.As <IRequest>());
                    Archivers.AddOrSet(name, new Archiver(provider)
                    {
                        Version = version
                    }).Initialize(request);
                }
                return(true);
            } catch (Exception e) {
                e.Dump();
            }
            return(false);
        }
        private Archiver RegisterArchiver(IArchiver provider, FourPartVersion asmVersion, IHostApi request) {
            string name = null;
            try {
                FourPartVersion ver = provider.GetProviderVersion();
                var version = ver == 0 ? asmVersion : ver;
                name = provider.GetArchiverName();
                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 (Archivers) {
                    if (Archivers.ContainsKey(name)) {
                        if (version > Archivers[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.

                            Archivers.Remove(name);
                        }
                        else {
                            return null;
                        }
                    }
                    request.Debug("Using Archiver Provider {0}".format(name));
                    var archiver = new Archiver(provider) {
                        Version = version,
                        IsLoaded = true
                    };

                    archiver.Initialize(request);
                    Archivers.AddOrSet(name, archiver);
                    return archiver;
                }
            }
            catch (Exception e) {
                request.Debug("Provider '{0}' Failed".format(name));
                e.Dump();
            }
            return null;
        }