本文整理汇总了C#中ITranslation.AddTranslationItem方法的典型用法代码示例。如果您正苦于以下问题:C# ITranslation.AddTranslationItem方法的具体用法?C# ITranslation.AddTranslationItem怎么用?C# ITranslation.AddTranslationItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITranslation
的用法示例。
在下文中一共展示了ITranslation.AddTranslationItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTranslationItemsFromList
public static void AddTranslationItemsFromList(string category, ITranslation translation, IEnumerable<Tuple<string, object>> items)
{
Action<string, object, PropertyInfo> action = delegate(string item, object itemObj, PropertyInfo propertyInfo)
{
var value = (string)propertyInfo.GetValue(itemObj, null);
if (AllowTranslateProperty(value))
{
translation.AddTranslationItem(category, item, propertyInfo.Name, value);
}
};
ForEachItem(items, action);
}
示例2: AddTranslationItem
public static void AddTranslationItem(string category, object obj, string propName, ITranslation translation)
{
if (obj == null)
return;
var propertyInfo = obj.GetType().GetProperty(propName,
BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static |
BindingFlags.NonPublic | BindingFlags.SetProperty);
if (propertyInfo == null)
{
return;
}
var value = propertyInfo.GetValue(obj, null) as string;
if (value != null && AllowTranslateProperty(value))
{
translation.AddTranslationItem(category, propName, "Text", value);
}
}
示例3: AddTranslationItemsFromList
public static void AddTranslationItemsFromList(string category, ITranslation translation, IEnumerable<Tuple<string, object>> items)
{
foreach (var item in items)
{
var itemName = item.Item1;
var itemObj = item.Item2;
foreach (var property in GetItemPropertiesEnumerator(item))
{
var value = property.GetValue(itemObj, null);
if (value == null)
continue;
var valueStr = value as string;
if (valueStr != null)
{
if (AllowTranslateProperty(valueStr))
{
translation.AddTranslationItem(category, itemName, property.Name, valueStr);
}
continue;
}
var listItems = value as IList;
if (listItems != null)
{
for (int index = 0; index < listItems.Count; index++)
{
var listItem = listItems[index] as string;
if (AllowTranslateProperty(listItem))
{
translation.AddTranslationItem(category, itemName, "Item" + index, listItem);
}
}
}
}
}
}