本文整理汇总了C#中EnumCollection.Translate方法的典型用法代码示例。如果您正苦于以下问题:C# EnumCollection.Translate方法的具体用法?C# EnumCollection.Translate怎么用?C# EnumCollection.Translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnumCollection
的用法示例。
在下文中一共展示了EnumCollection.Translate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadEnums
public override EnumCollection ReadEnums(StreamReader specFile)
{
// First, read all enum definitions from spec and override file.
// Afterwards, read all token/enum overrides from overrides file.
// Every single enum is merged into
EnumCollection enums = new EnumCollection();
Enum all = new Enum() { Name = Settings.CompleteEnumName };
XPathDocument specs = new XPathDocument(specFile);
XPathDocument overrides = new XPathDocument(new StreamReader(Path.Combine(Settings.InputPath, functionOverridesFile)));
foreach (XPathNavigator nav in new XPathNavigator[] {
specs.CreateNavigator().SelectSingleNode("/signatures"),
overrides.CreateNavigator().SelectSingleNode("/overrides/add") })
{
if (nav != null)
{
foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty))
{
Enum e = new Enum()
{
Name = node.GetAttribute("name", String.Empty),
Type = node.GetAttribute("type", String.Empty)
};
if (String.IsNullOrEmpty(e.Name))
throw new InvalidOperationException(String.Format("Empty name for enum element {0}", node.ToString()));
foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element))
{
Constant c = new Constant(param.GetAttribute("name", String.Empty), param.GetAttribute("value", String.Empty));
Utilities.Merge(all, c);
try { e.ConstantCollection.Add(c.Name, c); }
catch (ArgumentException ex) { Console.WriteLine("[Warning] Failed to add constant {0} to enum {1}: {2}", c.Name, e.Name, ex.Message); }
}
Utilities.Merge(enums, e);
}
}
}
Utilities.Merge(enums, all);
enums.Translate(overrides);
return enums;
}