コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalizedValue"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <exception cref="ArgumentNullException"><paramref name="property"/> is null.</exception>
        protected LocalizedValue(LocalizedProperty property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            Property = property;
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceLocalizedValue"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="resourceKey">The resource key.</param>
        /// <exception cref="ArgumentNullException"><paramref name="property"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="resourceKey"/> is null or empty.</exception>
        public ResourceLocalizedValue(LocalizedProperty property, string resourceKey)
            : base(property)
        {
            if (string.IsNullOrEmpty(resourceKey))
            {
                throw new ArgumentNullException("resourceKey");
            }

            _resourceKey = resourceKey;
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MethodLocalizedValue"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="method">The method.</param>
        /// <param name="parameter">The parameter to pass to the method.</param>
        /// <exception cref="ArgumentNullException"><paramref name="property"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="method"/> is null.</exception>
        public MethodLocalizedValue(LocalizedProperty property, LocalizationCallback method, object parameter)
            : base(property)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            _method = method;

            _parameter = parameter;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FormattedLocalizedValue"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="resourceKey">The resource key.</param>
        /// <param name="args">The args.</param>
        /// <exception cref="ArgumentNullException"><paramref name="property"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="resourceKey"/> is null or empty.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="args"/> is null.</exception>
        public ResourceFormattedLocalizedValue(
            LocalizedProperty property,
            string resourceKey,
            params object[] args
            )
            : base(property, resourceKey)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            _args = args;
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormattedLocalizedValue"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="formatString">The format string.</param>
        /// <param name="args">The args.</param>
        /// <exception cref="ArgumentNullException"><paramref name="property"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="formatString"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="args"/> is null.</exception>
        public FormattedLocalizedValue(LocalizedProperty property, string formatString, params object[] args)
            : base(property)
        {
            if (formatString == null)
            {
                throw new ArgumentNullException("formatString");
            }

            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            _formatString = formatString;

            _args = args;
        }
コード例 #6
0
        /// <summary>
        /// Removes any localized value associated with the specified property.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <exception cref="ArgumentNullException"><paramref name="property"/> is <c>null</c>.</exception>
        /// <remarks>
        /// This method remvoes the property from the list of properties updated automatically when the
        /// current culture changes. The current value of the property remains untouched.
        /// </remarks>
        public static void RemoveLocalizedValue(LocalizedProperty property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            lock (_localizedValues)
            {
                _localizedValues.Remove(property);
            }
        }
コード例 #7
0
 LocalizedValue CreateLocalizedValue(LocalizedProperty property)
 {
     if (Callback != null && Callback.GetCallback() != null)
     {
         return new MethodLocalizedValue(property, Callback.GetCallback(), CallbackParameter);
     }
     else if (string.IsNullOrEmpty(ResourceKey))
     {
         return null;
     }
     else
     {
         return new ResourceLocalizedValue(property, ResourceKey);
     }
 }
コード例 #8
0
        /// <summary>
        /// Checks if binding localization can be used on the specified property.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns>
        /// 	<c>true</c> binding localization can be used; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException"><paramref name="property"/> is null.</exception>
        internal static void CheckPropertySupported(LocalizedProperty property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            if (property.GetValueType() == typeof(string) || property.GetValueType() == typeof(object))
            {
                // The property is supported
            }
            else
            {
                throw new InvalidOperationException("Only properties of type 'System.String' and 'System.Object' are supported.");
            }
        }