Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
 }
Esempio n. 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);
 }