本文整理汇总了C#中WinterLeaf.Engine.Classes.View.Creators.ObjectCreator.writeObject方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectCreator.writeObject方法的具体用法?C# ObjectCreator.writeObject怎么用?C# ObjectCreator.writeObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WinterLeaf.Engine.Classes.View.Creators.ObjectCreator
的用法示例。
在下文中一共展示了ObjectCreator.writeObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: save
//.........这里部分代码省略.........
currentFile = GuiEditor["LastPath"] + "/" + name;
currentFile = Util.makeRelativePath(currentFile, Util.getMainDotCsDir());
}
else
currentFile = Util._expandFilename(name);
}
else
currentFile = Util._expandFilename(currentFile);
}
// Get the filename.
string filename;
if (!noPrompt)
{
filename = GuiEditorFileDialog.GuiBuilder.GetSaveName(currentFile);
// console.Call_Classname("GuiBuilder", "getSaveName", new string[] {currentFile} );
if (filename == "")
return;
}
else
filename = currentFile;
// Save the Gui.
if (Util.isWriteableFileName(filename))
{
//
// Extract any existent TorqueScript before writing out to disk
//
FileObject fileObject = new ObjectCreator("FileObject").Create();
fileObject.openForRead(filename);
bool skipLines = true;
bool beforeObject = true;
// var++ does not post-increment var, in torquescript, it pre-increments it,
// because ++var is illegal.
//int lines = -1;
//int beforeLines = -1;
skipLines = false;
//string[] beforeNewFileLines = new string[]{};
//string[] newFileLines = new string[]{};
List<string> beforeNewFileLines = new List<string>();
List<string> newFileLines = new List<string>();
while (!fileObject.isEOF())
{
string line = fileObject.readLine();
if (line == "//--- OBJECT WRITE BEGIN ---")
skipLines = true;
else if (line == "//--- OBJECT WRITE END ---")
{
skipLines = false;
beforeObject = false;
}
else if (skipLines == false)
{
if (beforeObject)
beforeNewFileLines.Add(line);
//beforeNewFileLines[ beforeLines++ ] = line;
else
//newFileLines[ lines++ ] = line;
newFileLines.Add(line);
}
}
fileObject.close();
fileObject.delete();
FileObject fo = new ObjectCreator("FileObject").Create();
fo.openForWrite(filename);
// Write out the captured TorqueScript that was before the object before the object
foreach (string line in beforeNewFileLines)
fo.writeLine(line);
//for(int i = 0; i <= beforeLines; i++)
// fo.writeLine( beforeNewFileLines[ i ] );
fo.writeLine("//--- OBJECT WRITE BEGIN ---");
fo.writeObject(currentObject, "%guiContent = ");
fo.writeLine("//--- OBJECT WRITE END ---");
// Write out captured TorqueScript below Gui object
//for( int i = 0; i <= lines; i++ )
// fo.writeLine( newFileLines[ i ] );
foreach (string line in newFileLines)
fo.writeLine(line);
fo.close();
fo.delete();
currentObject.setFilename(Util.makeRelativePath(filename, Util.getMainDotCsDir()));
GuiEditorStatusBar.print("Saved file '" + currentObject.getFilename() + "'");
}
else
Util.messageBox("Error writing to file", "There was an error writing to file '" + currentFile + "'. The file may be read-only.", "Ok", "Error");
}