Exemplo n.º 1
0
        private void AddAssembly(MSBuildAssembly msbuildAssembly)
        {
            string filePath = msbuildAssembly.FilePath;

            if (_assemblyByFilePath.ContainsKey(filePath))
            {
                return;
            }

            var projectAssembly = new AD.ProjectAssembly();

            projectAssembly.FilePath = filePath;

            if (msbuildAssembly.Sign)
            {
                projectAssembly.Sign = new AD.ProjectAssemblySign()
                {
                    DelaySign = msbuildAssembly.DelaySign,
                    KeyFile   = msbuildAssembly.KeyFilePath,
                    Password  = msbuildAssembly.KeyPassword,
                };
            }

            _project.Assemblies.Add(projectAssembly);

            OnProjectChanged();

            var assembly          = _assemblyManager.LoadAssembly(filePath);
            var assemblyViewModel = new AssemblyViewModel(assembly, projectAssembly, this);

            AddAssembly(assemblyViewModel);
            _assemblyByFilePath.Add(filePath, projectAssembly);
        }
Exemplo n.º 2
0
        public void DoAddAssembly(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            if (_assemblyByFilePath.ContainsKey(filePath))
            {
                AppService.UI.ShowMessageDialog(
                    string.Format(SR.AssemblyFileDuplicate, filePath),
                    MessageDialogType.Error);

                return;
            }

            var projectAssembly = new AD.ProjectAssembly();

            projectAssembly.FilePath = filePath;
            _project.Assemblies.Add(projectAssembly);

            OnProjectChanged();

            var assembly          = _assemblyManager.LoadAssembly(filePath);
            var assemblyViewModel = new AssemblyViewModel(assembly, projectAssembly, this);

            AddAssembly(assemblyViewModel);
            _assemblyByFilePath.Add(filePath, projectAssembly);
        }
Exemplo n.º 3
0
        public EventViewModel(EventDeclaration e, AD.ProjectEvent projectEvent, ViewModel parent)
            : base(parent)
        {
            _event             = e;
            _projectEvent      = projectEvent;
            _assemblyViewModel = FindParent <AssemblyViewModel>(true);

            Caption = NodePrinter.Print(_event);
            Image   = ImageType.Node_Event;
        }
        internal void Load(AssemblyViewModel viewModel)
        {
            var projectAssembly = viewModel.ProjectAssembly;

            if (projectAssembly.RenameMembers)
            {
                RenameMembers          = true;
                CanRenameMembers       = true;
                RenamePublicTypes      = projectAssembly.RenamePublicTypes;
                RenamePublicMethods    = projectAssembly.RenamePublicMethods;
                RenamePublicFields     = projectAssembly.RenamePublicFields;
                RenamePublicProperties = projectAssembly.RenamePublicProperties;
                RenamePublicEvents     = projectAssembly.RenamePublicEvents;
                RenameEnumMembers      = projectAssembly.RenameEnumMembers;
            }

            if (projectAssembly.ObfuscateControlFlow)
            {
                ObfuscateControlFlow    = true;
                CanObfuscateControlFlow = true;
            }

            if (projectAssembly.EncryptIL)
            {
                EncryptIL    = true;
                CanEncryptIL = true;
            }

            if (projectAssembly.ObfuscateStrings)
            {
                ObfuscateStrings    = true;
                CanObfuscateStrings = true;
            }

            if (projectAssembly.RemoveUnusedMembers)
            {
                RemoveUnusedMembers       = true;
                CanRemoveUnusedMembers    = true;
                RemoveUnusedPublicMembers = projectAssembly.RemoveUnusedPublicMembers;
            }

            if (projectAssembly.SealTypes)
            {
                SealTypes       = true;
                CanSealTypes    = true;
                SealPublicTypes = projectAssembly.SealPublicTypes;
            }

            if (projectAssembly.DevirtualizeMethods)
            {
                DevirtualizeMethods       = true;
                CanDevirtualizeMethods    = true;
                DevirtualizePublicMethods = projectAssembly.DevirtualizePublicMethods;
            }
        }
Exemplo n.º 5
0
        protected override void LoadChildren(List <NodeViewModel> children)
        {
            foreach (var projectAssembly in _assemblyByFilePath.Values)
            {
                if (string.IsNullOrEmpty(projectAssembly.FilePath))
                {
                    continue;
                }

                var assembly          = _assemblyManager.LoadAssembly(projectAssembly.FilePath);
                var assemblyViewModel = new AssemblyViewModel(assembly, projectAssembly, this);
                children.Add(assemblyViewModel);
            }

            children.Sort(NodeComparer.Default);
        }
Exemplo n.º 6
0
        public bool RemoveAssembly(AssemblyViewModel assemblyViewModel, bool ask)
        {
            if (ask)
            {
                bool?result = AppService.UI.ShowMessageDialog(
                    string.Format(SR.AskRemoveAssembly, assemblyViewModel.Caption),
                    MessageDialogType.Question,
                    false);

                if (!result.HasValue || !result.Value)
                {
                    return(false);
                }
            }

            int index = assemblyViewModel.Index;

            var projectAssembly = assemblyViewModel.ProjectAssembly;

            _project.Assemblies.Remove(projectAssembly);

            string filePath = projectAssembly.FilePath;

            _assemblyByFilePath.Remove(filePath);
            RemoveChild(assemblyViewModel);
            OnProjectChanged();
            ProjectShell.OnHierarchyChanged();

            if (ProjectShell.SelectedNode == assemblyViewModel)
            {
                if (index > 0)
                {
                    GetChild(index - 1).Show();
                }
                else
                {
                    Show();
                }
            }

            FireAssemblyRemoved(assemblyViewModel.Assembly);

            return(true);
        }
Exemplo n.º 7
0
        private void AddAssembly(AssemblyViewModel assemblyViewModel)
        {
            var comparer = StringLogicalComparer.Default;
            int index    = 0;

            for (int i = 0; i < ChildCount; i++)
            {
                var existingViewModel = (AssemblyViewModel)GetChild(i);
                if (0 > comparer.Compare(assemblyViewModel.Caption, existingViewModel.Caption))
                {
                    break;
                }

                index++;
            }

            InsertChild(index, assemblyViewModel);
            ProjectShell.OnHierarchyChanged();
            FireAssemblyAdded(assemblyViewModel.Assembly);
        }
 public override void Unload()
 {
     _node = null;
 }
 public override void Load(NodeViewModel node)
 {
     _node = (AssemblyViewModel)node;
 }