private void loadMenuItem_Click(object sender, EventArgs e) { if (_openFileDialog.ShowDialog() == DialogResult.OK) { FileLocationName = _openFileDialog.FileName; LoadAction?.Invoke(); } }
private void LoadPluginSettings(string name, T plugin, string path = null) { path = path ?? GetDefaultSettingsPath(name, plugin); if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) { return; } var text = File.ReadAllText(path); LoadAction?.Invoke(plugin, text); }
private void LoadPluginSettings(string name, T plugin) { var path = GetSettingsFilePath(name); if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) { return; } var text = File.ReadAllText(path); var list = JsonConvert.DeserializeObject <List <SettingItem> >(text); if (list == null || plugin == null) { return; } LoadAction?.Invoke(plugin, list); }
private T ReadFile <T>(string filePath) { LoadAction <T> loadAction = null; switch (fileFormat) { case FileFormat.Binary: loadAction = ReadBinary <T>; break; case FileFormat.Xml: loadAction = ReadXml <T>; break; case FileFormat.Json: loadAction = ReadJson <T>; break; } return(loadAction.Invoke(filePath)); }
/// <summary> /// Gets the result by invoking the <see cref="LoadAction"/> if not already loaded. /// </summary> /// <returns> /// An <see cref="T:System.Collections.Generic.IEnumerable`1"/> that can be used to iterate through the collection. /// </returns> protected virtual IEnumerable <T> GetResult() { if (IsLoaded) { return(_result); } // no load action, run query directly if (LoadAction == null) { _isLoaded = true; _result = _query as IEnumerable <T>; return(_result); } // invoke the load action on the datacontext // result will be set with a callback to SetResult LoadAction.Invoke(); return(_result ?? Enumerable.Empty <T>()); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); LoadAction?.Invoke(); }
protected override void OnLoad(EventArgs e) { Text = "Produtos"; base.OnLoad(e); LoadAction?.Invoke(); }
private void Btn_load_match_Click(object sender, EventArgs e) { LoadAction?.Invoke(txt_card_match_path.Text); }