Exemplo n.º 1
0
 /// <summary>
 /// Import the content of the .REG file and return the RegKeyEntry created from it
 /// </summary>
 /// <returns></returns>
 public RegKeyEntry Import()
 {
     if (Result == null)
     {
         Result = Parser.Parse(Content);
     }
     return(Result);
 }
 /// <summary>
 /// Import the content of the .REG file and return the RegKeyEntry created from it
 /// </summary>
 /// <returns></returns>
 public RegKeyEntry Import()
 {
     if (Result == null)
     {
         Result = Parser.Parse(Content);
     }
     return Result;
 }
Exemplo n.º 3
0
        private int HandleMultipleFiles()
        {
            if (WriteToTheRegistry)
            {
                Console.WriteLine("ERROR, /write is only allowed with single files");
                return(10);
            }
            if (AllAccess)
            {
                Console.WriteLine("ERROR, /allaccess is only allowed in combination with /write");
                return(10);
            }
            if (!string.IsNullOrEmpty(ParamsFilename))
            {
                Console.WriteLine("ERROR, /params is only allowed in combination with /write");
                return(10);
            }
            for (int i = 0; i < Files.Count; ++i)
            {
                for (int j = i + 1; j < Files.Count; ++j)
                {
                    RegKeyEntry file1 = Files[i];
                    RegKeyEntry file2 = Files[j];
                    RegDiff     rc    = new RegDiff(file1, Filenames[i], file2, Filenames[j], Aliases);
                    if (!Quiet)
                    {
                        Console.WriteLine(rc.ToString());
                    }

                    RegFileExportOptions options = RegFileExportOptions.None;
                    if (NoEmptyKeys)
                    {
                        options |= RegFileExportOptions.NoEmptyKeys;
                    }

                    if (!string.IsNullOrEmpty(DiffFile))
                    {
                        Console.WriteLine("Writing {0}...", DiffFile);
                        CreateRegFileExporter(DiffFile).Export(rc.CreateDiffKeyEntry(), DiffFile, options);
                        Console.WriteLine();
                    }
                    if (!string.IsNullOrEmpty(MergeFile))
                    {
                        Console.WriteLine("Writing {0}...", MergeFile);
                        CreateRegFileExporter(MergeFile).Export(rc.CreateMergeKeyEntry(), MergeFile, options);
                        Console.WriteLine();
                    }
                }
            }
            return(0);
        }
Exemplo n.º 4
0
 /// <summary>
 /// The constructor creates an object that represents a missing value in a key
 /// </summary>
 /// <param name="key">Key where the value was located</param>
 /// <param name="value">Original value</param>
 public MissingValue(RegKeyEntry key, RegValueEntry value)
 {
     Key   = key;
     Value = value;
 }
Exemplo n.º 5
0
 /// <summary>
 /// This constructor identifies a mismatch in the data of two registry values that are located
 /// in the same key path.
 /// </summary>
 /// <param name="key">Parent registry key path (by definition, the same in both registry trees)</param>
 /// <param name="value1">Data in first registry file</param>
 /// <param name="value2">Data in the second registry file</param>
 public DataMismatch(RegKeyEntry key, RegValueEntry value1, RegValueEntry value2)
 {
     Key    = key;
     Value1 = value1;
     Value2 = value2;
 }
Exemplo n.º 6
0
 /// <summary>
 /// The constructor creates an object that represents a missing value in a key
 /// </summary>
 /// <param name="key">Key where the value was located</param>
 /// <param name="value">Original value</param>
 public MissingValue(RegKeyEntry key, RegValueEntry value)
 {
     Key = key;
     Value = value;
 }
 /// <summary>
 /// The constructor takes the content of a .REG file, the expected header (=first line of the .REG file) and import options (if any)
 /// </summary>
 /// <param name="content">Content of the .REG file</param>
 /// <param name="expectedHeader">Expected header</param>
 /// <param name="options">Import options</param>
 public RegFileImporter(string content, string expectedHeader, RegFileImportOptions options)
 {
     Parser = new RegFileParser(expectedHeader, options);
     Content = content;
     Result = null;
 }
Exemplo n.º 8
0
 /// <summary>
 /// The constructor takes the content of a .REG file, the expected header (=first line of the .REG file) and import options (if any)
 /// </summary>
 /// <param name="content">Content of the .REG file</param>
 /// <param name="expectedHeader">Expected header</param>
 /// <param name="options">Import options</param>
 public RegFileImporter(string content, string expectedHeader, RegFileImportOptions options)
 {
     Parser  = new RegFileParser(expectedHeader, options);
     Content = content;
     Result  = null;
 }
Exemplo n.º 9
0
        private int HandleSingleFile()
        {
            RegKeyEntry regKeyEntry = Files[0];

            if (!string.IsNullOrEmpty(MergeFile))
            {
                Console.WriteLine("Writing {0}...", MergeFile);

                RegFileExportOptions options = RegFileExportOptions.None;
                if (NoEmptyKeys)
                {
                    options |= RegFileExportOptions.NoEmptyKeys;
                }

                CreateRegFileExporter(MergeFile).Export(regKeyEntry, MergeFile, options);
                Console.WriteLine();
            }
            if (WriteToTheRegistry)
            {
                RegEnvReplace env = new RegEnvReplace();
                if (!string.IsNullOrEmpty(ParamsFilename))
                {
                    if (!File.Exists(ParamsFilename))
                    {
                        Console.WriteLine("ERROR, /params file '{0}' not found", ParamsFilename);
                        return(10);
                    }
                    try
                    {
                        if (ParamsFilename.EndsWith(".ini", StringComparison.OrdinalIgnoreCase))
                        {
                            env.ReadIniFile(ParamsFilename);
                        }
                        else if (ParamsFilename.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
                        {
                            env.ReadXmlFile(ParamsFilename);
                        }
                        else
                        {
                            Console.WriteLine("ERROR, /params file '{0}' has an unsupported extension (only '.xml' and '.ini' are allowed)", ParamsFilename);
                            return(10);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("ERROR, unable to read /params file '{0}'", ParamsFilename);
                        Console.WriteLine(e.Message);
                        return(10);
                    }
                }
                env.MergeEnvironmentVariables();
                RegistryWriteOptions registryWriteOptions = RegistryWriteOptions.Recursive;
                if (AllAccess)
                {
                    registryWriteOptions |= RegistryWriteOptions.AllAccessForEveryone;
                }
                regKeyEntry.WriteToTheRegistry(registryWriteOptions, env, CurrentRegistryView);
            }
            else if (AllAccess)
            {
                Console.WriteLine("ERROR, /allaccess is only allowed in combination with /write");
                return(10);
            }
            else if (!string.IsNullOrEmpty(ParamsFilename))
            {
                Console.WriteLine("ERROR, /params is only allowed in combination with /write");
                return(10);
            }

            return(0);
        }
Exemplo n.º 10
0
 /// <summary>
 /// The constructor creates an object that represents a value that exists in both keys, but has different value kinds (and by definition
 /// different values) in each of them.
 /// </summary>
 /// <param name="key">Key where the value was located</param>
 /// <param name="value1">Value as it exists in the 1st key</param>
 /// <param name="value2">Value as it exists in the 2nd key</param>
 public KindMismatch(RegKeyEntry key, RegValueEntry value1, RegValueEntry value2)
 {
     Key = key;
     Value1 = value1;
     Value2 = value2;
 }