コード例 #1
0
        /// <summary>
        /// Sets up any aliases with logic that should be executed on them.
        /// </summary>
        public static void SetupAliases()
        {
            if (App.Settings?.ProfileSettings?.AliasList != null)
            {
                foreach (var alias in App.Settings.ProfileSettings.AliasList)
                {
                    // If it's got the old IsLua bit and it's set as a Command (the default) set it to MoonSharp.
                    if (alias.IsLua && alias.ExecuteAs == ExecuteType.Command)
                    {
                        alias.ExecuteAs = ExecuteType.LuaMoonsharp;
                    }

                    // In case any of the function names are null or blank, set them up based off of the ID.
                    if (string.IsNullOrWhiteSpace(alias.FunctionName))
                    {
                        alias.FunctionName = ScriptHost.GetFunctionName(alias.Id, "a");
                    }

                    // Load the scripts into the scripting environment.
                    if (alias.ExecuteAs == ExecuteType.LuaMoonsharp)
                    {
                        App.MainWindow.Interp.ScriptHost.AddFunction(new SourceCode(alias.Command, alias.FunctionName, ScriptType.MoonSharpLua));
                    }
                }
            }
        }