/// <summary> /// 取消调用 /// </summary> public void Cancel() { Action <string> onGet = this.onGet; UriString = null; UriBytes.SetNull(); LinkNext = null; this.onGet = null; AutoCSer.Threading.RingPool <Uri> .Default.PushNotNull(this); onGet(null); }
private unsafe void deSerialize(AutoCSer.BinarySerialize.DeSerializer deSerializer) { byte *read = deSerializer.Read; int size = *(int *)read; if (size <= 0) { if (size == 0) { Buffer.SetNull(); State = (MemberState)(byte)*(int *)(read + sizeof(int)); deSerializer.Read += sizeof(int) * 2; } else { Buffer.Start = -size; deSerializer.Read += sizeof(int); } } else if (size == Buffer.Length) { if (deSerializer.MoveReadAny(sizeof(int) + size + (-size & 3))) { fixed(byte *bufferFixed = Buffer.Array) AutoCSer.Memory.CopyNotNull(read + sizeof(int), bufferFixed + Buffer.Start, size); State = MemberState.Remote; } } else { deSerializer.State = BinarySerialize.DeSerializeState.IndexOutOfRange; } }
internal void SetFile(byte[] name, byte[] fileName, string saveFileName) { this.name.Set(name, 0, name.Length); value.SetNull(); FileName = fileName; SaveFileName = saveFileName; }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (Interlocked.CompareExchange(ref isDisposed, 1, 0) == 0) { array.SetNull(); bufferCount.Free(); } }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { BufferCount bufferCount = Interlocked.Exchange(ref this.bufferCount, null); if (bufferCount != null) { bufferCount.Free(); array.SetNull(); } }
/// <summary> /// 获取缩略图 /// </summary> /// <param name="data">输出数据</param> /// <param name="width">缩略宽度</param> /// <param name="height">缩略高度</param> /// <param name="type">目标图像文件格式</param> /// <param name="backColor">背景色</param> /// <param name="seek">输出数据起始位置</param> public void Pad(ref SubArray <byte> data, ref int width, ref int height, ImageFormat type, Color backColor, int seek) { if (checkPad(ref width, ref height)) { using (MemoryStream stream = new MemoryStream()) { if (seek != 0) { stream.Seek(seek, SeekOrigin.Begin); } pad(stream, width, height, type, backColor); data.Set(stream.GetBuffer(), seek, (int)stream.Position - seek); return; } } data.SetNull(); }
/// <summary> /// 图像缩略切剪 /// </summary> /// <param name="data">图像文件数据</param> /// <param name="width">缩略宽度,0表示与高度同比例</param> /// <param name="height">缩略高度,0表示与宽度同比例</param> /// <param name="type">目标图像文件格式</param> /// <param name="seek">输出数据起始位置</param> /// <returns>图像缩略文件数据</returns> public static void Cut(ref SubArray <byte> data, int width, int height, ImageFormat type, int seek = 0) { if (data.Length != 0 && width > 0 && height > 0 && (width | height) != 0 && seek >= 0) { try { using (MemoryStream memory = new MemoryStream(data.Array, data.Start, data.Length)) { ThumbnailBuilder builder = new ThumbnailBuilder(); using (Image image = builder.CreateImage(memory)) { builder.Cut(ref data, ref width, ref height, type, seek); return; } } } catch (Exception error) { AutoCSer.Log.Pub.Log.Add(Log.LogType.Error, error); } } data.SetNull(); }
/// <summary> /// 图像缩略补白 /// </summary> /// <param name="data">图像文件数据</param> /// <param name="width">缩略宽度,0表示与高度同比例</param> /// <param name="height">缩略高度,0表示与宽度同比例</param> /// <param name="type">目标图像文件格式</param> /// <param name="backColor">背景色</param> /// <param name="seek">输出数据起始位置</param> /// <returns>图像缩略文件数据</returns> public static void Pad(ref SubArray <byte> data, int width, int height, ImageFormat type, Color backColor, int seek = 0) { if (data.Length != 0 && width > 0 && height > 0 && (width | height) != 0 && seek >= 0) { try { using (MemoryStream memory = new MemoryStream(data.Array, data.Start, data.Length)) { ThumbnailBuilder builder = new ThumbnailBuilder(); using (Image image = builder.CreateImage(memory)) { builder.Pad(ref data, ref width, ref height, type, backColor, seek); return; } } } catch (Exception error) { AutoCSer.LogHelper.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer); } } data.SetNull(); }
/// <summary> /// Cookie 数据写入缓冲区 /// </summary> /// <param name="start"></param> /// <returns></returns> internal Cookie Write(ref byte *start) { writeSetCookie(start); byte *write = start + setCookieSize; int index = Name.Length; AutoCSer.Memory.Common.SimpleCopyNotNull64(Name, write, index); write += index; Name = null; *write++ = (byte)'='; if ((index = Value.Length) != 0) { AutoCSer.Memory.Common.SimpleCopyNotNull64(Value, write, index); Value = null; write += index; } if ((index = Domain.Length) != 0) { writeCookieDomain(write); fixed(byte *domainFixed = Domain.GetFixedBuffer()) AutoCSer.Memory.Common.SimpleCopyNotNull64(domainFixed + Domain.Start, write += cookieDomainSize, index); Domain.SetNull(); write += index; } if (Path != null) { writeCookiePath(write); write += cookiePathSize; if ((index = Path.Length) != 0) { AutoCSer.Memory.Common.SimpleCopyNotNull64(Path, write, index); write += index; } Path = null; } if (Expires != DateTime.MinValue) { writeCookieExpires(write); write += cookieExpiresSize; if (Expires == AutoCSer.Date.BaseTime) { writeMinTimeCookieExpires(write); } else { Date.ToBytes(Expires, write); } write += Date.ToByteLength; } if (IsSecure) { writeCookieSecure(write); write += cookieSecureSize; } if (IsHttpOnly) { writeCookieHttpOnly(write); write += cookieHttpOnlySize; } *(short *)write = 0x0a0d; start = write + sizeof(short); return(LinkNext); }