示例#1
0
        private void openProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _project = new Project();
            _mapping = new List<InjectionMapping>();

            DialogResult dialogResult = openProjectFileDialog.ShowDialog();

            if (dialogResult == System.Windows.Forms.DialogResult.OK)
            {
                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Project));
                TextReader reader = new StreamReader(openProjectFileDialog.FileName);

                _project = (Project)serializer.Deserialize(reader);

                _project.Injectors.ForEach(x => AddInjectionAssembly(x));
                _project.TargetAssemblies.ForEach(x => AddTargetAssembly(x));
                _project.Mapping.ForEach(x => _mapping.Add(InjectionMapping.FromProjectInjectionMapping(x)));

                grdCombination.DataSource = _mapping;

                reader.Close();
            }
        }
示例#2
0
        private void InitializeUI()
        {
            treeTarget.Nodes.Clear();
            _rootTarget = new TreeNode { Text = @"Target Assemblies", Tag = null };
            treeTarget.Nodes.Add(_rootTarget);

            treeInjectionCode.Nodes.Clear();
            _rootInjection = new TreeNode { Text = @"Injectors", Tag = null };
            treeInjectionCode.Nodes.Add(_rootInjection);

            _targetAssemblies = new Dictionary<string, MonoAssemblyResolver>();
            _mapping = new List<InjectionMapping>();
            _project = new Project();

            grdCombination.DataSource = null;

            var directory = Path.GetDirectoryName(Application.ExecutablePath);
            if (directory != null)
            {
                var files = Directory.GetFiles(directory, "*.dll");
                foreach (var file in files)
                {
                    LoadInjectorAssembly(file);
                }
            }
        }