/// <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;
        }
 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));
     }
 }
        /// <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.");
            }
        }
        /// <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>
 /// Stops localizing the property. Does not clear the current value of the property.
 /// </summary>
 /// <param name="property">The property.</param>
 /// <exception cref="ArgumentNullException"><paramref name="property"/> is null.</exception>
 public static void Clear(this LocalizedProperty property)
 {
     RemoveLocalizedValue(property);
 }
示例#7
0
 /// <summary>
 /// Assigns a value that is produced by a callback.
 /// </summary>
 /// <param name="property">The property.</param>
 /// <param name="method">The callback method.</param>
 /// <param name="parameter">The parameter to pass to the callback method.</param>
 /// <exception cref="ArgumentNullException"><paramref name="property"/> is null.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="method"/> is null.</exception>
 /// <remarks>
 /// The method will be called once to set the initial value of the property and each
 /// time the current culture changes.
 /// </remarks>
 public static void SetCallbackValue(this LocalizedProperty property, LocalizationCallback method, object parameter)
 {
     AddLocalizedValue(new MethodLocalizedValue(property, method, parameter));
 }
示例#8
0
 /// <summary>
 /// Assigns a formated value to the specified property. The format string is kept
 /// in resources.
 /// </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 static void SetResourceFormattedValue(this LocalizedProperty property, string resourceKey, params object[] args)
 {
     AddLocalizedValue(new ResourceFormattedLocalizedValue(property, resourceKey, args));
 }
示例#9
0
 /// <summary>
 /// Assigns a formated value to the specified property.
 /// </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 static void SetFormattedValue(this LocalizedProperty property, string formatString, params object[] args)
 {
     AddLocalizedValue(new FormattedLocalizedValue(property, formatString, args));
 }
示例#10
0
 /// <summary>
 /// Assigns a resource value to the specified localized property.
 /// </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 static void SetResourceValue(this LocalizedProperty property, string resourceKey)
 {
     AddLocalizedValue(new ResourceLocalizedValue(property, resourceKey));
 }