Merge() public method

public Merge ( string enabledLanguages, DefinitionCache cache ) : void
enabledLanguages string
cache DefinitionCache
return void
Beispiel #1
0
        private void mergeBuiltInCommands(bool updateDefinitions, ProfileLocator profiles)
        {
            var builtInFile  = Path.Combine(profiles.AppRootPath, "oi-definitions.json");
            var builtInCache = new DefinitionCache();

            if (File.Exists(builtInFile))
            {
                builtInCache = appendDefinitions(builtInFile);
                var updated = builtInCache.GetOldestItem();
                if (updateDefinitions && updated != null && fileTime(System.Reflection.Assembly.GetExecutingAssembly().Location) > updated.Updated)
                {
                    builtInCache = writeBuiltInCommands(builtInFile, profiles);
                }
            }
            else
            {
                if (updateDefinitions)
                {
                    Logger.Write("Could not find definition file: " + builtInFile);
                    builtInCache = writeBuiltInCommands(builtInFile, profiles);
                }
            }
            _cache.Merge(_enabledLanguages, builtInCache);
        }
Beispiel #2
0
 public void Can_merge_two_definition_caches()
 {
     var type = DefinitionCacheItemType.Script;
     var time = DateTime.Now;
     var cache = new DefinitionCache();
     cache
         .Add(type, "", time, false, true, "cmd1", "")
             .Append(type, "", time, false, true, "cmd2", "")
                 .Append(type, "", time, false, true, "cmd3", "")
                     .Append(type, "", time, false, false, "-g", "");
     var another = new DefinitionCache();
     another
         .Add(type, "", time, false, true, "cmdAnother", "")
             .Append(type, "", time, false, true, "cmdAnother2", "");
     cache.Merge(another);
     Assert.That(cache.Definitions.Length, Is.EqualTo(2));
 }
Beispiel #3
0
 public void When_merging_two_definition_caches_it_will_not_add_duplicate_commands()
 {
     var type = DefinitionCacheItemType.Script;
     var time = DateTime.Now;
     var cache = new DefinitionCache();
     cache
         .Add(type, "", time, false, true, "cmd1", "")
             .Append(type, "", time, false, true, "cmd2", "")
                 .Append(type, "", time, false, true, "cmd3", "")
                     .Append(type, "", time, false, false, "-g", "");
     var another = new DefinitionCache();
     another
         .Add(type, "", time, false, true, "cmd1", "")
             .Append(type, "", time, false, true, "cmdAnother", "");
     cache.Merge(another);
     Assert.That(cache.Definitions.Length, Is.EqualTo(1));
 }