private void installFromckanToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog open_file_dialog = new OpenFileDialog { Filter = Resources.CKANFileFilter }; if (open_file_dialog.ShowDialog() == DialogResult.OK) { var path = open_file_dialog.FileName; CfanModule module; try { module = CfanFileManager.fromCfanFile(path); } catch (Kraken kraken) { m_User.RaiseError(kraken.Message + ": " + kraken.InnerException.Message); return; } catch (Exception ex) { m_User.RaiseError(ex.Message); return; } // We'll need to make some registry changes to do this. RegistryManager registry_manager = RegistryManager.Instance(CurrentInstance); // Remove this version of the module in the registry, if it exists. registry_manager.registry.RemoveAvailable(module); // Sneakily add our version in... registry_manager.registry.AddAvailable(module); var changeset = new List <ModChange>(); changeset.Add(new ModChange( new GUIMod(module, registry_manager.registry, CurrentInstance.Version()), GUIModChangeType.Install, null)); menuStrip1.Enabled = false; RelationshipResolverOptions install_ops = RelationshipResolver.DefaultOpts(); install_ops.with_recommends = false; m_InstallWorker.RunWorkerAsync( new KeyValuePair <List <ModChange>, RelationshipResolverOptions>( changeset, install_ops)); m_Changeset = null; UpdateChangesDialog(null, m_InstallWorker); ShowWaitDialog(); } }
internal static CfanModule LoadCkanFromFile(CKAN.KSP current_instance, string ckan_file) { CfanModule module = CfanFileManager.fromCfanFile(ckan_file); // We'll need to make some registry changes to do this. RegistryManager registry_manager = RegistryManager.Instance(current_instance); // Remove this version of the module in the registry, if it exists. registry_manager.registry.RemoveAvailable(module); // Sneakily add our version in... registry_manager.registry.AddAvailable(module); return(module); }
internal static void ProcessRegistryMetadataFromJSON(string metadata, Registry registry, string filename) { log.DebugFormat("Converting metadata from JSON."); try { CfanModule module = CfanFileManager.fromJson(metadata); log.InfoFormat("Found {0} version {1}", module.identifier, module.modVersion); registry.AddAvailable(module); } catch (Exception exception) { // Alas, we can get exceptions which *wrap* our exceptions, // because json.net seems to enjoy wrapping rather than propagating. // See KSP-CKAN/CKAN-meta#182 as to why we need to walk the whole // exception stack. bool handled = false; while (exception != null) { if (exception is UnsupportedKraken || exception is BadMetadataKraken) { // Either of these can be caused by data meant for future // clients, so they're not really warnings, they're just // informational. log.InfoFormat("Skipping {0} : {1}", filename, exception.Message); // I'd *love a way to "return" from the catch block. handled = true; break; } // Look further down the stack. exception = exception.InnerException; } // If we haven't handled our exception, then it really was exceptional. if (handled == false) { // In case whatever's calling us is lazy in error reporting, we'll // report that we've got an issue here. log.ErrorFormat("Error processing {0} : {1}", filename, exception.Message); throw; } } }
public static CfanModule ModuleManagerModule() { return(CfanFileManager.fromCfanFile(DataDir("FARL_0.2.5.cfan"))); }
public static CfanModule RsoModule() { return(CfanFileManager.fromCfanFile(Path.Combine(DataDir(), "rso-mod_1.5.1.cfan"))); }
public static CfanModule kOS_014_module() { return(CfanFileManager.fromJson(kOS_014())); }
public static CfanModule DogeCoinFlag_101_module() { return(CfanFileManager.fromJson(DogeCoinFlag_101())); }