当前位置: 首页>>代码示例>>C#>>正文


C# DeflateStream.Dispose方法代码示例

本文整理汇总了C#中Ionic.Zlib.DeflateStream.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# DeflateStream.Dispose方法的具体用法?C# DeflateStream.Dispose怎么用?C# DeflateStream.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ionic.Zlib.DeflateStream的用法示例。


在下文中一共展示了DeflateStream.Dispose方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

 internal void Read()
 {
     try
     {
         using (FileStream fileStream = File.OpenRead(this.Name))
         {
             using (DeflateStream deflateStream = new DeflateStream(fileStream, CompressionMode.Decompress))
             {
                 using (BinaryReader binaryReader = new BinaryReader(deflateStream))
                 {
                     int num = (int)binaryReader.ReadByte();
                     for (int i = 0; i < num; i++)
                     {
                         this.AddFile(binaryReader.ReadString(), binaryReader.ReadBytes(binaryReader.ReadInt32()));
                     }
                 }
                 deflateStream.Dispose();
             }
         }
     }
     catch
     {
         this.InvalidFile = true;
     }
 }
开发者ID:CXUtk,项目名称:TmodKiller,代码行数:25,代码来源:TmodIO.cs

示例2: Save

        public void Save()
        {
            if (!EnterSave())
                return;

            Stream zip = new DeflateStream(File.Create(DataFile + ".tmp"), CompressionMode.Compress);
            try
            {
                zip.WriteByte(0); // version

                zip.WriteByte(Convert.ToByte(LightToRecalculate));
                for (int x = 0; x < 16; ++x)
                {
                    for (int z = 0; z < 16; ++z)
                    {
                        zip.WriteByte(HeightMap[x, z]);
                    }
                }
                WriteAllBlocks(zip);
                zip.Flush();
            }
            finally
            {
                try
                {
                    zip.Dispose();
                    File.Delete(DataFile);
                    File.Move(DataFile + ".tmp", DataFile);
                }
                catch
                {
                }
                finally
                {
                    ExitSave();
                }
            }
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:38,代码来源:Chunk.cs

示例3: Load

        public static Chunk Load(UniversalCoords coords, WorldManager world)
        {
            string path = world.Folder + "/x" + coords.ChunkX + "_z" + coords.ChunkZ + ".gz";

            if (!CanLoad(path))
                return null;

            Stream zip = null;

            Chunk chunk = new Chunk(world, coords);

            try
            {
                zip = new DeflateStream(File.Open(path, FileMode.Open), CompressionMode.Decompress);

                int version = zip.ReadByte();

                switch(version)
                {
                    /* When there's a new mod you do:
                    case 1:
                    {
                     * dosomething
                     * goto case 0;
                    }*/
                    case 0:
                    {
                        chunk.LightToRecalculate = Convert.ToBoolean(zip.ReadByte());
                        chunk.HeightMap = new byte[16,16];
                        int height;
                        chunk.MaxHeight = 0;
                        for (int x = 0; x < 16; ++x)
                        {
                            for (int z = 0; z < 16; ++z)
                            {
                                height = chunk.HeightMap[x, z] = (byte) zip.ReadByte();

                                if (chunk.MaxHeight < height)
                                    chunk.MaxHeight = height;
                            }
                        }
                        chunk.LoadAllBlocks(zip);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                world.Logger.Log(ex);
                return null;
            }
            if (zip != null)
                zip.Dispose();

            (BlockHelper.Instance((byte) BlockData.Blocks.Sign_Post) as BlockSignBase).LoadSignsFromDisk(chunk, world.SignsFolder);

            return chunk;
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:58,代码来源:Chunk.cs

示例4: Save

        public void Save()
        {
            if (!EnterSave())
                return;

            Stream zip = new DeflateStream(File.Create(DataFile + ".tmp"), CompressionMode.Compress);
            try
            {
                WriteAllBlocks(zip);
                zip.Flush();
            }
            finally
            {
                try
                {
                    zip.Dispose();
                    File.Delete(DataFile);
                    File.Move(DataFile + ".tmp", DataFile);
                }
                catch
                {
                }
                finally
                {
                    ExitSave();
                }
            }
        }
开发者ID:dredge20,项目名称:c-raft,代码行数:28,代码来源:Chunk.cs

示例5: Load

        public bool Load()
        {
            if (!CanLoad())
                return false;

            Stream zip = null;
            Monitor.Enter(_SavingLock);
            try
            {
                zip = new DeflateStream(File.Open(DataFile, FileMode.Open), CompressionMode.Decompress);
                LoadAllBlocks(zip);
                return true;
            }
            catch (Exception ex)
            {
                World.Logger.Log(ex);
                return false;
            }
            finally
            {
                Monitor.Exit(_SavingLock);
                if (zip != null)
                    zip.Dispose();
            }
        }
开发者ID:dredge20,项目名称:c-raft,代码行数:25,代码来源:Chunk.cs

示例6: SaveMap


//.........这里部分代码省略.........
													num7++;
													num8++;
												}
											}
										}
										if (b5 > 0)
										{
											b3 |= (byte)(b5 << 1);
										}
										if (b3 != 0)
										{
											b4 |= 1;
										}
										b4 |= (byte)(num5 << 1);
										if (flag3 && num6 > 255)
										{
											b4 |= 16;
										}
										if (flag4)
										{
											b4 |= 32;
										}
										if (num7 > 0)
										{
											if (num7 > 255)
											{
												b4 |= 128;
											}
											else
											{
												b4 |= 64;
											}
										}
										array[num] = b4;
										num++;
										if (b3 != 0)
										{
											array[num] = b3;
											num++;
										}
										if (flag3)
										{
											array[num] = (byte)num6;
											num++;
											if (num6 > 255)
											{
												array[num] = (byte)(num6 >> 8);
												num++;
											}
										}
										if (flag4)
										{
											array[num] = mapTile.Light;
											num++;
										}
										if (num7 > 0)
										{
											array[num] = (byte)num7;
											num++;
											if (num7 > 255)
											{
												array[num] = (byte)(num7 >> 8);
												num++;
											}
										}
										for (int m = num3; m < num4; m++)
										{
											array[num] = Main.Map[m, j].Light;
											num++;
										}
										k += num7;
										if (num >= 4096)
										{
											deflateStream.Write(array, 0, num);
											num = 0;
										}
									}
								}
								if (num > 0)
								{
									deflateStream.Write(array, 0, num);
								}
								deflateStream.Dispose();
								FileUtilities.WriteAllBytes(text, memoryStream.ToArray(), isCloudSave);
							}
						}
					}
				}
				catch (Exception value)
				{
					using (StreamWriter streamWriter = new StreamWriter("client-crashlog.txt", true))
					{
						streamWriter.WriteLine(DateTime.Now);
						streamWriter.WriteLine(value);
						streamWriter.WriteLine("");
					}
				}
				MapHelper.saveLock = false;
			}
		}
开发者ID:thegamingboffin,项目名称:Ulterraria_Reborn_GitHub,代码行数:101,代码来源:MapHelper.cs

示例7: lock


//.........这里部分代码省略.........
                                 }
                                 if (flag4)
                                 {
                                     array[num] = mapTile.Light;
                                     num++;
                                 }
                                 if (num7 > 0)
                                 {
                                     array[num] = (byte)num7;
                                     num++;
                                     if (num7 > 255)
                                     {
                                         array[num] = (byte)(num7 >> 8);
                                         num++;
                                     }
                                 }
                                 for (int m = num3; m < num4; m++)
                                 {
                                     array[num] = Main.Map[m, j].Light;
                                     num++;
                                 }
                                 k += num7;
                                 if (num >= 4096)
                                 {
                                     deflateStream.Write(array, 0, num);
                                     num = 0;
                                 }
                             }
                         }
                         if (num > 0)
                         {
                             deflateStream.Write(array, 0, num);
                         }
                         deflateStream.Dispose();
                         FileUtilities.WriteAllBytes(text, memoryStream.ToArray(), isCloudSave);
                     }
                 }
             }
         }
         catch (Exception value)
         {
             using (StreamWriter streamWriter = new StreamWriter("client-crashlog.txt", true))
             {
                 streamWriter.WriteLine(DateTime.Now);
                 streamWriter.WriteLine(value);
                 streamWriter.WriteLine("");
             }
         }
         MapHelper.saveLock = false;
     }
 }*/
 public static void SaveMap()
 {
     int i;
     int num;
     int num1;
     ushort type;
     int num2;
     bool isCloudSave = Main.ActivePlayerFileData.IsCloudSave;
     if (isCloudSave && SocialAPI.Cloud == null)
     {
         return;
     }
     if (!Main.mapEnabled || MapHelper.saveLock)
     {
         return;
开发者ID:MEFBAEA,项目名称:mefbaea,代码行数:67,代码来源:MapHelper.cs

示例8: Load

        public bool Load()
        {
            if (!CanLoad())
                return false;

            Stream zip = null;
            Monitor.Enter(_SavingLock);
            try
            {
                zip = new DeflateStream(File.Open(DataFile, FileMode.Open), CompressionMode.Decompress);
                HeightMap = new byte[16, 16];
                for (int x = 0; x < 16; ++x)
                {
                    for (int z = 0; z < 16; ++z)
                    {
                        HeightMap[x, z] = (byte)zip.ReadByte();
                    }
                }
                LoadAllBlocks(zip);
                return true;
            }
            catch (Exception ex)
            {
                World.Logger.Log(ex);
                return false;
            }
            finally
            {
                Monitor.Exit(_SavingLock);
                if (zip != null)
                    zip.Dispose();
            }
        }
开发者ID:StianLohna,项目名称:c-raft,代码行数:33,代码来源:Chunk.cs

示例9: CompressTileBlock

		public static int CompressTileBlock(int xStart, int yStart, short width, short height, byte[] buffer, int bufferStart)
		{
			int result;
			using (MemoryStream memoryStream = new MemoryStream())
			{
				using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
				{
					binaryWriter.Write(xStart);
					binaryWriter.Write(yStart);
					binaryWriter.Write(width);
					binaryWriter.Write(height);
					NetMessage.CompressTileBlock_Inner(binaryWriter, xStart, yStart, (int)width, (int)height);
					int num = buffer.Length;
					if ((long)bufferStart + memoryStream.Length > (long)num)
					{
						result = (int)((long)(num - bufferStart) + memoryStream.Length);
					}
					else
					{
						memoryStream.Position = 0L;
						MemoryStream memoryStream2 = new MemoryStream();
						using (DeflateStream deflateStream = new DeflateStream(memoryStream2, 0, true))
						{
							memoryStream.CopyTo(deflateStream);
							deflateStream.Flush();
							deflateStream.Close();
							deflateStream.Dispose();
						}
						if (memoryStream.Length <= memoryStream2.Length)
						{
							memoryStream.Position = 0L;
							buffer[bufferStart] = 0;
							bufferStart++;
							memoryStream.Read(buffer, bufferStart, (int)memoryStream.Length);
							result = (int)memoryStream.Length + 1;
						}
						else
						{
							memoryStream2.Position = 0L;
							buffer[bufferStart] = 1;
							bufferStart++;
							memoryStream2.Read(buffer, bufferStart, (int)memoryStream2.Length);
							result = (int)memoryStream2.Length + 1;
						}
					}
				}
			}
			return result;
		}
开发者ID:thegamingboffin,项目名称:Ulterraria_Reborn_GitHub,代码行数:49,代码来源:NetMessage.cs


注:本文中的Ionic.Zlib.DeflateStream.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。