public void RemoveOrphansFrom(IInitialTranslations resource)
 {
     lock (StoreLock)
     {
         foreach (var translation in Orphans(resource))
         {
             Store.Delete(translation);
         }
     }
 }
示例#2
0
 public void RemoveOrphansFrom(IInitialTranslations resource)
 {
     lock (StoreLock)
     {
         foreach (var translation in Orphans(resource))
         {
             Store.Delete(translation);
         }
     }
 }
 public void InitializeTranslationsFrom(IInitialTranslations resource)
 {
     lock (StoreLock)
     {
         foreach (var translation in Uninitialized(resource))
         {
             Store.Save(translation);
         }
     }
 }
示例#4
0
 public void InitializeTranslationsFrom(IInitialTranslations resource)
 {
     lock (StoreLock)
     {
         foreach (var translation in Uninitialized(resource))
         {
             Store.Save(translation);
         }
     }
 }
示例#5
0
        private Translation[] Uninitialized(IInitialTranslations resource)
        {
            var uninitialized = new List <Translation>();
            var language      = resource.IetfLanguageTag;

            foreach (var group in resource.Initials)
            {
                var translations = group.Translations.Where(t => !AlreadyInitialized(t.ResourceKey, language));
                uninitialized.AddRange(translations);
            }
            return(uninitialized.ToArray());
        }
示例#6
0
        private Identity[] Orphans(IInitialTranslations resource)
        {
            var condition            = ConditionsFor(ietfLanguageTag: resource.IetfLanguageTag);
            var databaseTranslations = Store.FindAsPropertyBag(condition).Select(b => b.ToObject <Translation>()).ToArray();

            if (!databaseTranslations.Any())
            {
                return(new Identity[0]);
            }

            var initialTranslations = resource.Initials.SelectMany(i => i.Translations).ToArray();
            var orphans             = new List <Identity>();

            foreach (var dt in databaseTranslations)
            {
                if (initialTranslations.Any(it => it.ResourceKey == dt.ResourceKey))
                {
                    continue;
                }
                orphans.Add(dt.Id);
            }
            return(orphans.ToArray());
        }
 private Translation[] Uninitialized(IInitialTranslations resource)
 {
     var uninitialized = new List<Translation>();
     var language = resource.IetfLanguageTag;
     foreach (var group in resource.Initials)
     {
         var translations = group.Translations.Where(t => !AlreadyInitialized(t.ResourceKey, language));
         uninitialized.AddRange(translations);
     }
     return uninitialized.ToArray();
 }
        private Identity[] Orphans(IInitialTranslations resource)
        {
            var condition = ConditionsFor(ietfLanguageTag: resource.IetfLanguageTag);
            var databaseTranslations = Store.FindAsPropertyBag(condition).Select(b => b.ToObject<Translation>()).ToArray();
            if (!databaseTranslations.Any())
            {
                return new Identity[0];
            }

            var initialTranslations = resource.Initials.SelectMany(i => i.Translations).ToArray();
            var orphans = new List<Identity>();
            foreach (var dt in databaseTranslations)
            {
                if (initialTranslations.Any(it => it.ResourceKey == dt.ResourceKey))
                {
                    continue;
                }
                orphans.Add(dt.Id);
            }
            return orphans.ToArray();
        }