public static void WriteToStream(Tag value, StreamAccessor accessor, out System.Action <long> SetSize) { long pos_size; Stream stream = new MemoryStream(); StreamAccessor accessor2 = new StreamAccessor(stream); StreamAccessor accessor3 = null; long start = 0L; if (value.has_ext) { value.WriteExtHeader(accessor2, out accessor3); start = stream.Position; } foreach (Frame frame in value.frames.Values) { accessor2.WriteAs <Frame>(frame); } if (value.has_ext) { long length = stream.Position - start; accessor3.Write(ID3Utils.CalculateCRC32(stream, start, length), EncodingType.U4BE); accessor3.Stream.Close(); } bool unsync = ID3Utils.ID3RequiredUnsync(stream); if (unsync) { Stream stream2 = ID3Utils.ID3Unsynchronize(stream); stream.Close(); stream = stream2; } value.WriteTagHeader(accessor, unsync, out pos_size); SetSize = delegate(long size){ if (size > StreamAccessor.MaxUInt28) { throw new System.ArgumentOutOfRangeException("Tag の情報量が多すぎて保存できません。Tag の内容は 256MB より小さくなる様にして下さい"); } accessor.PushPosition(pos_size); accessor.Write((uint)size, EncodingType.UInt28BE); accessor.PopPosition(); }; accessor.WriteStream(stream); }