Exemplo n.º 1
0
 public virtual void GetDataServiceParameters(IEnumerable <DataService> dataServices)
 {
     if (CollectionUtils.IsNullOrEmpty(dataServices))
     {
         return;
     }
     try
     {
         string pluginRootFilePath         = GetPluginFilePath(CollectionUtils.FirstItem(dataServices), true);
         PluginDomainInstanceLoader loader = GetPluginInstanceLoader(null, pluginRootFilePath);
         using (PluginDisposer disposer = new PluginDisposer(loader))
         {
             foreach (DataService dataService in dataServices)
             {
                 if ((dataService.PluginInfo != null) && !string.IsNullOrEmpty(dataService.PluginInfo.ImplementingClassName))
                 {
                     try
                     {
                         string                  pluginFilePath = GetPluginFilePath(dataService, true);
                         BaseWNOSPlugin          plugin         = loader.GetInstance <BaseWNOSPlugin>(pluginFilePath, dataService.PluginInfo.ImplementingClassName);
                         DataServicePublishFlags publishFlags;
                         dataService.ServiceParameters = plugin.GetDataServiceParameters(dataService.Name, out publishFlags);
                         dataService.PublishFlags      = publishFlags;
                     }
                     catch (Exception e)
                     {
                         // Don't publish on load error
                         dataService.PublishFlags = DataServicePublishFlags.DoNotPublish;
                         LOG.Error("Failed to GetDataServiceParameters for data service \"{0}\"", e, dataService.Name);
                     }
                 }
                 else
                 {
                     // Don't publish if not implementer
                     dataService.PublishFlags = DataServicePublishFlags.DoNotPublish;
                 }
             }
         }
     }
     catch (Exception)
     {
         foreach (DataService dataService in dataServices)
         {
             // Don't publish if can't load
             dataService.PublishFlags = DataServicePublishFlags.DoNotPublish;
         }
     }
 }
Exemplo n.º 2
0
        protected virtual ICollection <SimpleDataService> GetDataServiceImplementersInDirectory(string inDirectoryPath,
                                                                                                bool ignoreInstallingAssemblies)
        {
            OrderedSet <SimpleDataService> implementers = new OrderedSet <SimpleDataService>();

            if (Directory.Exists(inDirectoryPath))
            {
                OrderedSet <string>        processedAssemblies = new OrderedSet <string>();
                PluginDomainInstanceLoader loader = null;
                try
                {
                    PluginInstanceFinder pluginFinder = null;
                    foreach (string dllPath in Directory.GetFiles(inDirectoryPath, "*.dll", SearchOption.AllDirectories))
                    {
                        if (!ignoreInstallingAssemblies || !IsInstallingPluginAssemblyPath(dllPath))
                        {
                            string assemblyName = Path.GetFileName(dllPath);
                            if (!processedAssemblies.Contains(assemblyName))
                            {
                                string assemblyPath = GetPluginFilePathInDirectory(assemblyName, inDirectoryPath,
                                                                                   ignoreInstallingAssemblies);
                                if (assemblyPath != null)
                                {
                                    if (loader == null)
                                    {
                                        // Don't need to load spring objects here
                                        loader       = GetPluginInstanceLoader(null, assemblyPath);
                                        pluginFinder = loader.GetInstance <PluginInstanceFinder>();
                                    }
                                    GetDataServiceImplementers(pluginFinder, assemblyPath, ref implementers);
                                }
                                processedAssemblies.Add(assemblyName);
                            }
                        }
                    }
                }
                finally
                {
                    DisposableBase.SafeDispose(ref loader);
                }
            }
            return(implementers);
        }
Exemplo n.º 3
0
        protected virtual IPluginDisposer LoadPluginInterfaceInstance <T>(DataService inDataService,
                                                                          bool ignoreInstallingAssemblies,
                                                                          string pluginConfigFilePath,
                                                                          out T plugin) where T : class
        {
            string pluginFilePath               = GetPluginFilePath(inDataService, ignoreInstallingAssemblies);
            PluginDomainInstanceLoader loader   = GetPluginInstanceLoader(pluginConfigFilePath, pluginFilePath);
            PluginDisposer             disposer = new PluginDisposer(loader);

            try
            {
                plugin = loader.GetInstance <T>(pluginFilePath, inDataService.PluginInfo.ImplementingClassName);
            }
            catch (Exception)
            {
                DisposableBase.SafeDispose(ref disposer);
                throw;
            }
            return(disposer);
        }