Exemple #1
0
        /// <summary>
        /// Try to find real hardware device implementations.
        /// Thereto we search for defined interface-implementations or classes as compiled dlls in a special directory.
        /// ATTENTION: every "extension" should be in it's own directory.
        /// </summary>
        /// <param name="extensionPath">The path to the directory where extension can be found.</param>
        private List <Type> loadExtensionDevices(string extensionPath)
        {
            var extTypes = new List <Type>();

            try
            {
                var dir = new DirectoryInfo(extensionPath);
                if (dir.Exists)
                {
                    var dirs = dir.GetDirectories();
                    // check every subdirectory
                    foreach (var directoryInfo in dirs)
                    {
                        // let the Extension loader fetch all dlls (classes) that implement a certain type or interface
                        // in this example the type to search for is IBrailleIOAdapter --> which are wrappers to real tactile display hardware devices
                        var extension = ExtensionLoader.LoadAllExtensions(typeof(IBrailleIOAdapter), directoryInfo.FullName).SelectMany(x => x.Value);
                        extTypes.AddRange(extension);
                    }
                }

                // now we can instantiate the single identified extension classes
                if (io != null && io.AdapterManager != null)
                {
                    foreach (var extType in extTypes)
                    {
                        // you can also add constructor parameters such as the example object someConstrParam
                        var adapter = Activator.CreateInstance(extType, io.AdapterManager);
                        if (adapter != null)
                        {
                            io.AdapterManager.AddAdapter(adapter as IBrailleIOAdapter);
                            // make the loaded adapter the Active one
                            // --> is seems to be the replacement for the automatically loaded ShowOff adapter.
                            io.AdapterManager.ActiveAdapter = adapter as IBrailleIOAdapter;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (logger != null)
                {
                    logger.Log(tud.mci.tangram.LogPriority.MIDDLE, this, "Exception while loading extensions", e);
                }
            }
            return(extTypes);
        }
        public override void Initialise()
        {
            base.Initialise();

            PluginName         = "BuildYourOwnRoutineCore";
            KeyboardHelper     = new KeyboardHelper(GameController);
            ExtensionCache     = new ExtensionCache();
            ExtensionParameter = new ExtensionParameter(this);

            ProfileDirectory   = PluginDirectory + @"/Profile/";
            ExtensionDirectory = PluginDirectory + @"/Extension/";
            ExtensionLoader.LoadAllExtensions(ExtensionCache, ExtensionDirectory);
            ProcessLoadedExtensions();

            CreateAndStartTreeFromLoadedProfile();

            Settings.TicksPerSecond.OnValueChanged += UpdateCoroutineWaitRender;
        }
Exemple #3
0
        public override bool Initialise()
        {
            base.Initialise();

            Name               = "BuildYourOwnRoutineCore";
            KeyboardHelper     = new KeyboardHelper(GameController);
            ExtensionCache     = new ExtensionCache();
            ExtensionParameter = new ExtensionParameter(this);

            ProfileDirectory   = DirectoryFullName + @"/Profile/";
            ExtensionDirectory = DirectoryFullName + @"/Extension/";
            Directory.CreateDirectory(DirectoryFullName);
            Directory.CreateDirectory(ExtensionDirectory);
            ExtensionLoader.LoadAllExtensions(ExtensionCache, ExtensionDirectory);
            ProcessLoadedExtensions();

            Settings.Enable.OnValueChanged += (sender, b) =>
            {
                if (b)
                {
                    if (Core.ParallelRunner.FindByName(buildYourOwnRoutineChecker) == null)
                    {
                        CreateAndStartTreeFromLoadedProfile();
                    }
                    TreeCoroutine?.Resume();
                }
                else
                {
                    TreeCoroutine?.Pause();
                }
            };

            CreateAndStartTreeFromLoadedProfile();

            Settings.TicksPerSecond.OnValueChanged += (sender, b) =>
            {
                UpdateCoroutineWaitRender();
            };

            return(true);
        }
Exemple #4
0
        public bool Start(int port, bool ssl)
        {
            HttpPort = port;
            UDPPort  = port;

            InitHttpServer(HttpPort, ssl);

            RegionHandle = Utils.UIntsToLong(REGION_X, REGION_Y);

            try
            {
                // Load all of the extensions
                List <string> references = new List <string>();
                references.Add("OpenMetaverseTypes.dll");
                references.Add("OpenMetaverse.dll");
                references.Add("Simian.exe");

                List <FieldInfo> assignables = ExtensionLoader <Simian> .GetInterfaces(this);

                ExtensionLoader <Simian> .LoadAllExtensions(Assembly.GetExecutingAssembly(),
                                                            AppDomain.CurrentDomain.BaseDirectory, this, references,
                                                            "Simian.*.dll", "Simian.*.cs", this, assignables);
            }
            catch (ExtensionException ex)
            {
                Logger.Log("Interface loading failed, shutting down: " + ex.Message, Helpers.LogLevel.Error);
                Stop();
                return(false);
            }

            foreach (IExtension <Simian> extension in ExtensionLoader <Simian> .Extensions)
            {
                // Track all of the extensions with persistence
                if (extension is IPersistable)
                {
                    PersistentExtensions.Add((IPersistable)extension);
                }
            }

            foreach (IExtension <Simian> extension in ExtensionLoader <Simian> .Extensions)
            {
                // Start all extensions except for persistence providers
                if (!(extension is IPersistenceProvider))
                {
                    Logger.DebugLog("Loading extension " + extension.GetType().Name);
                    extension.Start(this);
                }
            }

            foreach (IExtension <Simian> extension in ExtensionLoader <Simian> .Extensions)
            {
                // Start the persistence provider(s) after all other extensions are loaded
                if (extension is IPersistenceProvider)
                {
                    Logger.DebugLog("Loading persistance provider " + extension.GetType().Name);
                    extension.Start(this);
                }
            }

            return(true);
        }