Example #1
0
        /// <summary>
        ///A test for Remove
        ///</summary>
        public void RemoveTestHelper <TValue>()
        {
            var    target = new CaseInsensitiveDictionary <TValue>();
            var    key    = "a";
            TValue value  = default(TValue);

            target.Add(key, value);
            target.Remove(key);
            Assert.IsFalse(((Dictionary <string, TValue>)target).ContainsKey(key));
        }
        public void replaceName(int idx, string newName)
        {
            if (IsName(idx))
            {
                nameLookupTable.Remove(names[idx]);
                names[idx] = newName;
                nameLookupTable[newName] = idx;

                updateTools(PackageChange.NameEdit, idx);
            }
        }
Example #3
0
        /// <summary>
        ///A test for Remove
        ///</summary>
        public void RemoveTest3Helper <TValue>()
        {
            var    target = new CaseInsensitiveDictionary <TValue>();
            var    key    = "a";
            var    zkey   = "z";
            TValue value  = default(TValue);

            target.Add(key, value);
            try
            {
                target.Remove(zkey);
            } catch {}
            Assert.IsTrue(((Dictionary <string, TValue>)target).ContainsKey(key));
        }
        private void AddToSensitiveList(
            BlockCommandContext context,
            string word)
        {
            // Update the internal dictionaries by removing it from the
            // insensitive list and adding it to the sensitive list.
            CaseInsensitiveDictionary.Remove(word.ToLowerInvariant());
            CaseSensitiveDictionary.Add(word);

            // Clear the spell-checking on the entire document and reparse it.
            Project.Plugins.ClearAnalysis(BlockAnalyzer);
            Project.Plugins.ProcessBlockAnalysis();

            // Make sure the settings are written out.
            WriteSettings();
        }
        private void buildInstallationQueue(ModJob job, CaseInsensitiveDictionary <InstallSourceFile> installationMapping, bool isSFAR)
        {
            CLog.Information(@"Building installation queue for " + job.Header, Settings.LogModInstallation);
            foreach (var entry in job.FilesToInstall)
            {
                //Key is destination, value is source file
                var destFile   = entry.Key;
                var sourceFile = entry.Value;

                bool altApplied = false;
                foreach (var altFile in job.AlternateFiles.Where(x => x.IsSelected))
                {
                    Debug.WriteLine(@"Checking alt conditions for application: " + altFile.FriendlyName);
                    if (altFile.Operation == AlternateFile.AltFileOperation.OP_NOTHING)
                    {
                        continue;                                                                 //skip nothing
                    }
                    if (altFile.Operation == AlternateFile.AltFileOperation.OP_APPLY_MULTILISTFILES)
                    {
                        continue;                                                                              //do not apply in the main loop.
                    }
                    if (altFile.Operation == AlternateFile.AltFileOperation.OP_NOINSTALL_MULTILISTFILES)
                    {
                        continue;                                                                                  //do not apply in the main loop.
                    }
                    if (altFile.ModFile.Equals(destFile, StringComparison.InvariantCultureIgnoreCase))
                    {
                        //Alt applies to this file
                        switch (altFile.Operation)
                        {
                        case AlternateFile.AltFileOperation.OP_NOINSTALL:
                            CLog.Information($@"Not installing {destFile} for Alternate File {altFile.FriendlyName} due to operation OP_NOINSTALL", Settings.LogModInstallation);
                            //we simply don't map as we just do a continue below.
                            altApplied = true;
                            break;

                        case AlternateFile.AltFileOperation.OP_SUBSTITUTE:
                            CLog.Information($@"Repointing {destFile} to {altFile.AltFile} for Alternate File {altFile.FriendlyName} due to operation OP_SUBSTITUTE", Settings.LogModInstallation);
                            if (job.JobDirectory != null && (altFile.AltFile.StartsWith(job.JobDirectory) && job.Header == ModJob.JobHeader.CUSTOMDLC))
                            {
                                installationMapping[destFile] = new InstallSourceFile(altFile.AltFile.Substring(job.JobDirectory.Length).TrimStart('/', '\\'))
                                {
                                    AltApplied             = true,
                                    IsFullRelativeFilePath = true
                                };     //use alternate file as key instead
                            }
                            else
                            {
                                installationMapping[destFile] = new InstallSourceFile(altFile.AltFile)
                                {
                                    AltApplied             = true,
                                    IsFullRelativeFilePath = true
                                };     //use alternate file as key instead
                            }

                            altApplied = true;
                            break;

                        case AlternateFile.AltFileOperation.OP_INSTALL:
                            //same logic as substitute, just different logging.
                            CLog.Information($@"Adding {sourceFile} to install (from {altFile.AltFile}) as part of Alternate File {altFile.FriendlyName} due to operation OP_INSTALL", Settings.LogModInstallation);
                            if (job.JobDirectory != null && (altFile.AltFile.StartsWith(job.JobDirectory) && job.Header == ModJob.JobHeader.CUSTOMDLC))
                            {
                                installationMapping[destFile] = new InstallSourceFile(altFile.AltFile.Substring(job.JobDirectory.Length).TrimStart('/', '\\'))
                                {
                                    AltApplied             = true,
                                    IsFullRelativeFilePath = true
                                };     //use alternate file as key instead
                            }
                            else
                            {
                                installationMapping[destFile] = new InstallSourceFile(altFile.AltFile)
                                {
                                    AltApplied             = true,
                                    IsFullRelativeFilePath = true
                                };     //use alternate file as key instead
                            }
                            altApplied = true;
                            break;
                        }
                        break;
                    }
                }

                if (altApplied)
                {
                    continue;             //no further processing for file
                }
                //installationMapping[sourceFile] = sourceFile; //Nothing different, just add to installation list


                installationMapping[destFile] = new InstallSourceFile(sourceFile);
                CLog.Information($@"Adding {job.Header} file to installation {(isSFAR ? @"SFAR" : @"unpacked")} queue: {entry.Value} -> {destFile}", Settings.LogModInstallation); //do not localize
            }

            //Apply autolist alternate files

            foreach (var altFile in job.AlternateFiles.Where(x => x.IsSelected && x.Operation == AlternateFile.AltFileOperation.OP_APPLY_MULTILISTFILES))
            {
                foreach (var multifile in altFile.MultiListSourceFiles)
                {
                    CLog.Information(
                        $@"Adding multilist file {multifile} to install (from {altFile.MultiListRootPath}) as part of Alternate File {altFile.FriendlyName} due to operation OP_APPLY_MULTILISTFILES",
                        Settings.LogModInstallation);
                    string relativeSourcePath = altFile.MultiListRootPath + '\\' + multifile;

                    var targetPath = altFile.MultiListTargetPath + '\\' + multifile;
                    installationMapping[targetPath] = new InstallSourceFile(relativeSourcePath)
                    {
                        AltApplied             = true,
                        IsFullRelativeFilePath = true
                    }; //use alternate file as key instead
                       //}

                    //not sure if there should be an else case here.
                    //else
                    //{
                    //    installationMapping[destFile] = new InstallSourceFile(multifile)
                    //    {
                    //        AltApplied = true,
                    //        IsFullRelativeFilePath = true
                    //    }; //use alternate file as key instead
                    //}
                }
            }

            // Remove multilist noinstall files
            foreach (var altFile in job.AlternateFiles.Where(x => x.IsSelected && x.Operation == AlternateFile.AltFileOperation.OP_NOINSTALL_MULTILISTFILES))
            {
                foreach (var multifile in altFile.MultiListSourceFiles)
                {
                    CLog.Information(
                        $@"Attempting to remove multilist file {multifile} from install (from {altFile.MultiListRootPath}) as part of Alternate File {altFile.FriendlyName} due to operation OP_NOINSTALL_MULTILISTFILES",
                        Settings.LogModInstallation);
                    string relativeSourcePath = altFile.MultiListRootPath + '\\' + multifile;

                    var targetPath = altFile.MultiListTargetPath + '\\' + multifile;
                    if (installationMapping.Remove(targetPath))
                    {
                        CLog.Information($@" > Removed multilist file {targetPath} from installation",
                                         Settings.LogModInstallation);
                    }
                    else
                    {
                        Log.Warning($@"Failed to remove multilist file from installation queue as specified by altfile: {targetPath}, path not present in installation files");
                    }
                }
            }
        }