public override void ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, string operationName) { using (var source = new System.IO.FileStream(fi.FullName, System.IO.FileMode.Open)) { var bytes = source.ReadAllBytes(); httpRes.OutputStream.Write(bytes, 0, bytes.Length); } // timeStamp = fi.LastWriteTime; httpRes.AddHeader("Date", DateTime.Now.ToString("R")); httpRes.AddHeader("Content-Type", ExtensionContentType.Safeget(fi.Extension) ?? "text/plain"); }
public AvatarOffsetsNew(byte[] avatarBytes, string originalFile) { // Check offsets byte[] originalAvatarBytes = null; using (var avatarStream = new System.IO.FileStream(originalFile, System.IO.FileMode.Open)) { originalAvatarBytes = avatarStream.ReadAllBytes(); } var originalOffsets = new AvatarOffsetsOriginal(); PropertyInfo[] properties = this.GetType().GetInterface("IAvatarOffset").GetProperties(); foreach (PropertyInfo pi in properties) { if (pi.Name.ToLower().Contains("offset") && !pi.Name.ToLower().Contains("blink") && !pi.Name.ToLower().Contains("enable") && !pi.Name.ToLower().Contains("encoded") && !pi.Name.ToLower().Contains("seed") && !pi.Name.ToLower().Contains("pointer")) { var newValue = avatarBytes[(int)pi.GetValue(this, null)]; var oldValue = originalAvatarBytes[(int)pi.GetValue(originalOffsets, null)]; if (newValue != oldValue) { throw new Exception($"Offset {pi.Name} appears to be wrong."); } } else if (pi.Name.ToLower().Contains("blink_cast")) { var newValue = avatarBytes[(int)pi.GetValue(this, null)]; if (!(newValue == 0xc0 || newValue == 0xff)) { throw new Exception($"Offset {pi.Name} appears to be wrong."); } } else if (pi.Name.ToLower().Contains("blink_destination")) { var newValue = avatarBytes[(int)pi.GetValue(this, null)]; if (!(newValue == 0x01 || newValue == 0x02)) { throw new Exception($"Offset {pi.Name} appears to be wrong."); } } else if (pi.Name.Contains("enable")) { var newValue = avatarBytes[(int)pi.GetValue(this, null)]; if (newValue != 0x08) { throw new Exception($"Offset {pi.Name} appears to be wrong."); } } } }