本文整理匯總了C#中AMFWriter.Flush方法的典型用法代碼示例。如果您正苦於以下問題:C# AMFWriter.Flush方法的具體用法?C# AMFWriter.Flush怎麽用?C# AMFWriter.Flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AMFWriter
的用法示例。
在下文中一共展示了AMFWriter.Flush方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SaveObject
private bool SaveObject(IPersistable obj) {
string filename = GetObjectFilename(obj);
FileInfo file = _scope.Context.GetResource(filename).File;
string path = file.DirectoryName;
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
lock (this.SyncRoot) {
MemoryStream ms = new MemoryStream();
AMFWriter writer = new AMFWriter(ms);
writer.UseLegacyCollection = false;
writer.WriteString(obj.GetType().FullName);
//amfSerializer.WriteData(ObjectEncoding.AMF0, obj);
obj.Serialize(writer);
writer.Flush();
byte[] buffer = ms.ToArray();
ms.Close();
using (FileStream fs = new FileStream(file.FullName, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) {
fs.Write(buffer, 0, buffer.Length);
fs.Close();
}
}
return true;
}