Exemplo n.º 1
0
        public void Undo()
        {
            bool refresh = false;

            resourceNodeCreator?.Remove();
            if (!(newAssemblyVersion is null) && !(origAssemblyVersion is null))
            {
                modNode.Document.AssemblyDef !.Version = origAssemblyVersion;
                refresh = true;
            }
            if (!(origExportedTypes is null) && !(newExportedTypes is null))
            {
                modNode.Document.ModuleDef !.ExportedTypes.Clear();
                foreach (var et in origExportedTypes)
                {
                    modNode.Document.ModuleDef.ExportedTypes.Add(et);
                }
            }
            if (!(origModuleCustomAttributes is null) && !(newModuleCustomAttributes is null))
            {
                modNode.Document.ModuleDef !.CustomAttributes.Clear();
                foreach (var ca in origModuleCustomAttributes)
                {
                    modNode.Document.ModuleDef.CustomAttributes.Add(ca);
                }
            }
            if (!(origAssemblyCustomAttributes is null) && !(newAssemblyCustomAttributes is null))
            {
                modNode.Document.AssemblyDef !.CustomAttributes.Clear();
                foreach (var ca in origAssemblyCustomAttributes)
                {
                    modNode.Document.AssemblyDef.CustomAttributes.Add(ca);
                }
            }
            if (!(origAssemblyDeclSecurities is null) && !(newAssemblyDeclSecurities is null))
            {
                modNode.Document.AssemblyDef !.DeclSecurities.Clear();
                foreach (var ds in origAssemblyDeclSecurities)
                {
                    modNode.Document.AssemblyDef.DeclSecurities.Add(ds);
                }
            }
            for (int i = existingTypeNodeUpdaters.Length - 1; i >= 0; i--)
            {
                existingTypeNodeUpdaters[i].Remove();
            }
            for (int i = newTypeNodeCreators.Length - 1; i >= 0; i--)
            {
                newTypeNodeCreators[i].Remove();
            }
            if (refresh)
            {
                asmNode?.TreeNode.RefreshUI();
            }
        }
Exemplo n.º 2
0
        public void Execute()
        {
            bool refresh = false;

            for (int i = 0; i < newTypeNodeCreators.Length; i++)
            {
                newTypeNodeCreators[i].Add();
            }
            for (int i = 0; i < existingTypeNodeUpdaters.Length; i++)
            {
                existingTypeNodeUpdaters[i].Add();
            }
            if (origAssemblyDeclSecurities is not null && newAssemblyDeclSecurities is not null)
            {
                modNode.Document.AssemblyDef !.DeclSecurities.Clear();
                foreach (var ds in newAssemblyDeclSecurities)
                {
                    modNode.Document.AssemblyDef.DeclSecurities.Add(ds);
                }
            }
            if (origAssemblyCustomAttributes is not null && newAssemblyCustomAttributes is not null)
            {
                modNode.Document.AssemblyDef !.CustomAttributes.Clear();
                foreach (var ca in newAssemblyCustomAttributes)
                {
                    modNode.Document.AssemblyDef.CustomAttributes.Add(ca);
                }
            }
            if (origModuleCustomAttributes is not null && newModuleCustomAttributes is not null)
            {
                modNode.Document.ModuleDef !.CustomAttributes.Clear();
                foreach (var ca in newModuleCustomAttributes)
                {
                    modNode.Document.ModuleDef.CustomAttributes.Add(ca);
                }
            }
            if (origExportedTypes is not null && newExportedTypes is not null)
            {
                modNode.Document.ModuleDef !.ExportedTypes.Clear();
                foreach (var et in newExportedTypes)
                {
                    modNode.Document.ModuleDef.ExportedTypes.Add(et);
                }
            }
            if (newAssemblyVersion is not null && origAssemblyVersion is not null)
            {
                modNode.Document.AssemblyDef !.Version = newAssemblyVersion;
                refresh = true;
            }
            resourceNodeCreator?.Add();
            if (refresh)
            {
                asmNode?.TreeNode.RefreshUI();
            }
        }