本文整理汇总了C#中SIL.Utils.StringTable.LocalizeLiteralValue方法的典型用法代码示例。如果您正苦于以下问题:C# StringTable.LocalizeLiteralValue方法的具体用法?C# StringTable.LocalizeLiteralValue怎么用?C# StringTable.LocalizeLiteralValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIL.Utils.StringTable
的用法示例。
在下文中一共展示了StringTable.LocalizeLiteralValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StringsFor
//.........这里部分代码省略.........
{
int chvo;
sda.VecProp(hvo, flid, ctarget, out chvo, arrayPtr);
contents = MarshalEx.NativeToArray<int>(arrayPtr, chvo);
}
string[] result = null;
string targetLayoutName = XmlVc.GetLayoutName(layout, caller); // also allows for finding "param" attr in caller, if not null
int i = 0;
foreach (int hvoTarget in contents)
{
int prevResultLength = GetArrayLength(result);
XmlNode layoutTarget = GetLayoutNodeForChild(sda, hvoTarget, flid, targetLayoutName, layout, layoutCache);
if (layoutTarget == null)
continue; // should not happen, but best recovery we can make
result = Concatenate(result, ChildKeys(fdoCache, sda, layoutTarget, hvoTarget, layoutCache, caller, stringTbl, wsForce));
// add a separator between the new childkey group and the previous childkey group
if (i > 0 && prevResultLength != GetArrayLength(result) && prevResultLength > 0)
{
int ichIns = 0;
if (result[prevResultLength - 1] != null)
ichIns = result[prevResultLength - 1].Length;
AddSeparator(ref result[prevResultLength - 1], ichIns, layout);
}
++i;
}
return result;
}
case "choice":
{
foreach(XmlNode whereNode in layout.ChildNodes)
{
if (whereNode.Name != "where")
{
if (whereNode.Name == "otherwise")
return StringsFor(fdoCache, sda, XmlUtils.GetFirstNonCommentChild(whereNode), hvo, layoutCache, caller, stringTbl, wsForce);
continue; // ignore any other nodes,typically comments
}
// OK, it's a where node.
if (XmlVc.ConditionPasses(whereNode, hvo, fdoCache, sda, caller))
return StringsFor(fdoCache, sda, XmlUtils.GetFirstNonCommentChild(whereNode), hvo, layoutCache, caller, stringTbl, wsForce);
}
break; // if no condition passes and no otherwise, return null.
}
case "if":
{
if (XmlVc.ConditionPasses(layout, hvo, fdoCache, sda, caller))
return StringsFor(fdoCache, sda, XmlUtils.GetFirstNonCommentChild(layout), hvo, layoutCache, caller, stringTbl, wsForce);
break;
}
case "ifnot":
{
if (!XmlVc.ConditionPasses(layout, hvo, fdoCache, sda, caller))
return StringsFor(fdoCache, sda, XmlUtils.GetFirstNonCommentChild(layout), hvo, layoutCache, caller, stringTbl, wsForce);
break;
}
case "lit":
{
string literal = layout.InnerText;
if (stringTbl != null)
{
string sTranslate = XmlUtils.GetOptionalAttributeValue(layout, "translate", "");
if (sTranslate.Trim().ToLower() != "do not translate")
literal = stringTbl.LocalizeLiteralValue(literal);
}
return new[] { literal };
}
case "int":
{
int flid = GetFlid(sda, layout, hvo);
int val = sda.get_IntProp(hvo, flid);
return new[] {AlphaCompNumberString(val)};
}
case "datetime":
{
int flid = GetFlid(sda, layout, hvo);
CellarPropertyType itype = (CellarPropertyType)sda.MetaDataCache.GetFieldType(flid);
if (itype == CellarPropertyType.Time)
{
DateTime dt = SilTime.GetTimeProperty(sda, hvo, flid);
return new[] {DateTimeCompString(dt)};
}
else
{
string stFieldName = XmlUtils.GetManditoryAttributeValue(layout, "field");
throw new Exception("Bad field type (" + stFieldName + " for hvo " + hvo + " found for " +
layout.Name + " property " + flid + " in " + layout.OuterXml);
}
}
case "picture":
// Treat a picture as a non-empty string for purposes of deciding whether something is empty.
// This string seems as good as anything for other purposes.
return new[] {"a picture"};
default: // unknown or comment node, adds nothing
Debug.Assert(false, "unrecognized XML node.");
break;
}
return new string[0]; // don't know how to sort, treat as empty key.
}
示例2: Create
//.........这里部分代码省略.........
}
case "summary":
{
slice = new SummarySlice();
break;
}
case "enumcombobox":
{
slice = new EnumComboSlice(cache, obj, flid, stringTbl, node["deParams"]);
break;
}
case "referencecombobox":
{
slice = new ReferenceComboBoxSlice(cache, obj, flid, persistenceProvider);
break;
}
case "typeaheadrefatomic":
{
slice = new AtomicRefTypeAheadSlice(obj, flid);
break;
}
case "msareferencecombobox":
{
slice = new MSAReferenceComboBoxSlice(cache, obj, flid, persistenceProvider);
break;
}
case "lit": // was "message"
{
string message = XmlUtils.GetManditoryAttributeValue(node, "message");
if (stringTbl != null)
{
string sTranslate = XmlUtils.GetOptionalAttributeValue(node, "translate", "");
if (sTranslate.Trim().ToLower() != "do not translate")
message = stringTbl.LocalizeLiteralValue(message);
}
slice = new MessageSlice(message);
break;
}
case "picture":
{
slice = new PictureSlice((ICmPicture)obj);
break;
}
case "image":
{
try
{
slice = new ImageSlice(FwDirectoryFinder.CodeDirectory, XmlUtils.GetManditoryAttributeValue(node, "param1"));
}
catch (Exception error)
{
slice = new MessageSlice(String.Format(DetailControlsStrings.ksImageSliceFailed,
error.Message));
}
break;
}
case "checkbox":
{
slice = new CheckboxSlice(cache, obj, flid, node);
break;
}
case "checkboxwithrefresh":
{
slice = new CheckboxRefreshSlice(cache, obj, flid, node);
break;
}
示例3: Create
public static Slice Create(FdoCache cache, string editor, int flid, XmlNode node, ICmObject obj,
StringTable stringTbl, IPersistenceProvider persistenceProvider, Mediator mediator, XmlNode caller)
{
Slice slice = null;
switch(editor)
{
case "string":
{
if (flid == 0)
throw new ApplicationException("field attribute required for basic properties " + node.OuterXml);
int ws = GetWs(mediator, cache, node);
if (ws != 0)
slice = new StringSlice(obj.Hvo, flid, ws);
else
slice = new StringSlice(obj.Hvo, flid);
break;
}
case "multistring":
{
if (flid == 0)
throw new ApplicationException("field attribute required for multistring " + node.OuterXml);
string wsSpec = XmlUtils.GetOptionalAttributeValue(node, "ws");
int wsMagic;
wsMagic = LangProject.GetMagicWsIdFromName(wsSpec);
if (wsMagic == 0)
throw new ApplicationException(
"ws must be 'all vernacular', 'all analysis', 'analysis vernacular', or 'vernacular analysis'"
+ " it said '" + wsSpec + "'.");
bool forceIncludeEnglish = XmlUtils.GetOptionalBooleanAttributeValue(node, "forceIncludeEnglish", false);
bool spellCheck = XmlUtils.GetOptionalBooleanAttributeValue(node, "spell", true);
bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true);
slice = new MultiStringSlice(obj.Hvo, flid, wsMagic, forceIncludeEnglish, editable, spellCheck);
break;
}
case "jtview":
{
string layout = XmlUtils.GetOptionalAttributeValue(caller, "param");
if (layout == null)
layout = XmlUtils.GetManditoryAttributeValue(node, "layout");
// Editable if BOTH the caller (part ref) AND the node itself (the slice) say so...or at least if neither says not.
bool editable = XmlUtils.GetOptionalBooleanAttributeValue(caller, "editable", true)
&& XmlUtils.GetOptionalBooleanAttributeValue(node, "editable", true);
slice = new ViewSlice(new XmlView(obj.Hvo, layout, stringTbl, editable));
break;
}
case "summary":
{
slice = new SummarySlice(obj, caller, node, stringTbl);
break;
}
case "enumcombobox":
{
slice = new EnumComboSlice(cache, obj, flid, stringTbl, node["deParams"]);
break;
}
case "referencecombobox":
{
slice = new ReferenceComboBoxSlice(cache, obj, flid, persistenceProvider, mediator);
break;
}
case "typeaheadrefatomic":
{
slice = new AtomicRefTypeAheadSlice(obj.Hvo, flid);
break;
}
case "msareferencecombobox":
{
slice = new MSAReferenceComboBoxSlice(cache, obj, flid, persistenceProvider, mediator);
break;
}
case "lit": // was "message"
{
string message = XmlUtils.GetManditoryAttributeValue(node, "message");
if (stringTbl != null)
{
string sTranslate = XmlUtils.GetOptionalAttributeValue(node, "translate", "");
if (sTranslate.Trim().ToLower() != "do not translate")
message = stringTbl.LocalizeLiteralValue(message);
}
slice = new MessageSlice(message);
break;
}
case "picture":
{
slice = new PictureSlice((FDO.Cellar.CmPicture) obj);
break;
}
case "image":
{
try
{
slice = new ImageSlice(DirectoryFinder.FWCodeDirectory, XmlUtils.GetManditoryAttributeValue(node, "param1"));
}
catch (Exception error)
{
slice = new MessageSlice(String.Format(DetailControlsStrings.ksImageSliceFailed,
error.Message));
}
break;
//.........这里部分代码省略.........