Example #1
0
File: Main.cs Project: j0nat/JCIW
        /// <summary>
        /// Check if app is valid and load.
        /// </summary>
        /// <param name="appId">Application ID</param>
        /// <param name="filePath">Path on file system.</param>
        private void LoadApp(long appId, string filePath)
        {
            FileInfo     file         = new FileInfo(Path.Combine(Local.Folder, filePath));
            ModuleHeader moduleHeader = ModuleHeaderReader.AppHeader(Local.Folder, file.FullName);

            if (moduleHeader != null)
            {
                if (apps.ContainsKey(appId))
                {
                    ModuleInstance app = apps[appId];

                    app.Load();

                    currentApp = app;
                }
                else
                {
                    ModuleInstance app = new ModuleInstance(file.FullName, "Module.App",
                                                            new object[] { Frame, Networking, PlatformFunctions, Platform, UserGroups.ToArray() });

                    bool result = app.Load();

                    apps.Add(appId, app);

                    currentApp = app;
                }

                CurrentlyRunningAppName = moduleHeader.Name;
            }
        }
Example #2
0
        /// <summary>
        /// Load service from disk.
        /// </summary>
        /// <param name="filePath"></param>
        public void RegisterModule(string filePath)
        {
            string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            if (baseDirectory.Length == 0)
            {
                baseDirectory = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
            }

            string fullPath = Path.Combine(baseDirectory, filePath);

            if (File.Exists(filePath))
            {
                ModuleHeader pluginHeader = ModuleHeaderReader.AppHeader(
                    baseDirectory, fullPath);

                ModuleHeader serviceHeader = ModuleHeaderReader.ServiceHeader(
                    baseDirectory, fullPath);

                if (pluginHeader != null)
                {
                    Module module = new Module();
                    module.enabled = 0;
                    module.type    = (int)ModuleType.App;
                    module.path    = filePath;
                    module.name    = pluginHeader.Name;
                    module.version = pluginHeader.Version;

                    moduleRepository.Add(module);
                }

                if (serviceHeader != null)
                {
                    Module module = new Module();
                    module.enabled = 0;
                    module.type    = (int)ModuleType.Service;
                    module.path    = filePath;
                    module.name    = serviceHeader.Name;
                    module.version = serviceHeader.Version;

                    moduleRepository.Add(module);

                    serviceManager.LoadServices();
                }
            }
            else
            {
                // No such file
            }
        }
Example #3
0
        public bool VerifyModule(string fileName)
        {
            bool returnValue = false;

            ModuleHeader serviceHeader = ModuleHeaderReader.ServiceHeader(Path.GetDirectoryName(fileName), fileName);
            ModuleHeader pluginHeader  = ModuleHeaderReader.AppHeader(Path.GetDirectoryName(fileName), fileName);

            if (pluginHeader != null || serviceHeader != null)
            {
                returnValue = true;
            }

            return(returnValue);
        }