Exemple #1
0
        private void ReplyToSender(int fromID, string fromApp, string messageText)
        {
            //AJ: return to sender
            SubAppContainer sac = (SubAppContainer)this.LoadedApps[fromApp];

            sac.App.MessageIn(0, @"LDR", fromID, fromApp, @"Unknown loader command: " + messageText);
        }
Exemple #2
0
        private bool Unload(string shortName)
        {
            try
            {
                if (this.LoadedApps.ContainsKey(shortName))
                {
                    SubAppContainer sac = (SubAppContainer)this.LoadedApps[shortName];

                    if (sac.App.Unloadable)
                    {
                        this.LoadedApps.Remove(shortName);
                        sac.Unload();
                        sac = null;
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemple #3
0
        private void WriteToRemoteConsole(string messageText)
        {
            //AJ: for deving
            Console.WriteLine(messageText + System.Environment.NewLine);
            //AJ: for deving

            if (this.LoadedApps.ContainsKey(@"RC"))
            {
                SubAppContainer sac = (SubAppContainer)this.LoadedApps[@"RC"];
                sac.App.MessageIn(0, @"LDR", 0, @"RC", messageText + System.Environment.NewLine);
            }
        }
Exemple #4
0
        internal bool LoadLocal(ISubApp_V1 subApp)
        {
            System.IO.FileInfo fi = new System.IO.FileInfo(System.Reflection.Assembly.GetCallingAssembly().Location);

            SubAppContainer sac = new SubAppContainer(fi.DirectoryName, fi.Name + @"." + fi.Extension, subApp.GetType().FullName, subApp);

            if (!this.LoadedApps.ContainsKey(sac.App.ShortName))
            {
                this.LoadedApps.Add(sac.App.ShortName, sac);
                sac.App.MessageOut += new MessageOutEventHandler(App_MessageOut);
            }

            return(true);
        }
Exemple #5
0
 private bool Load(string directory, string filename, string objectName)
 {
     try
     {
         Console.WriteLine(@"Loading '" + objectName + "'");
         Console.WriteLine(@"From '" + directory + @"\" + filename + "'");
         //AJ: create the sub app container with the assembly details
         SubAppContainer sac = new SubAppContainer(directory, filename, objectName, true);
         this.LoadedApps.Add(sac.App.ShortName, sac);
         sac.App.MessageOut += new MessageOutEventHandler(App_MessageOut);
         Console.WriteLine(@"Loaded '" + objectName + "'");
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine(@"Loading '" + objectName + "' Failed");
         Console.WriteLine(ex.Message + ex.StackTrace);
         return(false);
     }
 }
Exemple #6
0
        public void App_MessageOut(int fromID, string fromApp, int toID, string toApp, string messageText)
        {
            //messageText = messageText.Replace("\r", @"");

            if (toApp.ToLower() == "ldr")
            {
                this.ProcessLoaderCommands(fromID, fromApp, toID, toApp, messageText);
            }
            else if (this.LoadedApps.ContainsKey(toApp))
            {
                //load destination app
                SubAppContainer sac = (SubAppContainer)this.LoadedApps[toApp];
                sac.App.MessageIn(fromID, fromApp, toID, toApp, messageText);
            }
            else
            {
                //AJ: do error - to app doesn't exist
                this.ReplyToSender(fromID, fromApp, @"Destination app doesn't exist");
            }
        }
Exemple #7
0
        private void ProcessLoaderCommands(int fromID, string fromApp, int toID, string toApp, string messageText)
        {
            string[] messageParts = messageText.Split(' ');

            switch (messageParts[0])
            {
                #region load
            case @"load":
                if (messageParts.Length == 4)
                {
                    //AJ: load child app
                    this.Load(messageParts[1], messageParts[2], messageParts[3]);
                }
                else
                {
                    this.ReplyToSender(fromID, fromApp, @"Incorrect load arguments: " + messageText + "\r\n");
                }
                break;
                #endregion

                #region reload
            case @"reload":
                if (messageParts.Length == 2)
                {
                    //AJ: unload child app
                    this.Reload(messageParts[1]);
                }
                else
                {
                    this.ReplyToSender(fromID, fromApp, @"Incorrect reload arguments: " + messageText + "\r\n");
                }
                break;
                #endregion

                #region unload
            case @"unload":
                if (messageParts.Length == 2)
                {
                    //AJ: unload child app
                    this.Unload(messageParts[1]);
                }
                else
                {
                    this.ReplyToSender(fromID, fromApp, @"Incorrect unload arguments: " + messageText + "\r\n");
                }
                break;
                #endregion

                #region show
            case @"show":
                if (messageParts.Length == 2)
                {
                    switch (messageParts[1])
                    {
                        #region loaded_apps
                    case @"loaded_apps":
                        this.ReplyToSender(fromID, fromApp, this.ShowLoadedApps());
                        break;
                        #endregion
                    }
                }
                else
                {
                    this.ReplyToSender(fromID, fromApp, @"Incorrect show arguments: " + messageText + "\r\n");
                }
                break;
                #endregion

                #region help
            case @"help":
                if (messageParts.Length == 2)
                {
                    if (this.LoadedApps.ContainsKey(messageParts[1]))
                    {
                        SubAppContainer sac = (SubAppContainer)this.LoadedApps[messageParts[1]];

                        this.ReplyToSender(fromID, fromApp, sac.App.HelpText);
                    }
                    else
                    {
                        this.ReplyToSender(fromID, fromApp, @"App doesn't exist: " + messageText + "\r\n");
                    }
                }
                else
                {
                    this.ReplyToSender(fromID, fromApp, @"Incorrect help arguments: " + messageText + "\r\n");
                }
                break;
                #endregion

                #region default
            default:
                this.ReplyToSender(fromID, fromApp, @"Unknown loader command: " + messageText + "\r\n");
                break;
                #endregion
            }
        }