本文整理汇总了C#中Server.BinaryFileWriter.Write方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryFileWriter.Write方法的具体用法?C# BinaryFileWriter.Write怎么用?C# BinaryFileWriter.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.BinaryFileWriter
的用法示例。
在下文中一共展示了BinaryFileWriter.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public static void Save()
{
try
{
if (!Directory.Exists(General.SavePath))
Directory.CreateDirectory(General.SavePath);
GenericWriter writer = new BinaryFileWriter(Path.Combine(General.SavePath, "Gumps.bin"), true);
writer.Write(0); // version
writer.Write(s_ForceMenu);
writer.Write(s_ForceInfos.Count);
foreach (GumpInfo ginfo in s_ForceInfos.Values)
ginfo.Save(writer);
ArrayList list = new ArrayList();
GumpInfo info;
foreach (object o in new ArrayList(s_Infos.Values))
{
if (!(o is Hashtable))
continue;
foreach (object ob in new ArrayList(((Hashtable)o).Values))
{
if (!(ob is GumpInfo))
continue;
info = (GumpInfo)ob;
if (info.Mobile != null
&& info.Mobile.Player
&& !info.Mobile.Deleted
&& info.Mobile.Account != null
&& ((Account)info.Mobile.Account).LastLogin > DateTime.Now - TimeSpan.FromDays(30))
list.Add(ob);
}
}
writer.Write(list.Count);
foreach (GumpInfo ginfo in list)
ginfo.Save(writer);
writer.Close();
}
catch (Exception e)
{
Errors.Report(General.Local(199));
Console.WriteLine(e.Message);
Console.WriteLine(e.Source);
Console.WriteLine(e.StackTrace);
}
}
示例2: SerializeMessages
public static void SerializeMessages()
{
if( !Directory.Exists( SavePath ) )
Directory.CreateDirectory( SavePath );
BinaryFileWriter writer = new BinaryFileWriter( SaveFile, true );
writer.Write( (int)_messageTable.Count );
if( _messageTable.Count > 0 )
{
foreach( KeyValuePair<Mobile, List<ChatMessage>> kvp in _messageTable )
{
if( kvp.Key == null || kvp.Key.Deleted || kvp.Value == null )
{
writer.Write( (int)-1 );
}
else
{
writer.Write( (int)kvp.Key.Serial );
writer.Write( (int)kvp.Value.Count );
kvp.Value.ForEach(
delegate( ChatMessage message )
{
message.Serialize( writer );
} );
}
}
}
writer.Close();
}
示例3: CustomSeperateSave
public static void CustomSeperateSave(SeperateSaveData data)
{
GenericWriter writer = new BinaryFileWriter(Path.Combine(data.SaveLocation, data.SaveName + ".bin"), true);
DirectoryCheck(data.SaveLocation);
data.SaveMethod(writer);
writer.Write(writer.Position);
writer.Close();
}
示例4: OnSave
private static void OnSave( WorldSaveEventArgs e )
{try{
if ( !Directory.Exists( "Saves/Gumps/" ) )
Directory.CreateDirectory( "Saves/Gumps/" );
GenericWriter writer = new BinaryFileWriter( Path.Combine( "Saves/Gumps/", "Gumps.bin" ), true );
writer.Write( 0 ); // version
ArrayList list = new ArrayList();
GumpInfo gumpi;
foreach( object obj in new ArrayList( s_Infos.Values ) )
{
if ( !(obj is Hashtable) )
continue;
foreach( object obje in new ArrayList( ((Hashtable)obj).Values ) )
{
if ( !(obje is GumpInfo ) )
continue;
gumpi = (GumpInfo)obje;
if ( gumpi.Mobile != null
&& gumpi.Mobile.Player
&& !gumpi.Mobile.Deleted
&& gumpi.Mobile.Account != null
&& ((Account)gumpi.Mobile.Account).LastLogin > DateTime.Now - TimeSpan.FromDays( 30 ) )
list.Add( obje );
}
}
writer.Write( list.Count );
foreach( GumpInfo info in list )
info.Save( writer );
writer.Close();
}catch{ Errors.Report( "GumpInfo-> OnSave" ); } }
示例5: Save
public static void Save(bool message)
{
if (m_Saving || AsyncWriter.ThreadCount > 0)
return;
// we make certain we cannot save when we are in ServerWars
if (World.SaveType == World.SaveOption.NoSaves)
{
Console.WriteLine("Error: Save aborted: World.SaveType == World.SaveOption.NoSaves");
return;
}
NetState.FlushAll();
m_Saving = true;
if (message)
Broadcast(0x35, true, "The world is saving, please wait.");
Console.WriteLine("World: Saving...");
DateTime startTime = DateTime.Now;
// Adam: see comments in the function
PackMemory(true);
if (!Directory.Exists("Saves/Mobiles/"))
Directory.CreateDirectory("Saves/Mobiles/");
if (!Directory.Exists("Saves/Items/"))
Directory.CreateDirectory("Saves/Items/");
if (!Directory.Exists("Saves/Guilds/"))
Directory.CreateDirectory("Saves/Guilds/");
if (!Directory.Exists("Saves/Regions/"))
Directory.CreateDirectory("Saves/Regions/");
if (m_MultiProcessor)
{
Thread saveThread = new Thread(new ThreadStart(SaveItems));
saveThread.Name = "Item Save Subset";
saveThread.Start();
SaveMobiles();
SaveGuilds();
SaveRegions();
saveThread.Join();
}
else
{
SaveMobiles();
SaveItems();
SaveGuilds();
SaveRegions();
}
//Accounts.Save();
try
{
EventSink.InvokeWorldSave(new WorldSaveEventArgs(message));
}
catch (Exception e)
{
throw new Exception("World Save event threw an exception. Save failed!", e);
}
/* Adam, not currently used
DateTime copy = DateTime.Now;
if (Directory.Exists("Saves/Temp"))
Directory.Delete("Saves/Temp", true);
if (Directory.Exists("Temp"))
CopyDirectory("Temp", "Saves/Temp");
Console.WriteLine("Copying Temp/ took {0}ms", (DateTime.Now - copy).TotalMilliseconds);
*/
// take care of some World class-specific stuff
try
{
BinaryFileWriter w = new BinaryFileWriter("Saves/World.dat", true);
w.Write((int)1); // version
// version 1
w.Write(m_ReservedSerials.Keys.Count);
foreach (int i in m_ReservedSerials.Keys)
w.Write(i);
// version 0
w.Write((bool)m_FreezeDryEnabled);
w.Close();
}
catch (Exception e)
{
Console.WriteLine("Error writing World.dat:");
Console.WriteLine(e.ToString());
}
// Adam: final cleanup
PackMemory(false);
//.........这里部分代码省略.........
示例6: SaveGlobalOptions
public static void SaveGlobalOptions()
{
CleanUpData();
if (!Directory.Exists(General.SavePath))
Directory.CreateDirectory(General.SavePath);
GenericWriter writer = new BinaryFileWriter(Path.Combine(General.SavePath, "GlobalOptions.bin"), true);
writer.Write(2); // version
writer.Write(s_MultiPort);
writer.Write(s_MultiServer);
writer.Write(s_Notifications.Count);
foreach (Notification not in s_Notifications)
not.Save(writer);
writer.Write(s_Filters.Count);
foreach (string str in s_Filters)
writer.Write(str);
writer.Write((int)s_FilterPenalty);
writer.Write((int)s_MacroPenalty);
writer.Write(s_MaxMsgs);
writer.Write(s_ChatSpam);
writer.Write(s_MsgSpam);
writer.Write(s_RequestSpam);
writer.Write(s_FilterBanLength);
writer.Write(s_FilterWarnings);
writer.Write(s_AntiMacroDelay);
writer.Write(s_IrcPort);
writer.Write(s_IrcMaxAttempts);
writer.Write(s_IrcEnabled);
writer.Write(s_IrcAutoConnect);
writer.Write(s_IrcAutoReconnect);
writer.Write(s_FilterSpeech);
writer.Write(s_FilterMsg);
writer.Write(s_Debug);
writer.Write(s_LogChat);
writer.Write(s_LogPms);
writer.Write((int)s_IrcStaffColor);
writer.Write(s_IrcServer);
writer.Write(s_IrcRoom);
writer.Write(s_IrcNick);
writer.Write(s_TotalChats+1);
writer.Close();
}
示例7: SaveBackup
public static void SaveBackup( Mobile mobile, ArrayList ArgsList )
{
MC.SetProcess( Process.SaveBackup );
if ( !Directory.Exists( MC.BackupDirectory ) )
Directory.CreateDirectory( MC.BackupDirectory );
string path = Path.Combine( MC.BackupDirectory, "Backup.mbk" );
mobile.SendMessage( "Creating backup file..." );
MC.CheckSpawners();
ArrayList SpawnerList = CompileSpawnerList();
GenericWriter writer;
try
{
writer = new BinaryFileWriter( path, true );
}
catch(Exception ex)
{
MC.SetProcess( Process.None );
ArgsList[2] = "Create Backup File";
ArgsList[4] = String.Format( "Exception caught:\n{0}", ex );
mobile.SendGump( new FileMenuGump( mobile, ArgsList ) );
return;
}
writer.Write( SpawnerList.Count );
try
{
foreach ( MegaSpawner megaSpawner in SpawnerList )
Serialize( megaSpawner, writer );
}
catch{}
writer.Close();
MC.SetProcess( Process.None );
ArgsList[2] = "Create Backup File";
ArgsList[4] = "All Mega Spawners have now been backed up to the backup file.";
mobile.SendGump( new FileMenuGump( mobile, ArgsList ) );
}
示例8: Save
public static void Save( WorldSaveEventArgs args )
{
if( !Directory.Exists( "Saves/ACC" ) )
Directory.CreateDirectory( "Saves/ACC" );
string filename = "acc.sav";
string path [email protected]"Saves/ACC/";
string pathNfile = path+filename;
DateTime start = DateTime.Now;
Console.WriteLine();
Console.WriteLine();
Console.WriteLine( "----------" );
Console.WriteLine( "Saving ACC..." );
try
{
using( FileStream m_FileStream = new FileStream( pathNfile, FileMode.OpenOrCreate, FileAccess.Write ) )
{
BinaryFileWriter writer = new BinaryFileWriter( m_FileStream, true );
writer.Write( (int) m_RegSystems.Count );
foreach( DictionaryEntry de in m_RegSystems )
{
Type t = ScriptCompiler.FindTypeByFullName( (string)de.Key );
if( t != null )
{
writer.Write( (string)de.Key );
writer.Write( (bool)de.Value );
if( (bool)m_RegSystems[(string)de.Key] )
{
ACCSystem system = (ACCSystem)Activator.CreateInstance( t );
if( system != null )
system.StartSave( path );
}
}
}
writer.Close();
m_FileStream.Close();
}
Console.WriteLine( "Done in {0:F1} seconds.", (DateTime.Now-start).TotalSeconds );
Console.WriteLine( "----------" );
Console.WriteLine();
}
catch( Exception err )
{
Console.WriteLine( "Failed. Exception: "+err );
}
}
示例9: Save
public static void Save()
{
log.Info("Saving...");
log.Info(String.Format("idxPath: '{0}'", idxPath));
log.Info(String.Format("binPath: '{0}'", binPath));
if (!Directory.Exists(Path.Combine("Saves", "Donation")))
Directory.CreateDirectory(Path.Combine("Saves", "Donation"));
GenericWriter idx = new BinaryFileWriter(idxPath, false);
GenericWriter bin = new BinaryFileWriter(binPath, true);
log.Info(String.Format("m_ClaimedOrders.Count: '{0}'", m_ClaimedOrders.Count));
idx.Write((int)m_ClaimedOrders.Count);
foreach (ClaimedOrder claimed in m_ClaimedOrders)
{
long startPos = bin.Position;
claimed.Serialize(bin);
idx.Write((long)startPos);
idx.Write((int)(bin.Position - startPos));
}
idx.Close();
bin.Close();
log.Info("Saving done.");
}
示例10: Serialize
public virtual void Serialize( BinaryFileWriter writer )
{
writer.Write( (int)0 );
//version 0
writer.WriteMobileList<Mobile>( _buddyList, true );
writer.Write( _client );
writer.WriteMobileList<Mobile>( _ignoreList, true );
writer.Write( _visible );
}
示例11: Serialize
public void Serialize(BinaryFileWriter writer)
{
writer.Write((int)0); //Version
writer.Write((string)serialString.ToString());
writer.WriteMobile(allianceLeader);
writer.Write((int)membersOf.Count);
foreach (Mobile m in membersOf)
{
writer.WriteMobile(m);
}
writer.Write((int)childGuilds.Count);
foreach (Guild g in childGuilds)
{
writer.WriteGuild(g);
}
writer.Write((string)allianceName);
writer.Write((int)primaryHue);
writer.Write((int)secondaryHue);
writer.Write((int)mountBody);
writer.Write((int)mountID);
}
示例12: EventSink_WorldSave
private static void EventSink_WorldSave( WorldSaveEventArgs e )
{
DateTime start = DateTime.Now;
Console.WriteLine( "processing additional components." );
Console.WriteLine( "Forums: Saving..." );
if( AutoCleanup )
Console.Write( "Auto Cleanup is checking posts..." );
else
Console.Write( "Checking deletion queue..." );
int queue = 0;
int deleted = RemovedDeletedQueue(out queue);
if( queue == 0 )
Console.Write( "Empty Queue..." );
else
Console.Write( "{1} Queued...{0} Deleted...", deleted, queue );
string SavePath = Path.Combine( m_SavePath, "forumdata.sig" );
if( !Directory.Exists( m_SavePath ) )
Directory.CreateDirectory( m_SavePath );
GenericWriter bin = new BinaryFileWriter( SavePath, true );
try
{
bin.Write( ( int )0 );//Versioning
WritePlayerStatistics( bin );
bin.Write( ( int )( m_Threads.Count ) );
foreach( ThreadEntry te in m_Threads )
{
te.Serialize( bin );
}
bin.WriteMobileList( m_Moderators );
bin.Write( ( int )m_ThreadDeleteAccessLevel );
bin.Write( ( int )m_ThreadLockAccesLevel );
bin.Write( ( bool )m_AutoCleanup );
bin.Write( ( int )m_AutoCleanupDays );
bin.Write( ( int )m_MinPostCharactersCount );
bin.Write( ( int )m_MaxPostCharactersCount );
bin.Close();
DateTime end = DateTime.Now;
Console.WriteLine( "done in {0:F1} seconds.", ( end - start ).TotalSeconds );
Console.Write( "World: " );
}
catch( Exception err )
{
bin.Close();
Console.Write( "An error occurred while trying to save the forums. {0}", err.ToString());
}
}
示例13: OnSave
private static void OnSave( WorldSaveEventArgs e )
{
try{
if ( !Directory.Exists( "Saves/Commands/" ) )
Directory.CreateDirectory( "Saves/Commands/" );
GenericWriter writer = new BinaryFileWriter( Path.Combine( "Saves/Commands/", "Commands.bin" ), true );
writer.Write( 0 ); // version
ArrayList list = new ArrayList( s_Defaults.Values );
writer.Write( list.Count );
foreach( DefaultInfo info in list )
{
writer.Write( info.NewCommand );
writer.Write( info.OldCommand );
writer.Write( (int)info.NewAccess );
}
writer.Close();
}catch{ Errors.Report( "Commands-> OnSave" ); }
}
示例14: OnSave
public static void OnSave(WorldSaveEventArgs e)
{
try
{
Console.WriteLine("KinCityManager Saving...");
if (!Directory.Exists("Saves/AngelIsland"))
Directory.CreateDirectory("Saves/AngelIsland");
string filePath = Path.Combine("Saves/AngelIsland", "KinCityManager.bin");
GenericWriter writer;
writer = new BinaryFileWriter(filePath, true);
writer.Write(1); //version
//v1 below
//write out the city data class'
writer.Write(_cityData.Count);
foreach (KeyValuePair<KinFactionCities, KinCityData> pair in _cityData)
pair.Value.Save(writer);
writer.Close();
}
catch (Exception ex)
{
System.Console.WriteLine("Error saving KinCityManager!");
Scripts.Commands.LogHelper.LogException(ex);
}
}
示例15: Save
public static void Save()
{
try
{
if (!Directory.Exists(General.SavePath))
Directory.CreateDirectory(General.SavePath);
GenericWriter writer = new BinaryFileWriter(Path.Combine(General.SavePath, "Channels.bin"), true);
writer.Write(0); // version
writer.Write(s_Channels.Count);
foreach (Channel c in s_Channels)
{
writer.Write(c.GetType().ToString());
c.Save(writer);
}
writer.Close();
}
catch (Exception e)
{
Errors.Report(General.Local(187));
Console.WriteLine(e.Message);
Console.WriteLine(e.Source);
Console.WriteLine(e.StackTrace);
}
}