public T get(string key) { var cur = values_.get(key, default_.ToString()); cur = cur.Replace(within_value_separator_, "\r\n"); return((T)Convert.ChangeType(cur, typeof(T))); }
public dictionary_setting_readonly(settings_as_string sett, string name, T def = default(T)) { sett_ = sett; name_ = name; default_ = def; values_ = new settings_as_string(sett.get(name).Replace(separator_, "\r\n")); }
public T get() { var val = sett_.get(name_, default_.ToString()); if (can_be_multi_line_) { val = val.Replace(REPLACE_ENTER, "\r\n"); } return((T)Convert.ChangeType(val, typeof(T))); }
public void merge_settings(settings_as_string_readonly other_sett, bool edited_syntax_now) { if (edited_syntax_now) { if (default_settings_.get("syntax") == "") { default_settings_.set("syntax", other_sett.get("syntax")); } } default_settings_.set("aliases", other_sett.get("aliases")); default_settings_.set("description_template", other_sett.get("description_template")); }
public T get() { T o; if (Enum.TryParse <T>(sett_.get(name_, "" + default_), out o)) { return(o); } else { return(default_); } }
public file_text_reader(settings_as_string sett) : base(sett) { string file = sett.get("name"); buffer_ = new byte[max_read_in_one_go]; try { // get absolute path - normally, this should be the absolute path, but just to be sure file_ = new FileInfo(file).FullName; } catch { file_ = file; } var thread = app.inst.use_file_monitoring_api ? new Thread(read_all_file_thread_file_monitoring_api) {IsBackground = true} : new Thread(read_all_file_thread) {IsBackground = true}; thread.Start(); }
public file_text_reader(settings_as_string sett) : base(sett) { string file = sett.get("name"); buffer_ = new byte[max_read_in_one_go]; try { // get absolute path - normally, this should be the absolute path, but just to be sure file_ = new FileInfo(file).FullName; } catch { file_ = file; } var thread = app.inst.use_file_monitoring_api ? new Thread(read_all_file_thread_file_monitoring_api) { IsBackground = true } : new Thread(read_all_file_thread) { IsBackground = true }; thread.Start(); }
private void on_new_log() { string size = text_ is file_text_reader ? " (" + new FileInfo(text_.name).Length + " bytes)" : ""; set_status_forever("Log: " + text_.name + size); dropHere.Visible = false; if (history_.Count < 1) history_select(text_.settings); var reader_settings_copy = new settings_as_string( text_.settings.ToString() ); var context_settings_copy = new settings_as_string( settings_to_context(reader_settings_copy).default_settings.ToString()); context_settings_copy.merge(reader_settings_copy.ToString()); var file_text = text_ as file_text_reader; if (file_text != null) if ( factory.guess_file_type(file_text.name) == "line-by-line") if (reader_settings_copy.get("syntax") == "") { // file reader doesn't know syntax // by default - try to find the syntax by reading the header info; otherwise, try to parse it string file_to_syntax = log_to.file_to_syntax(text_.name); if (file_to_syntax != "") // note: file-to-syntax overrides the context syntax context_settings_copy.set("syntax", file_to_syntax); // note: if the context already knows syntax, use that else if (context_settings_copy.get("syntax") == "") { string found_syntax = file_text.try_to_find_log_syntax(); if (found_syntax != "" && found_syntax != file_text_reader.UNKNOWN_SYNTAX) context_settings_copy.set("syntax", found_syntax); } } text_.merge_setings( context_settings_copy); // note: we recreate the log, so that cached filters know to rebuild log_parser_ = new log_parser(text_); log_parser_.on_aliases_changed = on_aliases_changed; if ( text_.settings.get("description_template") != "") description.set_layout( text_.settings.get("description_template")); ui_context log_ctx = settings_to_context( text_.settings ); bool same_context = log_ctx == cur_context(); if (!same_context) { ++ignore_change_; // set_aliases context based on log curContextCtrl.SelectedIndex = contexts_.IndexOf(log_ctx); --ignore_change_; remove_all_log_views(); on_context_changed(); } full_log_ctrl_.set_filter(new List<raw_filter_row>()); on_new_log_parser(); load(); if (log_parser_.has_multi_line_columns) if (!app.inst.has_shown_details_pane) { app.inst.has_shown_details_pane = true; show_details(global_ui.show_details = true); } add_reader_to_history(); app.inst.set_log_file(selected_file_name()); Text = reader_title() + " - Log Wizard " + version(); logger.Info("new reader " + history_[logHistory.SelectedIndex].name); // at this point, some file has been dropped log_view_for_tab(0).Visible = true; notes.Enabled = text_ is file_text_reader; if (notes.Enabled) { notes.load(notes_keeper.inst.notes_file_for_file(text_.name)); merge_notes(); } util.postpone(update_list_view_edit, 250); util.postpone(check_are_settings_complete, 1500); }
/* 1.1.25+ - on new file (that does not match any context) - we will create a context matching the name of the file (if one exists, we will automatically select it) - by default, we'll never go to the "Default" context - the idea is for the uesr not to have to mistakenly delete a context when he's selecting a different type of file, (since he would want new filters). thus, just create a new context where he can do anything */ private void create_context_for_log(settings_as_string log_settings) { string context_name = log_settings.get("context"); if (contexts_.FirstOrDefault(x => x.name == context_name) != null) // in this case, I already have a context, and the context exists return; ui_context log_ctx = settings_to_context(log_settings); if (log_ctx.name != "Default") // we already have a context return; ui_context new_ctx = new ui_context(); contexts_.Add(new_ctx); switch (log_settings.get("type")) { case "file": string file = log_settings.get("name"); Debug.Assert(file != ""); new_ctx.name = Path.GetFileNameWithoutExtension(new FileInfo(file).Name); break; case "event_log": new_ctx.name = least_unused_context_name("Event Log"); break; case "debug_print": new_ctx.name = least_unused_context_name("Debug"); break; default: Debug.Assert(false); return; } Debug.Assert(new_ctx.name != ""); log_settings.set("context", new_ctx.name); update_contexts_combos_in_all_forms(); }
public bool get() { return((int)Convert.ChangeType(sett_.get(name_, default_ ? "1" : "0"), typeof(int)) != 0); }
private void on_new_log() { string size = text_ is file_text_reader ? " (" + new FileInfo(text_.name).Length + " bytes)" : ""; set_status_forever("Log: " + text_.name + size); dropHere.Visible = false; if (history_.Count < 1) history_select(text_.unique_id); var reader_settings_copy = new settings_as_string( text_.settings.ToString() ); var context_settings_copy = new settings_as_string( settings_to_context(reader_settings_copy).default_settings.ToString()); context_settings_copy.merge(reader_settings_copy.ToString()); var file_text = text_ as file_text_reader; if (file_text != null) if ( factory.guess_file_type(file_text.name) == "line-by-line") if (reader_settings_copy.get("syntax") == "") { // file reader doesn't know syntax // by default - try to find the syntax by reading the header info; otherwise, try to parse it string file_to_syntax = log_to.file_to_syntax(text_.name); if (file_to_syntax != "") { // note: file-to-syntax overrides the context syntax context_settings_copy.set("syntax", file_to_syntax); context_settings_copy.set("syntax_type", "file_to_syntax"); } // note: if the context already knows syntax, use that else if (context_settings_copy.get("syntax") == "") { string found_syntax = file_text.try_to_find_log_syntax(); if (found_syntax != "" && found_syntax != file_text_reader.UNKNOWN_SYNTAX) { context_settings_copy.set("syntax", found_syntax); context_settings_copy.set("syntax_type", "try_to_find_syntax"); } } } text_.merge_setings( context_settings_copy.ToString()); // note: we recreate the log, so that cached filters know to rebuild log_parser_ = new log_parser(text_); on_new_log_parser(); full_log_ctrl_.set_filter(new List<raw_filter_row>()); Text = reader_title() + " - Log Wizard " + version(); add_reader_to_history(); load_bookmarks(); logger.Info("new reader " + history_[logHistory.SelectedIndex].name); // at this point, some file has been dropped log_view_for_tab(0).Visible = true; notes.Enabled = text_ is file_text_reader; if (notes.Enabled) { notes.load(notes_keeper.inst.notes_file_for_file(text_.name)); merge_notes(); } util.postpone(update_list_view_edit, 250); util.postpone(check_are_settings_complete, 1500); }
public T get() { return((T)Convert.ChangeType(sett_.get(name_, default_.ToString()), typeof(T))); }