public ModeContext(LittleEndianStream stream, WriteModes resetNode) { _stream = stream; _resetNode = resetNode; }
public static bool WriteCookie(string cookieName, string value, WriteModes mode) { bool retVal = false; bool newCookie = false; HttpCookie cookie = null; try { // Set a reference to the cookie cookie = HttpContext.Current.Request.Cookies[cookieName]; // Check to see if the cookie exists if (cookie == null) { // It doesnt, set a reference to a brand new cookie cookie = new HttpCookie(cookieName); // This is a new cookie newCookie = true; } // Check to see if we should overwrite the existing cookie if (mode == WriteModes.Overwrite) { // Set the cookie value. cookie.Value = value; // Set the cookie expiration date. cookie.Expires = DateTime.Now.AddDays(30); // Add the cookie. HttpContext.Current.Response.Cookies.Add(cookie); } else { // Dont write duplicate values to the cookie if (newCookie || !(cookie.Value.Contains(value))) { // Check to see if the cookie contains at least 1 value if (!(string.IsNullOrEmpty(cookie.Value))) { // It does, comma delimit the list cookie.Value += value + ","; } else { // Set the cookie value. cookie.Value = value + ","; } // Set the cookie expiration date. cookie.Expires = DateTime.Now.AddDays(30); // Add the cookie. HttpContext.Current.Response.Cookies.Add(cookie); } } // Success! retVal = true; } catch { } return(retVal); }
// Utilities /// ======================================================================================================= static string Save(string source_path, int res, double timebase, GroupBox gb, int rowcount, int?excluded_row = null, bool?up_down = null) { CAT.InteractiveAddOverlay("Saving " + source_path, API.CAT.Status.WARN); WriteModes mode = WriteModes.Normal; if (excluded_row != null && up_down != null && excluded_row != rowcount && !(bool)up_down) { mode = WriteModes.Down; } if (excluded_row != null && up_down != null && excluded_row != 1 && (bool)up_down) { mode = WriteModes.Up; } if (excluded_row != null && up_down == null) { mode = WriteModes.Exclude; } string newtext = ""; for (int row = 1; row <= rowcount; row++) { switch (mode) { case WriteModes.Normal: newtext += RowString(gb, row, res, timebase); break; case WriteModes.Exclude: if (row != excluded_row) { newtext += RowString(gb, row, res, timebase); } break; case WriteModes.Up: if (row == excluded_row - 1) { newtext += RowString(gb, row + 1, res, timebase); newtext += RowString(gb, row, res, timebase); row++; } else { newtext += RowString(gb, row, res, timebase); } break; case WriteModes.Down: if (row == excluded_row) { newtext += RowString(gb, row + 1, res, timebase); newtext += RowString(gb, row, res, timebase); row++; } else { newtext += RowString(gb, row, res, timebase); } break; } } try { if (!string.IsNullOrWhiteSpace(newtext)) { newtext = newtext.Remove(newtext.Length - 1, 1); File.WriteAllText(source_path, newtext); CAT.InteractiveAddOverlay("Saved " + source_path + " with data:\r\n" + newtext, API.CAT.Status.PASS); } } catch (Exception e) { CAT.InteractiveAddOverlay("Saving failed:\r\n" + API.CAT.ErrorMsg(e), API.CAT.Status.FAIL); } return(source_path); }
public WriteInfo(WriteModes writeMode, string message) { WriteMode = writeMode; MessageToWrite = message; }