예제 #1
0
        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));
        }
예제 #2
0
 private void RaiseOnExtensionAction(ExtensionForm extension, ExtensionActionType action)
 {
     if (ExtensionAction != null)
     {
         OnExtensionAction(
             new ExtensionActionEventArgs(extension, action));
     }
 }
예제 #3
0
        public ExtensionBridge(HNode externalContractor, ExtensionForm extension)
        {
            _extension = extension;
            _externalContractor = externalContractor;

            RequestInformationAsync().Wait();
            Task readTask = ReadMessageAsync();
        }
예제 #4
0
        public ExtensionBridge(HNode externalContractor, ExtensionForm extension)
        {
            _extension          = extension;
            _externalContractor = externalContractor;

            RequestInformationAsync().Wait();
            Task readTask = ReadMessageAsync();
        }
예제 #5
0
 private void RaiseOnExtensionAction(ExtensionForm extension, ExtensionActionType action)
 {
     if (ExtensionAction != null)
     {
         OnExtensionAction(
             new ExtensionActionEventArgs(extension, action));
     }
 }
예제 #6
0
        public virtual ExtensionForm Initialize(ExtensionForm extension)
        {
            if (extension.IsDisposed)
            {
                if (_extensions.Contains(extension))
                {
                    _extensions.Remove(extension);
                }

                return(Initialize(extension.GetType()));
            }
            else
            {
                return(extension);
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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();
        }
예제 #9
0
        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));
        }
예제 #10
0
 public ExtensionActionEventArgs(
     ExtensionForm extension, ExtensionActionType action)
 {
     Action    = action;
     Extension = extension;
 }
예제 #11
0
 protected virtual void UninstallExtension(ExtensionForm extension)
 {
     if (extension != null)
         Contractor.Uninstall(extension);
 }
예제 #12
0
 protected virtual void CloseExtension(ExtensionForm extension)
 {
     if (extension != null &&
         extension.IsRunning)
     {
         extension.Close();
     }
 }
예제 #13
0
 public ExtensionActionEventArgs(
     ExtensionForm extension, ExtensionActionType action)
 {
     Action = action;
     Extension = extension;
 }
예제 #14
0
        public virtual ExtensionForm Initialize(ExtensionForm extension)
        {
            if (extension.IsDisposed)
            {
                if (_extensions.Contains(extension))
                    _extensions.Remove(extension);

                return Initialize(extension.GetType());
            }
            else return extension;
        }
예제 #15
0
        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));
        }