本文整理汇总了C#中Internal.AddEntity方法的典型用法代码示例。如果您正苦于以下问题:C# Internal.AddEntity方法的具体用法?C# Internal.AddEntity怎么用?C# Internal.AddEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Internal
的用法示例。
在下文中一共展示了Internal.AddEntity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public static void Parse(
CharStream stream, string identifier,
Internal.LocaleContext.Builder builder)
{
var startingPos = stream.Position;
try
{
// private identifiers start with an underscore
// and can only be referenced from within an l20n file
bool isPrivate = (identifier.IndexOf('_') == 0);
// an optional index is possible
AST.INode index = null;
Index.PeekAndParse(stream, out index);
// White Space is required
WhiteSpace.Parse(stream, false);
var valuePos = stream.Position;
// Now we need the actual value
var value = Value.Parse(stream);
if ((value as IO.AST.HashValue) == null && index != null)
{
string msg = String.Format(
"an index was given, but a stringValue was given, while a hashValue was expected",
stream.ComputeDetailedPosition(valuePos));
throw new Exceptions.ParseException(msg);
}
// an optional attributes collection is possible
AST.Attributes attributes;
Attributes.PeekAndParse(stream, out attributes);
// White Space is optional
WhiteSpace.Parse(stream, true);
stream.SkipCharacter('>');
var entityAST = new AST.Entity(identifier, isPrivate, index, value, attributes);
try
{
var entity = (Objects.Entity)entityAST.Eval();
builder.AddEntity(identifier, entity);
} catch (Exception e)
{
throw new Exceptions.EvaluateException(
String.Format("couldn't evaluate `{0}`", entityAST.Display()),
e);
}
} catch (Exception e)
{
string msg = String.Format(
"something went wrong parsing an <entity> starting at {0}",
stream.ComputeDetailedPosition(startingPos));
throw new Exceptions.ParseException(msg, e);
}
}