本文整理汇总了C#中Generator.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Generator.Save方法的具体用法?C# Generator.Save怎么用?C# Generator.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Generator
的用法示例。
在下文中一共展示了Generator.Save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
TotemGrammar tg = new TotemGrammar();
Irony.Parsing.Parser parser = new Irony.Parsing.Parser(tg);
var tree = parser.Parse(new StreamReader(File.OpenRead("test.pole")).ReadToEnd(), "test.pole");
if (!tree.HasErrors())
{
var generator = new Generator("test", Path.Combine(Environment.CurrentDirectory, "test.exe"), tg);
var rootNode = tree.Root;
generator.GenerateProgram(rootNode);
generator.Save();
}
else
{
Console.WriteLine("Error in input");
Console.ReadLine();
}
}
示例2: TryFix
public bool TryFix(string errorMessage, Generator gen)
{
Match m = ID.Match (errorMessage);
if (!m.Success)
return false;
string typeName = m.Groups [1].Value;
string oldMember = m.Groups [2].Value;
string newMember = oldMember + "2";
bool memberFound = false;
CodeContainer type = gen.GetPath (typeName.Split ('.').Skip (1).ToArray ());
foreach (var method in type.Atoms.OfType<Method> ()) {
if (method.FormattedName == oldMember) {
method.FormattedName = newMember;
memberFound = true;
break;
}
}
if (!memberFound) {
foreach (var prop in type.Atoms.OfType<Property> ()) {
if (prop.Name == oldMember) {
prop.Name = newMember;
memberFound = true;
break;
}
}
}
if (memberFound) {
//Console.WriteLine ("Renaming \"{0}\" to \"{1}\" to prevent name collision in class \"{2}\" ...", oldMember, newMember, typeName);
gen.Save ();
}
return memberFound;
}