Exemplo n.º 1
0
        private void buttonUpdateHandler_Click(object sender, RoutedEventArgs e)
        {
            if (this.danu == null)
            {
                return;
            }
            try
            {
                foreach (Type p in this.codeHandlers)
                {
                    IPoolManagerCodeHandler handler = (IPoolManagerCodeHandler)Activator.CreateInstance(p);

                    if (handler != null && handler.GetName() == comboBoxCodeHandlers.Text)
                    {
                        string oldDirectory = Environment.CurrentDirectory;
                        Environment.CurrentDirectory = Path.Combine(oldDirectory, "./Projects/" + this.danu.Root.Name.ToLower());

                        handler.GenerateCode(this.danu);
                        textBlockStatus.Text = "Code stub generated succefully.";

                        Environment.CurrentDirectory = oldDirectory;

                        return;
                    }
                }
                textBlockStatus.Text = "Unable to generate code. A suitable code generator could not be found.";
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PlugSPL Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load combo box values. Search app assemblies for types which implements
        /// IPoolManagerCodeHandler interface.
        /// </summary>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (this.codeHandlers.Count() > 0)
            {
                return;
            }

            try
            {
                string[] asmFiles = Directory.GetFiles("./", "ComponentPoolManager.*.dll");
                foreach (string s in asmFiles)
                {
                    Assembly asm = Assembly.LoadFrom(s);
                    foreach (Type p in asm.GetTypes())
                    {
                        Type type = typeof(IPoolManagerCodeHandler);
                        if (type.IsAssignableFrom(p))
                        {
                            this.codeHandlers.Add(p);
                        }
                    }
                }

                List <String> handlerNames = new List <string>();
                this.comboBoxCodeHandlers.Items.Clear();
                foreach (Type p in this.codeHandlers)
                {
                    IPoolManagerCodeHandler handler = (IPoolManagerCodeHandler)Activator.CreateInstance(p);
                    if (handler != null)
                    {
                        this.comboBoxCodeHandlers.Items.Add(handler.GetName());
                    }
                }

                this.comboBoxCodeHandlers.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PlugSPL Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }