示例#1
0
        private bool InternalLoad([NotNull][ItemNotNull] IEnumerable <IGrouping <string, ProjectFile> > resourceFilesByDirectory)
        {
            Contract.Requires(resourceFilesByDirectory != null);

            if (!LoadEntities(resourceFilesByDirectory))
            {
                return(false); // nothing has changed, no need to continue
            }
            if (!string.IsNullOrEmpty(_snapshot))
            {
                ResourceEntities.LoadSnapshot(_snapshot);
            }

            var cultureKeys = ResourceEntities
                              .SelectMany(entity => entity.Languages)
                              .Select(lang => lang.CultureKey)
                              .Distinct()
                              .OrderBy(item => item.Culture?.DisplayName)
                              .ToArray();

            Cultures.SynchronizeWith(cultureKeys);

            OnLoaded();

            return(true);
        }
示例#2
0
        private async Task <bool> InternalLoadAsync(ICollection <IGrouping <string, ProjectFile> > resourceFilesByDirectory, CancellationToken?cancellationToken)
        {
            if (!await LoadEntitiesAsync(resourceFilesByDirectory, cancellationToken).ConfigureAwait(true))
            {
                return(false); // nothing has changed, no need to continue
            }
            if (!_snapshot.IsNullOrEmpty())
            {
                ResourceEntities.LoadSnapshot(_snapshot);
            }

            var cultureKeys = ResourceEntities
                              .SelectMany(entity => entity.Languages)
                              .Select(lang => lang.CultureKey)
                              .Distinct()
                              .OrderBy(item => item.Culture?.DisplayName)
                              .ToArray();

            Cultures.SynchronizeWith(cultureKeys);

            OnLoaded();

            return(true);
        }