public virtual void Uninstall(ExtensionForm extension) { if (File.Exists(extension.FileLocation)) { File.Delete(extension.FileLocation); } if (_extensions.Contains(extension)) { _extensions.Remove(extension); } if (extension.IsRunning) { extension.Close(); } if (!extension.IsDisposed) { extension.Dispose(); } if (_extensionHash.ContainsKey(extension.Hash)) { _extensionHash.Remove(extension.Hash); } OnExtensionAction(new ExtensionActionEventArgs( extension, ExtensionActionType.Uninstalled)); }
private void RaiseOnExtensionAction(ExtensionForm extension, ExtensionActionType action) { if (ExtensionAction != null) { OnExtensionAction( new ExtensionActionEventArgs(extension, action)); } }
public ExtensionBridge(HNode externalContractor, ExtensionForm extension) { _extension = extension; _externalContractor = externalContractor; RequestInformationAsync().Wait(); Task readTask = ReadMessageAsync(); }
public virtual ExtensionForm Initialize(ExtensionForm extension) { if (extension.IsDisposed) { if (_extensions.Contains(extension)) { _extensions.Remove(extension); } return(Initialize(extension.GetType())); } else { return(extension); } }
protected virtual ExtensionForm Install(string path, string hash) { // Create a copy of the assembly, and load it into memory(byte[]). string installedExtensionPath = CopyExtension(hash, path); byte[] rawFile = File.ReadAllBytes(installedExtensionPath); // Read the assembly from memory (byte[]), so we can delete the file when uninstalled. Assembly fileAssembly = Assembly.Load(rawFile); InstallDependenciesFrom(path, fileAssembly); ExtensionForm extension = null; Type extensionFormType = GetExtensionFormType(fileAssembly); if (extensionFormType != null) { var extensionInfo = new ExtensionInfo( installedExtensionPath, hash, this); _extensionInfo.Add(fileAssembly, extensionInfo); _initialExtensionPaths.Add(fileAssembly, Path.GetDirectoryName(path)); extension = Initialize(extensionFormType); if (extension != null) { var extensionAction = extension.IsRunning ? ExtensionActionType.Opened : ExtensionActionType.Installed; OnExtensionAction(new ExtensionActionEventArgs( extension, extensionAction)); } else { _extensionInfo.Remove(fileAssembly); _initialExtensionPaths.Remove(fileAssembly); } } if (extension == null && File.Exists(installedExtensionPath)) { File.Delete(installedExtensionPath); } return(extension); }
protected virtual void OpenExtension(ExtensionForm extension) { if (extension == null) return; if (extension.IsDisposed) { ListViewItem item = _itemByHash[extension.Hash]; _itemByHash.Remove(extension.Hash); extension = Contractor.Initialize(extension); _extensionByItem[item] = extension; _itemByHash[extension.Hash] = item; } if (!extension.IsRunning) extension.Show(); else extension.BringToFront(); }
public ExtensionForm Install(string path) { path = Path.GetFullPath(path); if (!File.Exists(path)) { return(null); } string hash = GetHash(path); if (_extensionHash.ContainsKey(hash)) { ExtensionForm extensionForm = _extensionHash[hash]; if (!extensionForm.IsDisposed) { RaiseOnExtensionAction(extensionForm, ExtensionActionType.Reinstalled); } return(Initialize(extensionForm)); } return(Install(path, hash)); }
public ExtensionActionEventArgs( ExtensionForm extension, ExtensionActionType action) { Action = action; Extension = extension; }
protected virtual void UninstallExtension(ExtensionForm extension) { if (extension != null) Contractor.Uninstall(extension); }
protected virtual void CloseExtension(ExtensionForm extension) { if (extension != null && extension.IsRunning) { extension.Close(); } }
public virtual ExtensionForm Initialize(ExtensionForm extension) { if (extension.IsDisposed) { if (_extensions.Contains(extension)) _extensions.Remove(extension); return Initialize(extension.GetType()); } else return extension; }
public virtual void Uninstall(ExtensionForm extension) { if (File.Exists(extension.FileLocation)) File.Delete(extension.FileLocation); if (_extensions.Contains(extension)) _extensions.Remove(extension); if (extension.IsRunning) extension.Close(); if (!extension.IsDisposed) extension.Dispose(); if (_extensionHash.ContainsKey(extension.Hash)) _extensionHash.Remove(extension.Hash); OnExtensionAction(new ExtensionActionEventArgs( extension, ExtensionActionType.Uninstalled)); }