Beispiel #1
0
        private static int getPluginHashCode(TerrainPlugin terrainPlugin)
        {
            string details = terrainPlugin.Name;

            foreach (LayerType terrainLayerPipelineType in Enum.GetValues(typeof(LayerType)))
            {
                if (terrainPlugin.Out.Contains(terrainLayerPipelineType))
                {
                    details += Enum.GetName(typeof(LayerType), terrainLayerPipelineType);
                }
            }
            foreach (LayerType terrainLayerPipelineType in Enum.GetValues(typeof(LayerType)))
            {
                if (terrainPlugin.In.Contains(terrainLayerPipelineType))
                {
                    details += Enum.GetName(typeof(LayerType), terrainLayerPipelineType);
                }
            }
            foreach (LayerType terrainLayerPipelineType in Enum.GetValues(typeof(LayerType)))
            {
                if (terrainPlugin.Not.Contains(terrainLayerPipelineType))
                {
                    details += Enum.GetName(typeof(LayerType), terrainLayerPipelineType);
                }
            }


            return(details.GetHashCode());
        }
Beispiel #2
0
        private static List <TerrainPlugin> getTerrainPipeline(Configurations configurations)
        {
            List <TerrainPlugin> terrainPipeline = new List <TerrainPlugin>();
            Dictionary <TerrainPipelineLayer, List <TerrainPlugin> > availablePlugins = AvailablePlugins;

            foreach (TerrainPipelineLayer terrainPipelineLayer in configurations.Layers)
            {
                TerrainPlugin terrainPlugin = null;
                if (availablePlugins.ContainsKey(terrainPipelineLayer))
                {
                    foreach (TerrainPlugin plugin in availablePlugins[terrainPipelineLayer])
                    {
                        if (terrainPipelineLayer.PluginId == new TerrainPluginInfo(plugin).Id)
                        {
                            terrainPlugin = plugin;
                            break;
                        }
                    }
                }

                terrainPipeline.Add(terrainPlugin);
            }

            return(terrainPipeline);
        }
Beispiel #3
0
 public TerrainPluginInfo(TerrainPlugin terrainPlugin)
 {
     Name        = terrainPlugin.Name;
     Author      = terrainPlugin.Author;
     Description = terrainPlugin.Description;
     Id          = getPluginHashCode(terrainPlugin);
     Out         = terrainPlugin.Out;
     In          = terrainPlugin.In;
     Not         = terrainPlugin.Not;
 }
Beispiel #4
0
        private static List <TerrainPlugin> readAvailablePlugins()
        {
            List <TerrainPlugin> plugins = new List <TerrainPlugin>();

            string pluginsPath = PLUGINS_PATH;

            Console.Out.WriteLine("Plugins path: " + pluginsPath);
            Console.Out.WriteLine("Loading plugins...");
            string[] dllFileNames = null;
            if (Directory.Exists(pluginsPath))
            {
                dllFileNames = Directory.GetFiles(pluginsPath, "*.dll");

                ICollection <Assembly> assemblies = new List <Assembly>(dllFileNames.Length);
                foreach (string dllFile in dllFileNames)
                {
                    AssemblyName an       = AssemblyName.GetAssemblyName(dllFile);
                    Assembly     assembly = Assembly.Load(an);
                    assemblies.Add(assembly);
                }

                Type pluginType = typeof(TerrainPlugin);
                ICollection <Type> pluginTypes = new List <Type>();
                foreach (Assembly assembly in assemblies)
                {
                    if (assembly != null)
                    {
                        Type[] types = assembly.GetTypes();
                        foreach (Type type in types)
                        {
                            if (type.IsInterface || type.IsAbstract)
                            {
                                continue;
                            }
                            else
                            {
                                if (type.GetInterface(pluginType.FullName) != null)
                                {
                                    pluginTypes.Add(type);
                                }
                            }
                        }
                    }
                }

                Console.Out.WriteLine("### Available plugins: ###");

                foreach (Type type in pluginTypes)
                {
                    TerrainPlugin plugin = (TerrainPlugin)Activator.CreateInstance(type);
                    plugins.Add(plugin);
                    Console.Out.WriteLine("##################");
                    Console.Out.WriteLine("Hash code: " + plugin.GetHashCode());
                    foreach (LayerType layerType in plugin.Out)
                    {
                        Console.Out.WriteLine(layerType.ToString());
                    }
                    Console.Out.WriteLine(plugin.Name);
                    Console.Out.WriteLine("##################");
                }
            }
            else
            {
                Console.Out.WriteLine("Plugin path does not exist!!!");
            }

            return(plugins);
        }