private bool AddArchvier(string name, IArchiver provider, ulong version, IRequest request)
        {
            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);
                Archivers.AddOrSet(name, new Archiver(provider)
                {
                    Version = version
                }).Initialize(request);
            }
            return(true);
        }
        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 #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;
        }