/// <summary>
        /// Adds a new localized value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception>
        public static void AddLocalizedValue(LocalizedValue value)
        {
            InternalAddLocalizedValue(value);

            // Update the value initially
            value.UpdateValue();
        }
        /// <summary>
        /// Adds a new localized value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception>
        internal static void InternalAddLocalizedValue(LocalizedValue value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (_localizedValuesPurgeCount > PurgeLimit)
            {
                // Remove localized values the owners of which have been garbage collected

                lock (_localizedValues)
                {
                    List <LocalizedProperty> keys = null;

                    foreach (var item in _localizedValues.Keys)
                    {
                        if (false == item.IsAlive)
                        {
                            if (keys == null)
                            {
                                keys = new List <LocalizedProperty>();
                            }

                            keys.Add(item);
                        }
                    }

                    if (keys != null)
                    {
                        foreach (var key in keys)
                        {
                            _localizedValues.Remove(key);
                        }
                    }

                    _localizedValuesPurgeCount = 0;
                }
            }

            lock (_localizedValues)
            {
                var count = _localizedValues.Count;

                _localizedValues[value.Property] = value;

                if (count < _localizedValues.Count)
                {
                    // A new value has been added

                    _localizedValuesPurgeCount++;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a new localized value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception>
        internal static void InternalAddLocalizedValue(LocalizedValue value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (_localizedValuesPurgeCount > PurgeLimit)
            {
                // Remove localized values the owners of which have been garbage collected

                lock (_localizedValues)
                {
                    List<LocalizedProperty> keys = null;

                    foreach (var item in _localizedValues.Keys)
                    {
                        if (false == item.IsAlive)
                        {
                            if (keys == null)
                            {
                                keys = new List<LocalizedProperty>();
                            }

                            keys.Add(item);
                        }
                    }

                    if (keys != null)
                    {
                        foreach (var key in keys)
                        {
                            _localizedValues.Remove(key);
                        }
                    }

                    _localizedValuesPurgeCount = 0;
                }
            }

            lock (_localizedValues)
            {
                var count = _localizedValues.Count;

                _localizedValues[value.Property] = value;

                if (count < _localizedValues.Count)
                {
                    // A new value has been added

                    _localizedValuesPurgeCount++;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds a new localized value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception>
        public static void AddLocalizedValue(LocalizedValue value)
        {
            InternalAddLocalizedValue(value);

            // Update the value initially
            value.UpdateValue();
        }