/// <summary> /// Gets the value of the specified symbol /// </summary> /// <param name="symbol">Symbol name</param> /// <param name="startFromGlobal">Should resolution start from global scope?</param> /// <returns> /// Null, if the symbol cannot be found; otherwise, the symbol's value /// </returns> public (ExpressionValue ExprValue, IHasUsageInfo UsageInfo) GetSymbolValue(string symbol, bool startFromGlobal = false) { (ExpressionValue ExprValue, IHasUsageInfo UsageInfo)resolved; if (startFromGlobal) { // --- Most be a compound symbol resolved = CurrentModule.ResolveCompoundSymbol(symbol, true); } else if (symbol.Contains(".")) { resolved = CurrentModule.ResolveCompoundSymbol(symbol, false); if (resolved.ExprValue == null) { resolved = CurrentModule.ResolveSimpleSymbol(symbol); } } else { resolved = CurrentModule.ResolveSimpleSymbol(symbol); } return(resolved); //return !symbol.Contains(".") && !startFromGlobal // ? CurrentModule.ResolveSimpleSymbol(symbol) // : CurrentModule.ResolveCompoundSymbol(symbol, startFromGlobal); }
public static void ProcessArgs() { InitializeRuntimeCoreIfNeeded(); if (RuntimeCore != null) { if (typeof(IgorCore).IsAssignableFrom(RuntimeCore.GetType())) { IgorCore CoreInst = (IgorCore)RuntimeCore; if (CoreInst != null) { ActiveModulesForJob.Clear(); foreach (IIgorModule CurrentModule in EnabledModules) { CurrentModule.ProcessArgs(CoreInst); } } else { IgorDebug.CoreCriticalError("Core could not be case to type IgorCore!"); } } else { IgorDebug.CoreCriticalError("Core is not of type IgorCore. Did you make your own? You may need to change how this works."); } } else { IgorDebug.CoreCriticalError("Core not found so we bailed out of processing arguments!"); } }
public static bool StaticIsModuleNeededByOtherModules(IIgorModule Module) { foreach (IIgorModule CurrentModule in EnabledModules) { if (CurrentModule.IsDependentOnModule(Module)) { return(true); } } return(false); }
private void Toolbar_Button_Click(object sender, EventArgs e) { try { if (ParseSpecification(true) != null) { CurrentModule.PerformButtonClick(this.CurrentEditorTabItem.TabText.TrimEnd('*'), (sender as ToolStripButton).Text); } } catch (Exception ex) { } }
public void OnAppLoaded() { if (CurrentModule != null && CurrentModule.ModuleData != null) { if (CurrentModule.ModuleData.ModuleSettings.FirstTimeSetup) { Data.LockScreenVisibility = Visibility.Visible; CurrentModule.OpenSetup(OnSetupComplete); } mainWindow.MarkdownConverterWindow.SetData(FileCommands.Load.LoadModuleMarkdownConverterSettings(CurrentModule.ModuleData)); } LoadTextGeneratorData(); }
protected void Page_Load(object sender, System.EventArgs e) { editEnabled = CurrentModule.Permissions.Allowed(OperationType.Edit, CurrentUser) && EnableEditingSetting.Equals("true"); htmlSource = CurrentModule.Details.Trim(); moduleID = CurrentModule.ModuleInstanceID; //needs to set file arrays here ImageArray = filesInPath(ImagesPathsSetting, "Content/HtmlImages/Public/Images/General/"); FlashArray = filesInPath(FlashPathsSetting, "Content/HtmlImages/Public/Flash/General"); MediaAray = filesInPath(MediaPathsSetting, "Content/HtmlImages/Public/Media/General/"); DocumentArray = filesInPath(DocumentPathsSetting, "Content/HtmlImages/Public/Documents/General/"); if (Request.IsAuthenticated && editEnabled) { if (Request.HttpMethod.ToString() == "POST" && Request["moduleID"] == moduleID.ToString()) //Save the data { Response.Clear(); Response.ContentType = "application/json; charset=utf-8"; //grabes the JSON as a string and converts to JSON object var bodyStream = new StreamReader(HttpContext.Current.Request.InputStream); bodyStream.BaseStream.Seek(0, SeekOrigin.Begin); var bodyText = bodyStream.ReadToEnd(); var json = JObject.Parse(bodyText); string jsonString = bodyText; string jHtml = (string)json.GetValue("gjs-html"); if (!string.IsNullOrEmpty(jsonString)) { CurrentModule.Details = Server.HtmlEncode(jsonString); CurrentModule.Save(CurrentUser.Identity.Name); } Response.Write("Saved"); Response.End(); } else if (Request.HttpMethod.ToString() == "GET" && Request["moduleID"] == moduleID.ToString()) //Load the data { string json = Server.HtmlDecode(htmlSource); Response.Clear(); Response.ContentType = "application/json; charset=utf-8"; Response.Write(json); Response.End(); } } ShowView(); }
public void LoadPlugins() { if (Fougerite.Config.GetBoolValue("Engines", "EnableCSharp")) { foreach (string name in GetPluginNames()) { LoadPlugin(name); } List <Module> OrderedModuleSelector = new List <Module>(); foreach (var x in PluginLoader.GetInstance().Plugins.Values) { CSPlugin plugin = x as CSPlugin; if (plugin != null) { OrderedModuleSelector.Add(plugin.Engine); } } OrderedModuleSelector = OrderedModuleSelector.OrderBy(x => x.Order).ToList(); foreach (Module CurrentModule in OrderedModuleSelector) { try { CurrentModule.Initialize(); } catch (Exception ex) { // Broken modules better stop the entire server init. Logger.LogError(string.Format( "[CSharpPlugin] Module \"{0}\" has thrown an exception during initialization. {1}", CurrentModule.Name, ex)); } //Logger.Log(string.Format( // "[CSharpPlugin] Module {0} v{1} (by {2}) initiated.", CurrentModule.Name, CurrentModule.Version, CurrentModule.Author)); } Hooks.ModulesLoaded(); } else { Logger.LogDebug("[CSharpPluginLoader] C# plugins are disabled in Fougerite.cfg."); } }
public static void SetModuleActiveForJob(IIgorModule NewModule) { if (EnabledModules.Contains(NewModule) && !ActiveModulesForJob.Contains(NewModule)) { bool bFound = false; foreach (IIgorModule CurrentModule in ActiveModulesForJob) { if (CurrentModule.GetModuleName() == NewModule.GetModuleName()) { bFound = true; } } if (!bFound) { ActiveModulesForJob.Add(NewModule); } } }
public static bool RegisterNewModule(IIgorModule NewModule) { if (StaticGetEnabledModuleNames().Contains(NewModule.GetModuleName())) { bool bFound = false; foreach (IIgorModule CurrentModule in EnabledModules) { if (CurrentModule.GetModuleName() == NewModule.GetModuleName()) { bFound = true; } } if (!bFound) { EnabledModules.Add(NewModule); return(true); } } return(false); }
internal static void LoadModules() { Logger.Log("[Modules] Loading modules..."); string IgnoredPluginsFilePath = Path.Combine(ModulesFolder, "ignoredmodules.txt"); List <string> IgnoredModules = new List <string>(); if (File.Exists(IgnoredPluginsFilePath)) { IgnoredModules.AddRange(File.ReadAllLines(IgnoredPluginsFilePath)); } DirectoryInfo[] DirectoryInfos = new DirectoryInfo(ModulesFolder).GetDirectories(); foreach (DirectoryInfo DirInfo in DirectoryInfos) { FileInfo FileInfo = new FileInfo(Path.Combine(DirInfo.FullName, DirInfo.Name + ".dll")); if (!FileInfo.Exists) { continue; } if (Array.IndexOf(Config.FougeriteConfig.EnumSection("Modules"), DirInfo.Name) == -1) { Logger.LogDebug(string.Format("[Modules] {0} is not configured to be loaded.", DirInfo.Name)); continue; } Logger.LogDebug("[Modules] Module Found: " + FileInfo.Name); string FileNameWithoutExtension = Path.GetFileNameWithoutExtension(FileInfo.Name); if (IgnoredModules.Contains(FileNameWithoutExtension)) { Logger.LogWarning(string.Format("[Modules] {0} was ignored from being loaded.", FileNameWithoutExtension)); continue; } try { Logger.LogDebug("[Modules] Loading assembly: " + FileInfo.Name); Assembly Assembly; // The plugin assembly might have been resolved by another plugin assembly already, so no use to // load it again, but we do still have to verify it and create plugin instances. if (!LoadedAssemblies.TryGetValue(FileNameWithoutExtension, out Assembly)) { Assembly = Assembly.Load(File.ReadAllBytes(FileInfo.FullName)); LoadedAssemblies.Add(FileNameWithoutExtension, Assembly); } foreach (Type Type in Assembly.GetExportedTypes()) { if (!Type.IsSubclassOf(typeof(Module)) || !Type.IsPublic || Type.IsAbstract) { continue; } Logger.LogDebug("[Modules] Checked " + Type.FullName); Module PluginInstance = null; try { PluginInstance = (Module)Activator.CreateInstance(Type); Logger.LogDebug("[Modules] Instance created: " + Type.FullName); } catch (Exception ex) { // Broken plugins better stop the entire server init. Logger.LogError(string.Format("[Modules] Could not create an instance of plugin class \"{0}\". {1}", Type.FullName, ex)); } if (PluginInstance != null) { ModuleContainer Container = new ModuleContainer(PluginInstance); Container.Plugin.ModuleFolder = Path.Combine(PublicFolder, Config.GetValue("Modules", DirInfo.Name).TrimStart(new char[] { '\\', '/' }).Trim()); Modules.Add(Container); GlobalPluginCollector.GetPluginCollector().AddPlugin(Container.Plugin.Name, Container, "C#"); Logger.LogDebug("[Modules] Module added: " + FileInfo.Name); break; } } } catch (Exception ex) { // Broken assemblies better stop the entire server init. Logger.LogError(string.Format("[Modules] Failed to load assembly \"{0}\". {1}", FileInfo.Name, ex)); } } IOrderedEnumerable <ModuleContainer> OrderedModuleSelector = from x in Plugins orderby x.Plugin.Order, x.Plugin.Name select x; foreach (ModuleContainer CurrentModule in OrderedModuleSelector) { try { CurrentModule.Initialize(); } catch (Exception ex) { // Broken modules better stop the entire server init. Logger.LogError(string.Format( "[Modules] Module \"{0}\" has thrown an exception during initialization. {1}", CurrentModule.Plugin.Name, ex)); } Logger.Log(string.Format( "[Modules] Module {0} v{1} (by {2}) initiated.", CurrentModule.Plugin.Name, CurrentModule.Plugin.Version, CurrentModule.Plugin.Author)); } Hooks.ModulesLoaded(); }
/// <summary> /// Gets the value of the specified symbol /// </summary> /// <param name="symbol">Symbol name</param> /// <param name="scopeSymbolNames">Additional symbol name segments</param> /// <param name="startFromGlobal">Should resolution start from global scope?</param> /// <returns> /// Null, if the symbol cannot be found; otherwise, the symbol's value /// </returns> public (ExpressionValue ExprValue, IHasUsageInfo UsageInfo) GetSymbolValue(string symbol, List <string> scopeSymbolNames = null, bool startFromGlobal = false) { return((scopeSymbolNames == null || scopeSymbolNames.Count == 0) && !startFromGlobal ? CurrentModule.ResolveSimpleSymbol(symbol) : CurrentModule.ResolveCompoundSymbol(symbol, scopeSymbolNames, startFromGlobal)); }
private void SetCurrentModule(IModule module) { CurrentModule?.Deactivate(); CurrentModule = module; CurrentModule?.Activate(); }
protected override void OnViewUnloaded(object view) { CurrentModule?.Deactivate(); }