Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog wSchemaDialog = new OpenFileDialog();
            wSchemaDialog.DefaultExt = "dll";
            wSchemaDialog.CheckFileExists = true;

            wSchemaDialog.Filter = "DLL Files (*.dll;*.exe)|*.dll;*.exe|All Files (*.*)|*.*";
            wSchemaDialog.ShowReadOnly = true;

            MenuItemList wMenuItemList = new MenuItemList();
            
     
            if (wSchemaDialog.ShowDialog() == DialogResult.OK)
            {
                MenuItem wMenuItem = new MenuItem();
                Assembly ass = new Assembly(wSchemaDialog.FileName);
                lblFileName.Text = wSchemaDialog.FileName;
                foreach (AssemblyClass wAssemblyClass in ass.ClassCollections)
                {
                    if (wAssemblyClass.BaseType != null)
                    {
                        if (wAssemblyClass.BaseType.Name.Contains("Form"))
                        {
                            wMenuItem = new MenuItem();
                            wMenuItem.AssemblyInfo = wAssemblyClass.FullyQualifiedName;
                            wMenuItem.FormName = wAssemblyClass.Name;
                            wMenuItemList.Add(wMenuItem);
                        }
                    }
                }

                listBox1.DataSource = wMenuItemList;
            }
        }
Пример #2
0
        void LoadAssembly(string pFileName)
        {
            lblEx.Visible = false;
            ButtonBaseList wButtons = new ButtonBaseList();
            ButtonBase wButton = new ButtonBase();
            try
            {
                Assembly wAssembly = new Assembly(pFileName);
                lblFileName.Text = pFileName;

                foreach (AssemblyClass wAssemblyClass in wAssembly.ClassCollections)
                {
                    string name = wAssemblyClass.Name;


                    if (wAssemblyClass.BaseType != null)
                    {

                        typeof(ButtonBase).IsInstanceOfType(wButton);


                        //if (Fwk.HelperFunctions.TypeFunctions.TypeInheritFrom(wAssemblyClass.Type, _BaseTypesFilter))
                        if (inheritFromAny(wAssemblyClass.Type))
                        {
                            wButton = new ButtonBase();
                            wButton.AssemblyInfo = wAssemblyClass.FullyQualifiedName;

                            wButtons.Add(wButton);
                        }
                    }
                }

                listBox1.DataSource = wButtons;
            }
            catch (Exception ex)
            {
                lblEx.Visible = true;
                lblEx.Text = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex);
            }
        }
Пример #3
0
        void LoadAssembly()
        {

            try
            {
                Assembly wAssembly = new Assembly(_StorageFactory.StorageObject.AssemblyPath);
                Fwk.Bases.ServiceConfiguration s = null;
                Fwk.Bases.ServiceConfigurationCollection list = new Fwk.Bases.ServiceConfigurationCollection();
                lblFileName.Text = _StorageFactory.StorageObject.AssemblyPath;

                foreach (AssemblyClass wAssemblyClass in wAssembly.ClassCollections)
                {
                    if (wAssemblyClass.BaseType != null)
                    {
                        if (wAssemblyClass.BaseType.Name.Contains("BusinessService"))
                        {
                            if (!Services.Exists(p => p.Name.Equals(wAssemblyClass.Name.Trim())))
                            {
                                s = new Fwk.Bases.ServiceConfiguration();
                                //Service name
                                s.Name = wAssemblyClass.Name;
                                s.Handler = wAssemblyClass.FullyQualifiedName;
                                //Request
                                s.Request = wAssemblyClass.Methods[0].Parameters[0].ParameterType.AssemblyQualifiedName;

                                //Response
                                s.Response = wAssemblyClass.Methods[0].ReturnType.AssemblyQualifiedName;

                                list.Add(s);
                            }
                        }
                    }
                }

                var ordenedList = from x in list orderby x.Name select x;
                serviceConfigurationCollectionBindingSource.DataSource = ordenedList;
            }
            catch (System.Reflection.ReflectionTypeLoadException rx)
            {
                base.ExceptionViewer.Show(rx.LoaderExceptions, "Service Management:. Loading assembly");
                _StorageFactory.Clear();
            }
            catch (Exception ex)
            {

                base.ExceptionViewer.Show(ex);
                _StorageFactory.StorageObject.AssemblyPath = string.Empty;
                _StorageFactory.Save();
            }
        }
Пример #4
0
        void LoadAssembly()
        {
           
            try
            {
                if (!System.IO.File.Exists(ControllerTest.Storage.StorageObject.AssemblyPath))
                    return;
                Assembly wAssembly = new Assembly(ControllerTest.Storage.StorageObject.AssemblyPath);
                Fwk.Bases.ServiceConfiguration wServiceConfiguration = null;
                Fwk.Bases.ServiceConfigurationCollection list = new Fwk.Bases.ServiceConfigurationCollection();
                lblFileName.Text = ControllerTest.Storage.StorageObject.AssemblyPath;

                foreach (AssemblyClass wAssemblyClass in wAssembly.ClassCollections)
                {
                    if (wAssemblyClass.BaseType != null)
                    {
                        if (wAssemblyClass.BaseType.Name.Contains("BusinessService"))
                        {
                            wServiceConfiguration = new Fwk.Bases.ServiceConfiguration();
                            //Service name
                            wServiceConfiguration.Name = wAssemblyClass.Name;
                            wServiceConfiguration.Handler = wAssemblyClass.FullyQualifiedName;
                            //Request
                            wServiceConfiguration.Request = wAssemblyClass.Methods[0].Parameters[0].ParameterType.AssemblyQualifiedName;

                            //Response
                            wServiceConfiguration.Response = wAssemblyClass.Methods[0].ReturnType.AssemblyQualifiedName;

                            list.Add(wServiceConfiguration);
                        }
                    }
                }

                serviceConfigurationCollectionBindingSource.DataSource = list.OrderBy (p=> p.Name );
            }
            catch (System.Reflection.ReflectionTypeLoadException rx)
            {
                base.ExceptionViewer.Show(rx.LoaderExceptions, "Service Management:. Loading assembly");
                //ControllerTest.Storage.Clear();
            }
            catch (Exception ex)
            {

                base.ExceptionViewer.Show(ex);
                //ControllerTest.Storage.Clear();
            }
        }