/// <summary>
 /// Informs the user.
 /// </summary>
 /// <param name="extension">The extension.</param>
 /// <param name="action">The action.</param>
 /// <remarks>Documented by Dev02, 2009-07-09</remarks>
 private void ExtensionInformUser(IExtension extension, ExtensionAction action)
 {
     if (InformUser != null)
     {
         InformUser(this, new ExtensionEventArgs(extension, action));
     }
 }
 /// <summary>
 /// Forces the extension.
 /// </summary>
 /// <param name="extension">The extension.</param>
 /// <param name="action">The action.</param>
 /// <remarks>Documented by Dev02, 2009-07-03</remarks>
 private void ForceExtension(IExtension extension, ExtensionAction action)
 {
     if (ExecuteExtension != null)
     {
         ExecuteExtension(this, new ExtensionEventArgs(extension, action));
     }
 }
        /// <summary>
        /// Determines whether action has already been executed.
        /// </summary>
        /// <param name="extension">The extension.</param>
        /// <param name="action">The action.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev02, 2009-07-03</remarks>
        private static bool ActionAlreadyExecuted(IExtension extension, ExtensionAction action)
        {
            if (!executedActions.ContainsKey(extension.Id) || executedActions[extension.Id] == null)
            {
                return(false);
            }

            return(executedActions[extension.Id].Contains(action));
        }
Beispiel #4
0
        protected void CopyAssociatedFile(string sourceFullPath, string extension, ExtensionAction action)
        {
            // Look for a file with the same name but different extension.

            string fileFullPath = action == ExtensionAction.Replace ? Path.ChangeExtension(sourceFullPath, extension) : sourceFullPath + extension;

            if (System.IO.File.Exists(fileFullPath))
            {
                Copy(fileFullPath);
                Artifact.AddAssociatedArtifact(Path.Combine(Path.GetDirectoryName(Artifact.ProjectRelativePath), Path.GetFileName(fileFullPath)));
            }
        }
Beispiel #5
0
 public void AddExtensionChange(StandardLine l1, StandardLine l2, bool add)
 {
     if (!_working)
     {
         if (_actions.Count == 0)
         {
             return;
         }
         var ac  = new ExtensionAction(l1, l2, add);
         var act = (lineaction)_actions[_actions.Count - 1];
         act.extensions.Add(ac);
     }
 }
        /// <summary>
        /// Adds the action executed.
        /// </summary>
        /// <param name="extension">The extension.</param>
        /// <param name="action">The action.</param>
        /// <remarks>Documented by Dev02, 2009-07-03</remarks>
        private static void AddActionExecuted(IExtension extension, ExtensionAction action)
        {
            if (!executedActions.ContainsKey(extension.Id) || executedActions[extension.Id] == null)
            {
                executedActions[extension.Id] = new List <ExtensionAction>();
            }

            if (!executedActions[extension.Id].Contains(action))
            {
                executedActions[extension.Id].Add(action);
                extensionListsDirty = true;
            }
        }
Beispiel #7
0
        public void IExtensionTestAddExtensionToLM()
        {
            TestInfrastructure.DebugLineStart(TestContext);
            if (TestInfrastructure.IsActive(TestContext) && TestInfrastructure.ConnectionType(TestContext) != "File")
            {
                using (IDictionary writeLM = TestInfrastructure.GetLMConnection(TestContext, TestInfrastructure.GetAdminUser))
                {
                    byte[] bufCheck    = new byte[5];
                    byte[] bufOriginal = new byte[5] {
                        (byte)'H', (byte)'e', (byte)'l', (byte)'l', (byte)'o'
                    };

                    ExtensionAction extensionAction = new ExtensionAction()
                    {
                        Kind = ExtensionActionKind.Install, Execution = ExtensionActionExecution.Once
                    };

                    IExtension extension = writeLM.Parent.CurrentUser.List().ExtensionFactory();
                    extension.Type      = ExtensionType.Skin;
                    extension.Name      = "TheurySkin";
                    extension.Version   = new Version("1.0.0.0");
                    extension.StartFile = "TheurySkin.style";
                    extension.Data      = new System.IO.MemoryStream(bufOriginal);
                    extension.Actions.Add(extensionAction);

                    writeLM.Extensions.Add(extension);

                    ////////////////////////////////////////////////////////////////

                    Assert.AreEqual <int>(1, writeLM.Extensions.Count, "The Extension is not correctly saved to the database/LM");
                    Assert.AreEqual <ExtensionType>(ExtensionType.Skin, writeLM.Extensions[0].Type, "The ExtensionType is wrong");
                    Assert.AreEqual <string>("TheurySkin", writeLM.Extensions[0].Name, "The ExtensionName is wrong");
                    Assert.AreEqual <Version>(new Version("1.0.0.0"), writeLM.Extensions[0].Version, "The ExtensionVersion is wrong");
                    Assert.AreEqual <string>("TheurySkin.style", writeLM.Extensions[0].StartFile, "The ExtensionStartFile is wrong");
                    Assert.AreEqual <ExtensionAction>(extensionAction, writeLM.Extensions[0].Actions[0], "The ExtensionAction is wrong");

                    writeLM.Extensions[0].Data.Read(bufCheck, 0, bufOriginal.Length);
                    for (int i = 0; i < bufCheck.Length; i++)
                    {
                        Assert.AreEqual <byte>(bufCheck[i], bufOriginal[i], "The ExtensionData is wrong");
                    }

                    ////////////////////////////////////////////////////////////////

                    writeLM.Extensions[0].Actions.RemoveAt(0);
                    Assert.AreEqual <int>(0, writeLM.Extensions[0].Actions.Count, "Number of ExtensionActions is wrong");
                }
            }
            TestInfrastructure.DebugLineEnd(TestContext);
        }
        /// <summary>
        /// Installs the extension.
        /// </summary>
        /// <param name="extension">The extension.</param>
        /// <param name="action">The action.</param>
        /// <remarks>Documented by Dev02, 2009-07-03</remarks>
        private void InstallExtension(IExtension extension, ExtensionAction action)
        {
            string extractionPath;

            switch (extension.Type)
            {
            case ExtensionType.Skin:
                extractionPath = SkinPath;
                break;

            case ExtensionType.Unknown:
            default:
                return;
            }
            extension.ExtractData(extractionPath);
        }
Beispiel #9
0
        /// <summary>
        /// Gets the extension actions.
        /// </summary>
        /// <param name="guid">The GUID.</param>
        /// <returns></returns>
        public IList <ExtensionAction> GetExtensionActions(Guid guid)
        {
            List <ExtensionAction> actions = new List <ExtensionAction>();

            using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser))
            {
                using (NpgsqlCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = "SELECT action, execution FROM \"ExtensionActions\" WHERE guid=:guid";
                    cmd.Parameters.Add("guid", guid.ToString());
                    NpgsqlDataReader reader = PostgreSQLConn.ExecuteReader(cmd, Parent.CurrentUser);
                    while (reader.Read())
                    {
                        ExtensionAction action = new ExtensionAction();
                        action.Kind      = (ExtensionActionKind)Enum.Parse(typeof(ExtensionActionKind), Convert.ToString(reader["action"]));
                        action.Execution = (ExtensionActionExecution)Enum.Parse(typeof(ExtensionActionExecution), Convert.ToString(reader["execution"]));
                        actions.Add(action);
                    }
                }
            }
            return(actions);
        }
        /// <summary>
        /// Gets the extension actions.
        /// </summary>
        /// <param name="guid">The GUID.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev02, 2009-07-03</remarks>
        public IList <ExtensionAction> GetExtensionActions(Guid guid)
        {
            IList <ExtensionAction> extensionActions = new List <ExtensionAction>();

            using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
            {
                cmd.CommandText = "SELECT action, execution FROM \"ExtensionActions\" WHERE guid=@guid";
                cmd.Parameters.Add("@guid", guid.ToString());

                SqlCeDataReader reader = MSSQLCEConn.ExecuteReader(cmd);
                while (reader.Read())
                {
                    object action    = reader["action"];
                    object execution = reader["execution"];

                    ExtensionAction extensionAction = new ExtensionAction();
                    extensionAction.Kind      = (ExtensionActionKind)Enum.Parse(typeof(ExtensionActionKind), action as string);
                    extensionAction.Execution = (ExtensionActionExecution)Enum.Parse(typeof(ExtensionActionExecution), execution as string);

                    extensionActions.Add(extensionAction);
                }
            }
            return(extensionActions);
        }
Beispiel #11
0
 protected virtual void OnExtensionAction(ExtensionActionEventArgs e)
 {
     ExtensionAction?.Invoke(this, e);
 }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtensionCheckActionDataEntry"/> struct.
 /// </summary>
 /// <param name="metadata">The metadata.</param>
 /// <param name="action">The action.</param>
 /// <param name="installedVersion">The installed version.</param>
 public ExtensionCheckActionDataEntry(ISharperCryptoApiExtensionMetadata metadata, ExtensionAction action, Version installedVersion)
 {
     ExtensionMetadata = metadata;
     Action            = action;
     InstalledVersion  = installedVersion;
 }
Beispiel #13
0
        protected void CleanAssociatedFile(string destinationFullPath, string extension, ExtensionAction action)
        {
            // Look for a file with the same name but different extension.

            string fileFullPath = action == ExtensionAction.Replace ? Path.ChangeExtension(destinationFullPath, extension) : destinationFullPath + extension;

            Delete(fileFullPath);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtensionEventArgs"/> class.
 /// </summary>
 /// <param name="extension">The extension.</param>
 /// <param name="action">The action.</param>
 /// <remarks>Documented by Dev02, 2009-07-03</remarks>
 public ExtensionEventArgs(IExtension extension, ExtensionAction action)
 {
     this.Extension = extension;
     this.Action    = action;
 }