Exemplo n.º 1
0
        public override XmlElement VToXML()
        {
            var componentDoc  = new XmlDocument();
            var componentData = componentDoc.CreateElement(GetComponentName <Cv_ScriptComponent>());
            var initScript    = componentDoc.CreateElement("InitScript");
            var script        = componentDoc.CreateElement("Script");
            var interval      = componentDoc.CreateElement("Interval");
            var executeOnce   = componentDoc.CreateElement("ExecuteOnce");
            var paused        = componentDoc.CreateElement("Paused");
            var runInEditor   = componentDoc.CreateElement("RunInEditor");

            initScript.SetAttribute("resource", InitScriptResource);
            script.SetAttribute("resource", ScriptResource);
            interval.SetAttribute("value", Interval.ToString(CultureInfo.InvariantCulture));
            executeOnce.SetAttribute("status", ExecuteOnce.ToString(CultureInfo.InvariantCulture));
            paused.SetAttribute("status", PauseExecution.ToString(CultureInfo.InvariantCulture));
            runInEditor.SetAttribute("value", RunInEditor.ToString(CultureInfo.InvariantCulture));

            componentData.AppendChild(initScript);
            componentData.AppendChild(script);
            componentData.AppendChild(interval);
            componentData.AppendChild(executeOnce);
            componentData.AppendChild(paused);
            componentData.AppendChild(runInEditor);

            return(componentData);
        }
Exemplo n.º 2
0
        public bool Execute(ConsoleDisplay console, string configurationFile)
        {
            console.WriteLine("Repairing shell icon overlays...");
            var serializer    = new ConfigurationSerializer();
            var configuration = serializer.Read(configurationFile);

            if (configuration.Sets == null || configuration.Sets.Count == 0)
            {
                console.WriteError($"No sets defined");
                return(false);
            }

            var backupTask = new ExecuteOnce(new BackupRegistryKeys());
            var duplicates = GatherDuplicates().ToList();

            if (duplicates.Any())
            {
                if (!backupTask.Execute(console, configurationFile))
                {
                    return(false);
                }

                console.WriteLine($"Deleting {duplicates.Count} duplicate identifiers");
                foreach (var duplicate in duplicates)
                {
                    _identifiers.Delete(duplicate);
                }
            }


            var changes = GatherChanges(console, configuration).ToList();

            if (!changes.Any())
            {
                console.WriteLine($"No identifiers need updating");
                return(true);
            }

            if (!backupTask.Execute(console, configurationFile))
            {
                return(false);
            }

            console.WriteLine($"Updating {changes.Count} identifiers");
            foreach (var change in changes)
            {
                _identifiers.UpdateIdentifier(change.Item1, change.Item2);
            }

            return(new RestartExplorerProcess().Execute(console, configurationFile));
        }