當前位置: 首頁>>代碼示例>>C#>>正文


C# Server.SaveMetrics類代碼示例

本文整理匯總了C#中Server.SaveMetrics的典型用法代碼示例。如果您正苦於以下問題:C# SaveMetrics類的具體用法?C# SaveMetrics怎麽用?C# SaveMetrics使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SaveMetrics類屬於Server命名空間,在下文中一共展示了SaveMetrics類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Save

 public override void Save( SaveMetrics metrics )
 {
     SaveMobiles( metrics );
     SaveItems( metrics );
     SaveGuilds( metrics );
     SaveMaps( metrics );
 }
開發者ID:kamronbatman,項目名稱:Defiance-AOS-Pre-2012,代碼行數:7,代碼來源:StandardSaveStrategy.cs

示例2: Save

		public override void Save(SaveMetrics metrics, bool permitBackgroundWrite)
		{
			_metrics = metrics;

			OpenFiles();

			var saveTasks = new Task[4];

			saveTasks[0] = SaveItems();
			saveTasks[1] = SaveMobiles();
			saveTasks[2] = SaveGuilds();
			saveTasks[3] = SaveData();

			SaveTypeDatabases();

			if (permitBackgroundWrite)
			{
				//This option makes it finish the writing to disk in the background, continuing even after Save() returns.
				Task.Factory.ContinueWhenAll(
					saveTasks,
					_ =>
					{
						CloseFiles();

						World.NotifyDiskWriteComplete();
					});
			}
			else
			{
				Task.WaitAll(saveTasks); //Waits for the completion of all of the tasks(committing to disk)
				CloseFiles();
			}
		}
開發者ID:jasegiffin,項目名稱:JustUO,代碼行數:33,代碼來源:DynamicSaveStrategy.cs

示例3: SaveGuilds

        protected void SaveGuilds( SaveMetrics metrics )
        {
            GenericWriter idx;
            GenericWriter bin;

            if ( World.SaveType == World.SaveOption.Normal ) {
                idx = new BinaryFileWriter( World.GuildIndexPath, false );
                bin = new BinaryFileWriter( World.GuildDataPath, true );
            } else {
                idx = new AsyncWriter( World.GuildIndexPath, false );
                bin = new AsyncWriter( World.GuildDataPath, true );
            }

            idx.Write( ( int ) BaseGuild.List.Count );
            foreach ( BaseGuild guild in BaseGuild.List.Values ) {
                long start = bin.Position;

                idx.Write( ( int ) 0 );//guilds have no typeid
                idx.Write( ( int ) guild.Id );
                idx.Write( ( long ) start );

                guild.Serialize( bin );

                if ( metrics != null ) {
                    metrics.OnGuildSaved( ( int ) ( bin.Position - start ) );
                }

                idx.Write( ( int ) ( bin.Position - start ) );
            }

            idx.Close();
            bin.Close();
        }
開發者ID:notsentient,項目名稱:RunZHA,代碼行數:33,代碼來源:StandardSaveStrategy.cs

示例4: Save

		public override void Save( SaveMetrics metrics, bool permitBackgroundWrite )
		{
			this.PermitBackgroundWrite = permitBackgroundWrite;

#if Framework_4_0
			Task saveItemsTask = Task.Factory.StartNew(() => SaveItems(metrics));
#else
			Thread saveThread = new Thread( delegate() {
				SaveItems(metrics);
			} );

			saveThread.Name = "Item Save Subset";
			saveThread.Start();
#endif

			SaveMobiles( metrics );
			SaveGuilds( metrics );
			SaveMaps( metrics );

#if Framework_4_0
			saveItemsTask.Wait();
#else
			saveThread.Join();
#endif

			if (permitBackgroundWrite && UseSequentialWriters)	//If we're permitted to write in the background, but we don't anyways, then notify.
				World.NotifyDiskWriteComplete();
		}
開發者ID:greeduomacro,項目名稱:UO-Forever,代碼行數:28,代碼來源:DualSaveStrategy.cs

示例5: Save

        public override void Save(SaveMetrics metrics, bool permitBackgroundWrite)
        {
            _permitBackgroundWrite = permitBackgroundWrite;

            SaveMobiles(metrics);
            SaveItems(metrics);
            SaveGuilds(metrics);

            if (permitBackgroundWrite && UseSequentialWriters)	//If we're permitted to write in the background, but we don't anyways, then notify.
                World.NotifyDiskWriteComplete();
        }
開發者ID:Godkong,項目名稱:RunUO,代碼行數:11,代碼來源:StandardSaveStrategy.cs

示例6: SaveMobiles

		protected void SaveMobiles(SaveMetrics metrics)
		{
			Dictionary<Serial, Mobile> mobiles = World.Mobiles;

			GenericWriter idx;
			GenericWriter tdb;
			GenericWriter bin;

			if (UseSequentialWriters)
			{
				idx = new BinaryFileWriter(World.MobileIndexPath, false);
				tdb = new BinaryFileWriter(World.MobileTypesPath, false);
				bin = new BinaryFileWriter(World.MobileDataPath, true);
			}
			else
			{
				idx = new AsyncWriter(World.MobileIndexPath, false);
				tdb = new AsyncWriter(World.MobileTypesPath, false);
				bin = new AsyncWriter(World.MobileDataPath, true);
			}

			idx.Write(mobiles.Count);

			foreach (Mobile m in mobiles.Values)
			{
				long start = bin.Position;

				idx.Write(m._TypeRef);
				idx.Write(m.Serial);
				idx.Write(start);

				m.Serialize(bin);

				if (metrics != null)
				{
					metrics.OnMobileSaved((int)(bin.Position - start));
				}

				idx.Write((int)(bin.Position - start));

				m.FreeCache();
			}

			tdb.Write(World.m_MobileTypes.Count);

			foreach (Type t in World.m_MobileTypes)
			{
				tdb.Write(t.FullName);
			}

			idx.Close();
			tdb.Close();
			bin.Close();
		}
開發者ID:rokann,項目名稱:JustUO,代碼行數:54,代碼來源:StandardSaveStrategy.cs

示例7: SequentialFileWriter

		public SequentialFileWriter(string path, SaveMetrics metrics)
		{
			if (path == null)
			{
				throw new ArgumentNullException("path");
			}

			this.metrics = metrics;

			fileStream = FileOperations.OpenSequentialStream(path, FileMode.Create, FileAccess.Write, FileShare.None);

			fileQueue = new FileQueue(Math.Max(1, FileOperations.Concurrency), FileCallback);
		}
開發者ID:jasegiffin,項目名稱:JustUO,代碼行數:13,代碼來源:SequentialFileWriter.cs

示例8: Save

		public override void Save( SaveMetrics metrics ) {
			Thread saveThread = new Thread( delegate() {
				SaveItems( metrics );
			} );

			saveThread.Name = "Item Save Subset";
			saveThread.Start();

			SaveMobiles( metrics );
			SaveGuilds( metrics );

			saveThread.Join();
		}
開發者ID:PepeBiondi,項目名稱:runsa,代碼行數:13,代碼來源:DualSaveStrategy.cs

示例9: SaveMobiles

		protected void SaveMobiles( SaveMetrics metrics ) {
			Dictionary<Serial, Mobile> mobiles = World.Mobiles;

			GenericWriter idx;
			GenericWriter tdb;
			GenericWriter bin;

			if ( World.SaveType == World.SaveOption.Normal ) {
				idx = new BinaryFileWriter( World.MobileIndexPath, false );
				tdb = new BinaryFileWriter( World.MobileTypesPath, false );
				bin = new BinaryFileWriter( World.MobileDataPath, true );
			} else {
				idx = new AsyncWriter( World.MobileIndexPath, false );
				tdb = new AsyncWriter( World.MobileTypesPath, false );
				bin = new AsyncWriter( World.MobileDataPath, true );
			}

			idx.Write( ( int ) mobiles.Count );
			foreach ( Mobile m in mobiles.Values ) {
				long start = bin.Position;

				idx.Write( ( int ) m.m_TypeRef );
				idx.Write( ( int ) m.Serial );
				idx.Write( ( long ) start );

				m.Serialize( bin );

				if ( metrics != null ) {
					metrics.OnMobileSaved( ( int ) ( bin.Position - start ) );
				}

				idx.Write( ( int ) ( bin.Position - start ) );

				m.FreeCache();
			}

			tdb.Write( ( int ) World.m_MobileTypes.Count );

			for ( int i = 0; i < World.m_MobileTypes.Count; ++i )
				tdb.Write( World.m_MobileTypes[i].FullName );

			idx.Close();
			tdb.Close();
			bin.Close();
		}
開發者ID:PepeBiondi,項目名稱:runsa,代碼行數:45,代碼來源:StandardSaveStrategy.cs

示例10: Save

        public override void Save( SaveMetrics metrics, bool permitBackgroundWrite )
        {
            this.PermitBackgroundWrite = permitBackgroundWrite;

            Thread saveThread = new Thread( delegate() {
                SaveItems(metrics);
            } );

            saveThread.Name = "Item Save Subset";
            saveThread.Start();

            SaveMobiles(metrics);
            SaveGuilds(metrics);

            saveThread.Join();

            if (permitBackgroundWrite && UseSequentialWriters)	//If we're permitted to write in the background, but we don't anyways, then notify.
                World.NotifyDiskWriteComplete();
        }
開發者ID:Godkong,項目名稱:RunUO,代碼行數:19,代碼來源:DualSaveStrategy.cs

示例11: SaveItems

        protected void SaveItems(SaveMetrics metrics)
        {
            Dictionary<Serial, Item> items = World.Items;

            GenericWriter idx;
            GenericWriter tdb;
            GenericWriter bin;

            if (UseSequentialWriters)
            {
                idx = new BinaryFileWriter( World.ItemIndexPath, false );
                tdb = new BinaryFileWriter( World.ItemTypesPath, false );
                bin = new BinaryFileWriter( World.ItemDataPath, true );
            } else {
                idx = new AsyncWriter( World.ItemIndexPath, false );
                tdb = new AsyncWriter( World.ItemTypesPath, false );
                bin = new AsyncWriter( World.ItemDataPath, true );
            }

            idx.Write( ( int ) items.Count );
            foreach ( Item item in items.Values ) {
                if ( item.Decays && item.Parent == null && item.Map != Map.Internal && ( item.LastMoved + item.DecayTime ) <= DateTime.Now ) {
                    _decayQueue.Enqueue( item );
                }

                long start = bin.Position;

                idx.Write( ( int ) item.m_TypeRef );
                idx.Write( ( int ) item.Serial );
                idx.Write( ( long ) start );

                item.Serialize( bin );

                if ( metrics != null ) {
                    metrics.OnItemSaved( ( int ) ( bin.Position - start ) );
                }

                idx.Write( ( int ) ( bin.Position - start ) );

                item.FreeCache();
            }

            tdb.Write( ( int ) World.m_ItemTypes.Count );
            for ( int i = 0; i < World.m_ItemTypes.Count; ++i )
                tdb.Write( World.m_ItemTypes[i].FullName );

            idx.Close();
            tdb.Close();
            bin.Close();
        }
開發者ID:Godkong,項目名稱:RunUO,代碼行數:50,代碼來源:StandardSaveStrategy.cs

示例12: Save

		public abstract void Save( SaveMetrics metrics );
開發者ID:PepeBiondi,項目名稱:runsa,代碼行數:1,代碼來源:SaveStrategy.cs

示例13: Save

 public abstract void Save(SaveMetrics metrics, bool permitBackgroundWrite);
開發者ID:FreeReign,項目名稱:imaginenation,代碼行數:1,代碼來源:SaveStrategy.cs

示例14: SaveData

        protected void SaveData(SaveMetrics metrics)
        {
            Dictionary<CustomSerial, SaveData> data = World.Data;

            GenericWriter indexWriter;
            GenericWriter typeWriter;
            GenericWriter dataWriter;

            if (this.UseSequentialWriters)
            {
                indexWriter = new BinaryFileWriter(World.DataIndexPath, false);
                typeWriter = new BinaryFileWriter(World.DataTypesPath, false);
                dataWriter = new BinaryFileWriter(World.DataBinaryPath, true);
            }
            else
            {
                indexWriter = new AsyncWriter(World.DataIndexPath, false);
                typeWriter = new AsyncWriter(World.DataTypesPath, false);
                dataWriter = new AsyncWriter(World.DataBinaryPath, true);
            }

            indexWriter.Write(data.Count);

            foreach (SaveData saveData in data.Values)
            {
                long start = dataWriter.Position;

                indexWriter.Write(saveData._TypeID);
                indexWriter.Write((int)saveData.Serial);
                indexWriter.Write(start);

                saveData.Serialize(dataWriter);

                if (metrics != null)
                    metrics.OnDataSaved((int)(dataWriter.Position - start));

                indexWriter.Write((int)(dataWriter.Position - start));
            }

            typeWriter.Write(World._DataTypes.Count);

            for (int i = 0; i < World._DataTypes.Count; ++i)
                typeWriter.Write(World._DataTypes[i].FullName);

            indexWriter.Close();
            typeWriter.Close();
            dataWriter.Close();
        }
開發者ID:Tukaramdas,項目名稱:ServUO-EC-Test-Fork,代碼行數:48,代碼來源:StandardSaveStrategy.cs

示例15: SaveMaps

		protected void SaveMaps( SaveMetrics metrics )
		{
			Dictionary<Serial, BaseInstanceMap> maps = World.Maps;

			GenericWriter idx;
			GenericWriter tdb;
			GenericWriter bin;

			if (UseSequentialWriters)
			{
				idx = new BinaryFileWriter( World.MapIndexPath, false );
				tdb = new BinaryFileWriter( World.MapTypesPath, false );
				bin = new BinaryFileWriter( World.MapDataPath, true );
			}
			else
			{
				idx = new AsyncWriter( World.MapIndexPath, false );
				tdb = new AsyncWriter( World.MapTypesPath, false );
				bin = new AsyncWriter( World.MapDataPath, true );
			}

			idx.Write( ( int ) maps.Count );

			foreach ( BaseInstanceMap map in maps.Values )
			{
				if ( map.Decays )
					_decayMapQueue.Enqueue( map );

				long start = bin.Position;

				idx.Write( ( int ) map.TypeReference );
				idx.Write( ( int ) map.Serial );
				idx.Write( ( long ) start );

				map.Serialize( bin );

				if ( metrics != null )
					metrics.OnMapSaved( ( int ) ( bin.Position - start ) );

				idx.Write( ( int ) ( bin.Position - start ) );
			}

			tdb.Write( ( int ) World.m_InstanceMapTypes.Count );
			for ( int i = 0; i < World.m_InstanceMapTypes.Count; ++i )
				tdb.Write( World.m_InstanceMapTypes[i].FullName );

			idx.Close();
			tdb.Close();
			bin.Close();
		}
開發者ID:greeduomacro,項目名稱:UO-Forever,代碼行數:50,代碼來源:StandardSaveStrategy.cs


注:本文中的Server.SaveMetrics類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。