Пример #1
0
        /// <summary>
        /// Create a new instance of <see cref="TranslationResource"/>
        /// </summary>
        /// <param name="resource"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public TranslationResource(TranslationResource resource)
        {
            if (resource == null)
            {
                throw new ArgumentNullException(nameof(resource));
            }

            _pureTranslationTexts = new Dictionary <string, PureTranslationText>();

            Merge(resource);
        }
Пример #2
0
        /// <summary>
        /// Merge
        /// </summary>
        /// <param name="resource"></param>
        public void Merge(TranslationResource resource)
        {
            if (resource == null)
            {
                return;
            }

            foreach (var textWrapper in resource._pureTranslationTexts)
            {
                var _ = textWrapper.Value;

                if (_ == null)
                {
                    continue;
                }

                AddOrUpdate(_.LanguageAlias, _.Text, _.Type);
            }
        }
        /// <summary>
        /// Add
        /// </summary>
        /// <param name="key"></param>
        /// <param name="resource"></param>
        public void Add(string key, TranslationResource resource)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return;
            }

            if (resource == null)
            {
                return;
            }

            lock (_mapLockObj)
            {
                if (_holidayResourceMap.ContainsKey(key))
                {
                    _holidayResourceMap[key].Merge(resource);
                }
                else
                {
                    _holidayResourceMap.Add(key, resource);
                }
            }
        }