Example #1
0
        public static void TranslateItemsFromList(string category, Translation translation, IEnumerable <Tuple <string, object> > items)
        {
            Action <string, object, PropertyInfo> action = delegate(string item, object itemObj, PropertyInfo propertyInfo)
            {
                string value = translation.TranslateItem(category, item, propertyInfo.Name, null);
                if (!String.IsNullOrEmpty(value))
                {
                    if (propertyInfo.CanWrite)
                    {
                        propertyInfo.SetValue(itemObj, value, null);
                    }
                }
                else if (propertyInfo.Name == "ToolTipText" && !String.IsNullOrEmpty((string)propertyInfo.GetValue(itemObj, null)))
                {
                    value = translation.TranslateItem(category, item, "Text", null);
                    if (!String.IsNullOrEmpty(value))
                    {
                        if (propertyInfo.CanWrite)
                        {
                            propertyInfo.SetValue(itemObj, value, null);
                        }
                    }
                }
            };

            ForEachItem(items, action);
        }
Example #2
0
        public static void TranslateItemsFromFields(string category, object obj, Translation translation)
        {
            if (obj == null)
            {
                return;
            }

            Action <string, object, PropertyInfo> action = delegate(string item, object itemObj, PropertyInfo propertyInfo)
            {
                string value = translation.TranslateItem(category, item, propertyInfo.Name, null);
                if (value != null)
                {
                    propertyInfo.SetValue(itemObj, value, null);
                }
                else if (propertyInfo.Name == "ToolTipText" && !String.IsNullOrEmpty((string)propertyInfo.GetValue(itemObj, null)))
                {
                    value = translation.TranslateItem(category, item, "Text", null);
                    if (value != null)
                    {
                        propertyInfo.SetValue(itemObj, value, null);
                    }
                }
            };

            ForEachField(obj, action);
        }
Example #3
0
        public static void TranslateItemsFromFields(string category, object obj, Translation translation)
        {
            if (obj == null)
            {
                return;
            }

            Action <string, object, PropertyInfo> action = delegate(string item, object itemObj, PropertyInfo propertyInfo)
            {
                string value = translation.TranslateItem(category, item, propertyInfo.Name, null);
                if (value != null)
                {
                    propertyInfo.SetValue(itemObj, value, null);
                }
            };

            ForEachField(obj, action);
        }
Example #4
0
        public static void TranslateItemsFromFields(string category, object obj, Translation translation)
        {
            if (obj == null)
                return;

            Action<string, object, PropertyInfo> action = delegate(string item, object itemObj, PropertyInfo propertyInfo)
            {
                string value = translation.TranslateItem(category, item, propertyInfo.Name, null);
                if (value != null)
                    propertyInfo.SetValue(itemObj, value, null);
                else if (propertyInfo.Name == "ToolTipText" && !String.IsNullOrEmpty((string)propertyInfo.GetValue(itemObj, null)))
                {
                    value = translation.TranslateItem(category, item, "Text", null);
                    if (value != null)
                        propertyInfo.SetValue(itemObj, value, null);
                }
            };
            ForEachField(obj, action);
        }
 public virtual void TranslateItems(Translation translation)
 {
     Text = translation.TranslateItem(Name, "$this", "Text", Text);
     TranslationUtl.TranslateItemsFromFields(Name, this, translation);
 }
Example #6
0
 public static void TranslateItemsFromList(string category, Translation translation, IEnumerable<Tuple<string, object>> items)
 {
     Action<string, object, PropertyInfo> action = delegate(string item, object itemObj, PropertyInfo propertyInfo)
     {
         string value = translation.TranslateItem(category, item, propertyInfo.Name, null);
         if (!String.IsNullOrEmpty(value))
         {
             if (propertyInfo.CanWrite)
                 propertyInfo.SetValue(itemObj, value, null);
         }
         else if (propertyInfo.Name == "ToolTipText" && !String.IsNullOrEmpty((string)propertyInfo.GetValue(itemObj, null)))
         {
             value = translation.TranslateItem(category, item, "Text", null);
             if (!String.IsNullOrEmpty(value))
             {
                 if (propertyInfo.CanWrite)
                     propertyInfo.SetValue(itemObj, value, null);
             }
         }
     };
     ForEachItem(items, action);
 }