示例#1
0
        public void AddNewKey(ResourceEntity entity, string key)
        {
            Contract.Requires(entity != null);
            Contract.Requires(!string.IsNullOrEmpty(key));

            if (!entity.CanEdit(null))
            {
                return;
            }

            var entry = entity.Add(key);

            if (entry == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(_snapshot))
            {
                _resourceEntities.LoadSnapshot(_snapshot);
            }

            _selectedTableEntries.Clear();
            _selectedTableEntries.Add(entry);
        }
示例#2
0
        private static void VerifyCultures([NotNull] ResourceEntity entity, [NotNull][ItemNotNull] IEnumerable <CultureInfo> languages)
        {
            var undefinedLanguages = languages.Where(outer => entity.Languages.All(inner => !Equals(outer, inner.Culture))).ToArray();

            var lockedLanguage = undefinedLanguages.FirstOrDefault(language => !entity.CanEdit(language));

            if (lockedLanguage == null)
            {
                return;
            }

            throw new ImportException(string.Format(CultureInfo.CurrentCulture, Resources.ImportLanguageNotEditable, lockedLanguage));
        }
示例#3
0
        private static void VerifyCultures(ResourceEntity entity, ICollection <string> dataColumns)
        {
            Contract.Requires(entity != null);
            Contract.Requires(dataColumns != null);

            if (dataColumns.Distinct().Count() != dataColumns.Count)
            {
                throw new ImportException(Resources.ImportDuplicateLanguageError);
            }

            var languages = dataColumns.Select(data => data.ExtractCulture()).Distinct().ToArray();

            var undefinedLanguages = languages.Where(outer => entity.Languages.All(inner => !Equals(outer, inner.Culture))).ToArray();

            var lockedLanguage = undefinedLanguages.FirstOrDefault(language => !entity.CanEdit(language));

            if (lockedLanguage == null)
            {
                return;
            }

            throw new ImportException(string.Format(CultureInfo.CurrentCulture, Resources.ImportLanguageNotEditable, lockedLanguage));
        }
 public bool CanEdit(CultureKey cultureKey)
 {
     return(_container.CanEdit(cultureKey));
 }