Esempio n. 1
0
        private void showPostSharpInstallStatus(IGacDll gacDll)
        {
            //if (gacDll.PostSharpHooks == PostSharpHookStatus.NotCalculated)
            if (PostSharpUtils.containsO2PostSharpHooks(gacDll.fullPath))
            {
                gacDll.PostSharpHooks = PostSharpHookStatus.Installed;
            }
            else
            {
                gacDll.PostSharpHooks = PostSharpHookStatus.NotInstalled;
            }
            switch (gacDll.PostSharpHooks)
            {
            case PostSharpHookStatus.Installed:
                lbPostSharpHooksState.Text        = "YES";
                lbPostSharpHooksState.ForeColor   = Color.DarkGreen;
                btInstallPostSharpHooks.Enabled   = false;
                btUnInstallPostSharpHooks.Enabled = true;
                break;

            case PostSharpHookStatus.NotInstalled:
                lbPostSharpHooksState.Text        = "NO";
                lbPostSharpHooksState.ForeColor   = Color.DarkRed;
                btInstallPostSharpHooks.Enabled   = true;
                btUnInstallPostSharpHooks.Enabled = false;
                break;

            case PostSharpHookStatus.NotCalculated:
                lbPostSharpHooksState.Text        = "...";
                lbPostSharpHooksState.ForeColor   = Color.Black;
                btInstallPostSharpHooks.Enabled   = false;
                btUnInstallPostSharpHooks.Enabled = false;
                break;
            }
        }
Esempio n. 2
0
 public void InstallPostSharpHook(IGacDll iGacDll, string typeToHook, string methodToHook)
 {
     if (false == PostSharpUtils.containsO2PostSharpHooks(iGacDll.fullPath))
     {
         IISDeployment.kill_IIS_Process_W3wp();
         BackupRestoreFiles.backup(iGacDll.fullPath);
         if (PostSharpExecution.InsertHooksAndRunPostSharpOnAssembly(iGacDll.fullPath, typeToHook, methodToHook))
         {
             DI.log.debug("PostSharp hooks installed on Gac Assembly: {0} (in {1})", iGacDll.name, iGacDll.fullPath);
         }
     }
     showGacAssemblyDetails(iGacDll, false);
     //throw new NotImplementedException();
 }
        public string runPostSharpOnAssembly()
        {
            var assemblyOriginal = compileFileToExe();
            var assemblyCopy     = Files.Copy(assemblyOriginal, assemblyOriginal + "_PS.exe");

            var assembly = CecilUtils.getAssembly(assemblyCopy);

            InjectAttributes.addO2PostSharpHookAttribute(assembly);
            InjectAttributes.addOnMethodInvocationttribute(assembly, assembly.Name.Name, "*", "TestScript_MultipleCalls", "validate");

            assembly.Name.PublicKey = null;
            AssemblyFactory.SaveAssembly(assembly, assemblyCopy);
            Hacks.patchAssemblyForCecilPostSharpBug(assemblyCopy);

            InjectAttributes.addO2PostSharpHookAttribute(assemblyCopy);

            Assert.That(PostSharpExecution.runPostSharpOnAssembly(assemblyCopy));
            Assert.That(true == PostSharpUtils.arePostSharpDllsAddedAsReferences(assemblyCopy));
            Assert.That(false == PostSharpUtils.arePostSharpDllsAddedAsReferences(assemblyOriginal));
            log.info("runPostSharpOnAssembly executed ok");
            return(assemblyCopy);
        }