コード例 #1
0
        public void Run(IAssemblyTrackerFactory trackerFactory,
                        IEnumerable <IAssemblyTransformationFactory> transformationFactories,
                        IAssemblySignerFactory signerFactory,
                        IAppDomainInfoBroker infoBroker)
        {
            ArgumentUtility.CheckNotNull("trackerFactory", trackerFactory);
            ArgumentUtility.CheckNotNull("transformationFactories", transformationFactories);
            ArgumentUtility.CheckNotNull("signerFactory", signerFactory);

#if PERFORMANCE_TEST
            Stopwatch s     = new Stopwatch();
            Stopwatch total = new Stopwatch();
            s.Start();
            total.Start();
#endif

            var tracker = trackerFactory.CreateTracker();

#if PERFORMANCE_TEST
            total.Stop();
            Process procObj = Process.GetCurrentProcess();
            Console.WriteLine(Environment.NewLine + "  Private Memory Size : {0:N0}" + Environment.NewLine +
                              "  Virtual Memory Size : {1:N0}" + Environment.NewLine +
                              "  Working Set Size: {2:N0}", procObj.PrivateMemorySize64, procObj.VirtualMemorySize64, procObj.WorkingSet64);
            Console.WriteLine(Environment.NewLine + "  Initialization:   " + s.Elapsed);
            Console.WriteLine(Environment.NewLine + "  press key to continue with transformations");
            total.Start();
            s.Restart();
#endif

            foreach (var factory in transformationFactories)
            {
                Console.WriteLine("Transforming assemblies according to " + factory.GetType().Name);
                factory.CreateTransformation(infoBroker).Transform(tracker);
            }
            infoBroker.Unload();

#if PERFORMANCE_TEST
            total.Stop();
            procObj = Process.GetCurrentProcess();
            Console.WriteLine(Environment.NewLine + "  Private Memory Size : {0:N0}" + Environment.NewLine +
                              "  Virtual Memory Size : {1:N0}" + Environment.NewLine +
                              "  Working Set Size: {2:N0}", procObj.PrivateMemorySize64, procObj.VirtualMemorySize64, procObj.WorkingSet64);
            Console.WriteLine(Environment.NewLine + "  Transformation:   " + s.Elapsed);
            Console.WriteLine(Environment.NewLine + "  press key to continue with sign and save");
            total.Start();
            s.Restart();
#endif

            var signer = signerFactory.CreateSigner();
            Console.WriteLine("Signing and writing the transformed assemblies ... ");
            signer.SignAndSave(tracker);

#if PERFORMANCE_TEST
            s.Stop();
            total.Stop();
            procObj = Process.GetCurrentProcess();
            Console.WriteLine(Environment.NewLine + "  Private Memory Size : {0:N0}" + Environment.NewLine +
                              "  Virtual Memory Size : {1:N0}" + Environment.NewLine +
                              "  Working Set Size: {2:N0}", procObj.PrivateMemorySize64, procObj.VirtualMemorySize64, procObj.WorkingSet64);
            Console.WriteLine(Environment.NewLine + "  Signing & Saving: " + s.Elapsed);
            Console.WriteLine(Environment.NewLine + "Total: " + total.Elapsed + Environment.NewLine);
#endif
        }
コード例 #2
0
        public void Run(IAssemblyTrackerFactory trackerFactory,
                      IEnumerable<IAssemblyTransformationFactory> transformationFactories, 
                      IAssemblySignerFactory signerFactory,
                      IAppDomainInfoBroker infoBroker)
        {
            ArgumentUtility.CheckNotNull ("trackerFactory", trackerFactory);
              ArgumentUtility.CheckNotNull ("transformationFactories", transformationFactories);
              ArgumentUtility.CheckNotNull ("signerFactory", signerFactory);

            #if PERFORMANCE_TEST
              Stopwatch s = new Stopwatch ();
              Stopwatch total = new Stopwatch ();
              s.Start ();
              total.Start();
            #endif

              var tracker = trackerFactory.CreateTracker();

            #if PERFORMANCE_TEST
              total.Stop();
              Process procObj = Process.GetCurrentProcess ();
              Console.WriteLine (Environment.NewLine + "  Private Memory Size : {0:N0}" + Environment.NewLine +
              "  Virtual Memory Size : {1:N0}" + Environment.NewLine +
              "  Working Set Size: {2:N0}", procObj.PrivateMemorySize64, procObj.VirtualMemorySize64, procObj.WorkingSet64);
              Console.WriteLine (Environment.NewLine + "  Initialization:   " + s.Elapsed);
              Console.WriteLine (Environment.NewLine + "  press key to continue with transformations");
              total.Start ();
              s.Restart ();
            #endif

              foreach (var factory in transformationFactories)
              {
            Console.WriteLine ("Transforming assemblies according to " + factory.GetType().Name);
            factory.CreateTransformation(infoBroker).Transform (tracker);
              }
              infoBroker.Unload();

            #if PERFORMANCE_TEST
              total.Stop ();
              procObj = Process.GetCurrentProcess ();
              Console.WriteLine (Environment.NewLine + "  Private Memory Size : {0:N0}" + Environment.NewLine +
              "  Virtual Memory Size : {1:N0}" + Environment.NewLine +
              "  Working Set Size: {2:N0}", procObj.PrivateMemorySize64, procObj.VirtualMemorySize64, procObj.WorkingSet64);
              Console.WriteLine (Environment.NewLine + "  Transformation:   " + s.Elapsed);
              Console.WriteLine (Environment.NewLine + "  press key to continue with sign and save");
              total.Start ();
              s.Restart ();
            #endif

              var signer = signerFactory.CreateSigner();
              Console.WriteLine ("Signing and writing the transformed assemblies ... ");
              signer.SignAndSave (tracker);

            #if PERFORMANCE_TEST
              s.Stop();
              total.Stop ();
              procObj = Process.GetCurrentProcess ();
              Console.WriteLine (Environment.NewLine + "  Private Memory Size : {0:N0}" + Environment.NewLine +
              "  Virtual Memory Size : {1:N0}" + Environment.NewLine +
              "  Working Set Size: {2:N0}", procObj.PrivateMemorySize64, procObj.VirtualMemorySize64, procObj.WorkingSet64);
              Console.WriteLine (Environment.NewLine + "  Signing & Saving: " + s.Elapsed);
              Console.WriteLine (Environment.NewLine + "Total: " + total.Elapsed + Environment.NewLine);
            #endif
        }