static CakeAPI() { var env = new CakeEnvironment(new CakePlatform(), new CakeRuntime()); var fileSystem = new FileSystem(); var verbosity = Verbosity.Normal; if (Startup.HasArgument("cake-verbosity")) { verbosity = Enum.Parse <Verbosity>(Startup.Argument("cake-verbosity")); } var cakeLog = new CakeBuildLog(new CakeConsole(env), verbosity); var cakeConfiguration = new CakeConfiguration(new Dictionary <string, string>()); var toolRepos = new ToolRepository(env); Globber = new Globber(fileSystem, env); var cakeDataService = new CakeDataService(); var registry = new WindowsRegistry(); var toolLocator = new ToolLocator(env, toolRepos, new ToolResolutionStrategy(fileSystem, env, Globber, cakeConfiguration, cakeLog)); var cakeArgs = new CakeArguments(new List <string>().ToLookup(x => x)); var procRunner = new ProcessRunner(fileSystem, env, cakeLog, toolLocator, cakeConfiguration); Context = new CakeContext(fileSystem, env, Globber, cakeLog, cakeArgs, procRunner, registry, toolLocator, cakeDataService, cakeConfiguration); }
private void FrmTree_Load(object sender, EventArgs e) { var sw = new Stopwatch(); sw.Start(); SelectOptionsFromRegistry(); taxonomyTree.LoadProject(); //Text = string.Format("Tree View - {0}", AryaTools.Instance.InstanceData.CurrentProject.ProjectDescription); // Use Publish Version on Deployed Applications Text = string.Format("Tree - {0} {1}{2}", Assembly.GetExecutingAssembly().GetName().Name, ApplicationDeployment.IsNetworkDeployed ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() : "Not Deployed", AryaTools.Instance.InstanceData.CurrentUser.IsAryaReadOnly ? " - Read Only" : string.Empty); SnapToLeftInNewScreen(); //taxonomyTree.OnTaxonomySelected = UpdateCurrentVocabularyContext; taxonomyTree.OnTaxonomyOpen = OpenTaxonomyNodeForAttributeNormalization; taxonomyTree.OnTaxonomyMove = MoveTaxonomyNode; taxonomyTree.OnCrossListNode = CrossListHere; if (taxonomyTree.SelectedTaxonomy == null) { var taxId = WindowsRegistry.GetFromRegistry(WindowsRegistry.RegistryKeyCurrentTaxonomy); if (taxId != null) { try { var taxonomyId = new Guid(taxId); //previous selected Taxonomy taxonomyTree.SelectedTaxonomy = taxonomyTree.Taxonomies.Select(tax => tax.Key) .FirstOrDefault(tax => tax.ID.Equals(taxonomyId)); } catch { } } } autoSaveToolStripMenuItem.Checked = AryaTools.Instance.AutoSave; taxonomyTree.updateNodeTimer.Start(); sw.Stop(); Diagnostics.WriteMessage("*Loading Project Tree", "FrmTree - taxonomyTree.LoadProject()", sw.Elapsed); sw.Reset(); Show(); BringToFront(); if (!AryaTools.Instance.InstanceData.CurrentUser.IsProjectAdmin) { projectMetaAttributesToolStripMenuItem.Enabled = false; projectCustomDictionaryToolStripMenuItem.Enabled = false; } }
static String GetIDepositAppConfig(String config) { String ConfigName = "IDEPOSIT_"; if (AppLogic.AppConfigBool("UseLiveTransactions")) { ConfigName += "LIVE_"; } else { ConfigName += "TEST_"; } ConfigName += config; String val = AppLogic.AppConfig(ConfigName); if (val.Trim().Equals("REGISTRY", StringComparison.InvariantCultureIgnoreCase)) { WindowsRegistry reg = new WindowsRegistry(AppLogic.AppConfig("EncryptKey.RegistryLocation")); val = reg.Read(ConfigName); reg = null; } return(val); }
public FakeCakeContext() { testsDir = new DirectoryPath( System.IO.Path.GetFullPath(AppContext.BaseDirectory)); var fileSystem = new FileSystem(); log = new FakeLog(); var runtime = new CakeRuntime(); var platform = new FakePlatform(PlatformFamily.Windows); var environment = new CakeEnvironment(platform, runtime); var globber = new Globber(fileSystem, environment); var args = new FakeCakeArguments(); var registry = new WindowsRegistry(); var dataService = new FakeDataService(); var toolRepository = new ToolRepository(environment); var config = new FakeConfiguration(); var toolResolutionStrategy = new ToolResolutionStrategy(fileSystem, environment, globber, config, log); IToolLocator tools = new ToolLocator(environment, toolRepository, toolResolutionStrategy); var processRunner = new ProcessRunner(fileSystem, environment, log, tools, config); context = new CakeContext(fileSystem, environment, globber, log, args, processRunner, registry, tools, dataService, config); context.Environment.WorkingDirectory = testsDir; }
public FakeCakeContext() { var testsDir = new DirectoryPath(System.IO.Path.GetFullPath(AppContext.BaseDirectory)); var fileSystem = new FileSystem(); var environment = new FakeEnvironment(PlatformFamily.Windows); var globber = new Globber(fileSystem, environment); var log = new FakeLog(); var args = new FakeCakeArguments(); var toolRepo = new ToolRepository(environment); var config = new CakeConfigurationProvider(fileSystem, environment) .CreateConfiguration(testsDir, new Dictionary <string, string>()); var toolResolutionStrategy = new ToolResolutionStrategy(fileSystem, environment, globber, config); var toolLocator = new ToolLocator(environment, toolRepo, toolResolutionStrategy); var processRunner = new ProcessRunner(fileSystem, environment, log, toolLocator, config); var registry = new WindowsRegistry(); var dataService = new FakeDataService(); _context = new CakeContext( fileSystem, environment, globber, log, args, processRunner, registry, toolLocator, dataService, config); _context.Environment.WorkingDirectory = testsDir; }
public FakeCakeContext() { var fileSystem = new FileSystem(); Log = new FakeLog(); var runtime = new CakeRuntime(); var platform = new FakePlatform(PlatformFamily.Windows); var environment = new CakeEnvironment(platform, runtime, Log); var globber = new Globber(fileSystem, environment); var args = Substitute.For <ICakeArguments>(); var registry = new WindowsRegistry(); var dataService = Substitute.For <ICakeDataService>(); var toolRepository = new ToolRepository(environment); var toolResolutionStrategy = new ToolResolutionStrategy(fileSystem, environment, globber, new FakeConfiguration()); var tools = new ToolLocator(environment, toolRepository, toolResolutionStrategy); var processRunner = new ProcessRunner(fileSystem, environment, Log, tools, new FakeConfiguration()); Context = new CakeContext(fileSystem, environment, globber, Log, args, processRunner, registry, tools, dataService); WorkingDirectory = new DirectoryPath( System.IO.Path.GetFullPath(AppContext.BaseDirectory)); Context.Environment.WorkingDirectory = WorkingDirectory; }
private void SelectProject() { var currentProject = (Project)ddlSelectProject.SelectedItem; AryaTools.Instance.InstanceData.CurrentProject = currentProject; AryaTools.Instance.AutoSave = chkAutoSave.Checked; Program.WriteToErrorFile( string.Format( "UserID: {0},UserName: {1}, Project: {2}, Hostname: {3}", AryaTools.Instance.InstanceData.CurrentUser.ID, string.IsNullOrEmpty(AryaTools.Instance.InstanceData.CurrentUser.FullName) ? string.Empty : AryaTools.Instance.InstanceData.CurrentUser.FullName, AryaTools.Instance.InstanceData.CurrentProject.ProjectName, Environment.MachineName), true); WindowsRegistry.SaveToRegistry( WindowsRegistry.RegistryKeyProject, AryaTools.Instance.InstanceData.CurrentProject.ProjectName); //AryaTools.Instance.selectedProject = true; DialogResult = DialogResult.OK; AryaTools.Instance.Forms.TreeForm.Show(); Hide(); }
public void Can_Set_Get_And_Delete_Values() { var registry = new WindowsRegistry(); using (var usersKey = registry.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)) using (var subkey = usersKey.CreateSubKey("SharpShellTests")) { // Set a value, check it is set, check unset values are not set. var testValue = new Guid().ToString(); subkey.SetValue("TestString", testValue); Assert.That(subkey.GetValue("TestString"), Is.EqualTo(testValue)); subkey.SetValue("TestExpandString", testValue, RegistryValueKind.ExpandString); // Delete the value, and make sure it is no longer present. subkey.DeleteValue("TestString"); Assert.That(subkey.GetValueNames(), Does.Not.Contain("TestString")); subkey.DeleteValue("TestExpandString"); Assert.That(subkey.GetValueNames(), Does.Not.Contain("TestExpandString")); // Make sure missing values are returned properly. Assert.That(subkey.GetValue("TestString"), Is.Null); Assert.That(subkey.GetValue("TestExpandString", "DefaultValue"), Is.EqualTo("DefaultValue")); // If we delete a value which is missing, we should be able to choose whether to throw or now. Assert.DoesNotThrow(() => subkey.DeleteValue("TestString", false)); Assert.Throws <ArgumentException>(() => subkey.DeleteValue("TestString", true)); } }
public static void SetAssociation(string[] extensions, string id, string description, string exePath, string iconPath) { if (PlatformInfo.System.OperatingSystem == ModernOperatingSystem.WindowsDesktop) { WindowsRegistry.SetAssociation(extensions: extensions, id: id, description: description, exePath: exePath, iconPath: iconPath); } }
private static void DoLaundry() { // Easter Egg - Time to do your laundry - once every 7 days DateTime now = DateTime.Now; var quotes = new[] { "It's our fundamental guiding principle: provide elegant product data solutions for our clients. Our expertise in data management, data quality, search and navigation drive online revenue and create a customer experience that is intuitive, efficient and rewarding.", "Some might call us Data Geeks. And we are. But our team of architects and analysts are also journalists, librarians, linguists, IT ninjas, usability experts, MRO aficionados and more. We love data and it shows in our work habits, culture and success with our clients.", "Nobody will tell you that your website is dysfunctional (they'll just shop somewhere else).", "Customers don't buy products when they think they have found the right item. They buy when they know they have.", "Fixing data problems can be a bit like plugging a hole in a leaky bucket; as soon as you cover one issue, another emerges to take its place." }; DateTime dtLastLaundry; const string lastLaundryDateRegistryKey = "LastLaundry"; string lastLaundryDate = WindowsRegistry.GetFromRegistry(lastLaundryDateRegistryKey); try { dtLastLaundry = DateTime.Parse(lastLaundryDate); } catch { dtLastLaundry = now.Subtract(TimeSpan.FromDays(8)); } if (now - dtLastLaundry > TimeSpan.FromDays(7)) { var randomQuote = quotes[new Random(now.Millisecond).Next(quotes.Length)]; var result = MessageBox.Show(randomQuote, @"Arya quote"); WindowsRegistry.SaveToRegistry(lastLaundryDateRegistryKey, now.ToString()); } }
/// <summary> /// Gets the CLSID for this MimeType instance. /// </summary> /// <returns>CLSID (string), or null</returns> public string GetCLSID() { if (msType == null || msType.Length == 0) { return(null); } return(WindowsRegistry.GetMimeTypeOption(ContentType, "CLSID")); }
public void Can_Open_A_Base_Key() { // Try and open the users base key. var registry = new WindowsRegistry(); using var usersKey = registry.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default); Assert.That(usersKey.Name, Is.EqualTo("HKEY_CURRENT_USER")); }
public void Open_Subkey_Returns_Null_For_Missing_Subkeys() { var registry = new WindowsRegistry(); using var usersKey = registry.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default); using var subkey = usersKey.CreateSubKey("WindowsRegistryTests"); Assert.That(subkey.OpenSubKey("MissingSubkey"), Is.Null); }
/// <summary> /// Gets the file extension for this MimeType instance. /// </summary> /// <returns>File extension (string) if found/available, else null</returns> public string GetFileExtension() { if (msType == null || msType.Length == 0) { return(null); } return(WindowsRegistry.GetMimeTypeOption(ContentType, "Extension")); }
public void TearDown() { // Clean up the test key. var registry = new WindowsRegistry(); using var usersKey = registry.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default); usersKey.DeleteSubKeyTree("WindowsRegistryTests", false); // don't throw if the key is already deleted. }
private bool SkipEnable(StrongNameConfiguration configuration) { if (!File.Exists(XmlFile)) { Log.LogError("The XmlFile given must exist."); return(false); } if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Log.LogError("Strongname tasks should only be run on Windows."); return(false); } bool printedHeader = false; foreach (RegistrySection section in WindowsRegistry.Sections) { using (RegistryKey registryKey = WindowsRegistry.CreateWritableVerificationRegistryKey(section)) { if (registryKey == null) { Log.LogError($"Unable to open writable verification registry key for {section}."); return(false); } foreach (var assembly in configuration.FilteredAssemblySpecifications[section]) { using (RegistryKey subKey = registryKey.OpenSubKey(assembly)) { if (subKey == null) { if (!printedHeader) { printedHeader = true; Log.LogMessage("Adding registry entries:"); } Log.LogMessage($" {registryKey}\\{assembly}"); registryKey.CreateSubKey(assembly); } } } } } if (!printedHeader) { Log.LogMessage("Skip Strong Names is already enabled."); } else { Log.LogMessage(""); Log.LogMessage("Skip Strong Names was successfully enabled."); } return(true); }
public void SeleniumZoneTest() { // this test will fail if not all protected mode settings are the same var registry = new WindowsRegistry(); var protectedModes = new ProtectedMode(new ZoneListFactory(registry)); var same = protectedModes.AllAreSame(); Assert.IsTrue(same); }
public void TestMockWindowsRegistry() { var w = new WindowsRegistry(); IRegistryKey rCore = w.LocalMachine.OpenSubKey(@"SOFTWARE\R-core"); string localMachineTestReg = @" [HKEY_LOCAL_MACHINE\SOFTWARE\R-core] [HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R] 'InstallPath'='C:\Program Files\R\R-3.3.3' 'Current Version'='3.3.3' "; var reg = new MockRegistry(localMachineTestReg); var lm = reg.LocalMachine; //var sk = lm.GetSubKeyNames(); rCore = lm.OpenSubKey(@"SOFTWARE\R-core"); var valNames = rCore.GetValueNames(); Assert.AreEqual(valNames.Length, 0); Assert.AreEqual(rCore.GetSubKeyNames().Length, 1); Assert.AreEqual(rCore.GetSubKeyNames()[0], "R"); var R = rCore.OpenSubKey(@"R"); Assert.AreEqual(R.GetSubKeyNames().Length, 0); Assert.AreEqual(R.GetValueNames().Length, 2); Assert.AreEqual(R.GetValue("InstallPath"), "C:\\Program Files\\R\\R-3.3.3"); Assert.AreEqual(R.GetValue("Current Version"), "3.3.3"); localMachineTestReg = @" [HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R\R64] 'InstallPath'='C:\Program Files\Microsoft\R Client\R_SERVER\' 'Current Version'='3.2.2.803' [HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R\R64\3.2.2.803] 'InstallPath'='C:\Program Files\Microsoft\R Client\R_SERVER\' "; reg = new MockRegistry(localMachineTestReg); lm = reg.LocalMachine; rCore = lm.OpenSubKey(@"SOFTWARE\R-core"); Assert.AreEqual(rCore.GetValueNames().Length, 0); Assert.AreEqual(rCore.GetSubKeyNames().Length, 1); Assert.AreEqual(rCore.GetSubKeyNames()[0], "R"); R = rCore.OpenSubKey(@"R"); Assert.AreEqual(R.GetSubKeyNames().Length, 1); var R64 = lm.OpenSubKey(@"SOFTWARE\R-core\R\R64"); Assert.AreEqual(R64.GetSubKeyNames().Length, 1); Assert.AreEqual(R64.GetValueNames().Length, 2); Assert.AreEqual(R64.GetValue("InstallPath"), @"C:\Program Files\Microsoft\R Client\R_SERVER\"); Assert.AreEqual(R64.GetValue("Current Version"), "3.2.2.803"); }
public void Can_Create_And_Delete_A_Subkey() { // Open the unit test key. var registry = new WindowsRegistry(); using var usersKey = registry.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default); using var subkey = usersKey.CreateSubKey("WindowsRegistryTests"); Assert.That(subkey.Name, Is.EqualTo(@"HKEY_CURRENT_USER\WindowsRegistryTests")); usersKey.DeleteSubKeyTree("WindowsRegistryTests"); Assert.That(usersKey.GetSubKeyNames(), Does.Not.Contain("WindowsRegistryTests")); }
public RaillessMining() { this.playerMobile = PlayerMobile.GetPlayer(); this.movingHelper = MovingHelper.GetMovingHelper(); this.smeltWeight = WindowsRegistry.GetValueOrDefault(@"Software\ScriptSDK.SantiagoUO\RaillessMining\" + playerMobile.Name, "SmeltWeight", 350); this.smelt1x1 = WindowsRegistry.GetValueOrDefault(@"Software\ScriptSDK.SantiagoUO\RaillessMining\" + playerMobile.Name, "Smelt1x1", false); this.bankWeight = WindowsRegistry.GetValueOrDefault(@"Software\ScriptSDK.SantiagoUO\RaillessMining\" + playerMobile.Name, "BankWeight", 100); this.dropContainer = new Container(EasyUOHelper.ConvertToStealthID(WindowsRegistry.GetValue(@"Software\ScriptSDK.SantiagoUO\RaillessMining\" + playerMobile.Name, "DropContainerId"))); this.pickaxesCount = WindowsRegistry.GetValueOrDefault(@"Software\ScriptSDK.SantiagoUO\RaillessMining\" + playerMobile.Name, "PickaxesCount", 2); }
public MockContext() { Arguments = new CakeArguments(); Environment = FakeEnvironment.CreateUnixEnvironment(); FileSystem = new FakeFileSystem(Environment); Globber = Substitute.For <IGlobber>(); Log = new FakeLog(); var configuration = new FakeConfiguration(); Configuration = configuration; Registry = new WindowsRegistry(); Tools = new ToolLocator(Environment, new ToolRepository(Environment), new ToolResolutionStrategy(FileSystem, Environment, Globber, configuration, Log)); ProcessRunner = new ProcessRunner(FileSystem, Environment, Log, Tools, configuration); }
private void CreateRegistry(LaunchInfo launchInfo) { if (!WindowsRegistry.IsRegeditKeyExist(Constants.EXPIRATION_DATE)) { WindowsRegistry.SetRegistryValue(Constants.EXPIRATION_DATE, launchInfo.ExpirationDate.ToShortDateString()); } if (!WindowsRegistry.IsRegeditKeyExist(Constants.ENCRYPTED_TEXT)) { WindowsRegistry.SetRegistryValue(Constants.ENCRYPTED_TEXT, launchInfo.EncryptedText); } if (!WindowsRegistry.IsRegeditKeyExist(Constants.PRODUCT_KEY)) { WindowsRegistry.SetRegistryValue(Constants.PRODUCT_KEY, launchInfo.ProductKey); } }
/// <summary> /// Worker role on start event /// </summary> /// <returns>Result of on start</returns> public override bool OnStart() { ServicePointManager.DefaultConnectionLimit = this.defaultConnectionLimit; RoleEnvironment.Changing += this.RoleEnvironmentChanging; this.container = IoC.Initialize(); this.log = this.container.GetInstance <ILog>(); var registry = new WindowsRegistry(this.log); registry.ConfigureLocalTcpSettings(); bool result = base.OnStart(); return(result); }
private void SelectOptionsFromRegistry() { var includeChildrenTaxnNorm = WindowsRegistry.GetFromRegistry(RegistryKeyIncludeChildren); if (!string.IsNullOrEmpty(includeChildrenTaxnNorm) && includeChildrenTaxnNorm.Equals(true.ToString())) { IncludeChildren = true; } var selectMultipleTaxnNorm = WindowsRegistry.GetFromRegistry(RegistryKeyLoadMultiple); if (!string.IsNullOrEmpty(selectMultipleTaxnNorm) && selectMultipleTaxnNorm.Equals(true.ToString())) { LoadToOneTab = true; } }
public FakeCakeContext () { testsDir = new DirectoryPath ( System.IO.Path.GetFullPath (AppDomain.CurrentDomain.BaseDirectory)); var fileSystem = new FileSystem (); var environment = new CakeEnvironment (); var globber = new Globber (fileSystem, environment); log = new FakeLog (); var args = new FakeCakeArguments (); var processRunner = new ProcessRunner (environment, log); var registry = new WindowsRegistry (); context = new CakeContext (fileSystem, environment, globber, log, args, processRunner, registry); context.Environment.WorkingDirectory = testsDir; }
/// <summary> /// 离线验证 /// </summary> /// <returns></returns> private bool OfflineVerify(LaunchInfo launchInfo) { //远程验证失败,开始离线验证 var expirationDate = EncryptionService.EncryptText(WindowsRegistry.GetRegistryValue(Constants.EXPIRATION_DATE)); var encryptedText = WindowsRegistry.GetRegistryValue(Constants.ENCRYPTED_TEXT); var prdkey = WindowsRegistry.GetRegistryValue(Constants.PRODUCT_KEY); if (encryptedText == launchInfo.EncryptedText && prdkey == launchInfo.ProductKey) { return(expirationDate == encryptedText); } else { return(false); } }
public FakeCakeContext () { testsDir = new DirectoryPath(System.IO.Path.GetFullPath(AppContext.BaseDirectory)); var environment = Cake.Testing.FakeEnvironment.CreateUnixEnvironment (false); var fileSystem = new Cake.Testing.FakeFileSystem (environment); var globber = new Globber (fileSystem, environment); log = new Cake.Testing.FakeLog (); var args = new FakeCakeArguments (); var processRunner = new ProcessRunner (environment, log); var registry = new WindowsRegistry (); var tools = new ToolLocator(environment, new ToolRepository(environment), new ToolResolutionStrategy(fileSystem, environment, globber, new FakeConfiguration())); context = new CakeContext (fileSystem, environment, globber, log, args, processRunner, registry, tools); context.Environment.WorkingDirectory = testsDir; }
public CakeFixture() { var env = FakeEnvironment.CreateUnixEnvironment(); FileSystem = new FakeFileSystem(env); var globber = new Globber(FileSystem, env); var log = new NullLog(); var reg = new WindowsRegistry(); var config = new CakeConfiguration(new Dictionary <string, string>()); var strategy = new ToolResolutionStrategy(FileSystem, env, globber, config, log); var toolLocator = new ToolLocator(env, new ToolRepository(env), strategy); var cakeDataService = new FakeDataService(); var runner = new ProcessRunner(FileSystem, env, log, toolLocator, config); var args = new FakeArguments(); Context = new CakeContext(FileSystem, env, globber, log, args, runner, reg, toolLocator, cakeDataService, config); }
public FakeSession() { testsDir = new DirectoryPath( System.IO.Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory)); var fileSystem = new FileSystem(); var environment = new CakeEnvironment(); var globber = new Globber(fileSystem, environment); log = new FakeLog(); var args = new FakeCakeArguments(); var processRunner = new ProcessRunner(environment, log); var registry = new WindowsRegistry(); context = new CakeContext(fileSystem, environment, globber, log, args, processRunner, registry); context.Environment.WorkingDirectory = testsDir; }
private bool SkipDisable(StrongNameConfiguration configuration) { bool printedHeader = false; foreach (RegistrySection section in WindowsRegistry.Sections) { using (RegistryKey registryKey = WindowsRegistry.CreateWritableVerificationRegistryKey(section)) { if (registryKey == null) { Log.LogError($"Unable to open writable verification registry key for {section}."); return(false); } foreach (var assembly in configuration.FilteredAssemblySpecifications[section]) { RegistryKey subKey = registryKey.OpenSubKey(assembly); if (subKey != null) { if (!printedHeader) { printedHeader = true; Log.LogMessage("Deleting registry entries:"); } Log.LogMessage($" {registryKey}\\{assembly}"); subKey.Dispose(); registryKey.DeleteSubKeyTree(assembly); } } } } if (!printedHeader) { Log.LogMessage("Skip Strong Names is already disabled."); } else { Log.LogMessage(""); Log.LogMessage("Skip Strong Names was successfully disabled."); } return(true); }
/// <summary> /// Creates a MimeType for a file extension using the OS registered applications /// for that file type. /// </summary> /// <param name="fileExtension">string (e.g. "pdf" or ".pdf")</param> /// <returns>MimeType</returns> /// <permission cref="RegistryPermission">Read access to HKEY_CLASSES_ROOT\MIME</permission> public static MimeType CreateFromRegisteredApps(string fileExtension) { if (fileExtension == null) { return(Empty); } string dotExt = (fileExtension.IndexOf(".") >= 0 ? fileExtension : "." + fileExtension); string mType = WindowsRegistry.GetMimeTypeString(dotExt); if (mType == null) { return(Empty); } return(new MimeType(mType)); }
public FakeCakeContext () { testsDir = new DirectoryPath ( System.IO.Path.GetFullPath (AppDomain.CurrentDomain.BaseDirectory)); var fileSystem = new FileSystem (); var environment = new CakeEnvironment (new CakePlatform (), new CakeRuntime ()); var globber = new Globber (fileSystem, environment); log = new FakeLog (); var args = new FakeCakeArguments (); var processRunner = new ProcessRunner (environment, log); var registry = new WindowsRegistry (); var toolRepo = new ToolRepository (environment); var config = new Core.Configuration.CakeConfigurationProvider (fileSystem, environment).CreateConfiguration (testsDir, new Dictionary<string, string> ()); var toolResolutionStrategy = new ToolResolutionStrategy (fileSystem, environment, globber, config); var toolLocator = new ToolLocator (environment, toolRepo, toolResolutionStrategy); context = new CakeContext (fileSystem, environment, globber, log, args, processRunner, registry, toolLocator); context.Environment.WorkingDirectory = testsDir; }
public FakeCakeContext () { testsDir = new DirectoryPath ( System.IO.Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly ().Location)); var fileSystem = new FileSystem (); var environment = new CakeEnvironment (); var globber = new Globber (fileSystem, environment); log = new FakeLog (); var args = new FakeCakeArguments (); var processRunner = new ProcessRunner (environment, log); var registry = new WindowsRegistry (); var toolRepo = new ToolRepository (environment); var config = new Core.Configuration.CakeConfigurationProvider (fileSystem, environment).CreateConfiguration (new Dictionary<string, string> ()); var toolResStrat = new ToolResolutionStrategy (fileSystem, environment, globber, config); var toolLocator = new ToolLocator (environment, toolRepo, toolResStrat); context = new CakeContext (fileSystem, environment, globber, log, args, processRunner, registry, toolLocator); context.Environment.WorkingDirectory = testsDir; }
/// <summary> /// Runs the application. /// </summary> /// <param name="args">Arguments.</param> /// <returns>0 on success.</returns> public int Run( string[] args ) { var console = new CakeConsole(); var logger = new SafeCakeLog( console ); var engine = new CakeEngine( logger ); ICakePlatform platform = new CakePlatform(); ICakeRuntime runtime = new CakeRuntime(); IFileSystem fileSystem = new FileSystem(); MutableCakeEnvironment environment = new MutableCakeEnvironment( platform, runtime ); IGlobber globber = new Globber( fileSystem, environment ); environment.Initialize( globber ); IProcessRunner processRunner = new ProcessRunner( environment, logger ); IRegistry windowsRegistry = new WindowsRegistry(); // Parse options. var argumentParser = new ArgumentParser( logger, fileSystem ); CakeOptions options = argumentParser.Parse( args ); Debug.Assert( options != null ); CakeConfigurationProvider configProvider = new CakeConfigurationProvider( fileSystem, environment ); ICakeConfiguration configuration = configProvider.CreateConfiguration( environment.ApplicationRoot, options.Arguments ); IToolRepository toolRepo = new ToolRepository( environment ); IToolResolutionStrategy toolStrategy = new ToolResolutionStrategy( fileSystem, environment, globber, configuration ); IToolLocator locator = new ToolLocator( environment, toolRepo, toolStrategy ); IToolLocator toolLocator = new ToolLocator( environment, toolRepo, toolStrategy ); logger.SetVerbosity( options.Verbosity ); CodeCakeBuildTypeDescriptor choosenBuild; if( !AvailableBuilds.TryGetValue( options.Script, out choosenBuild ) ) { logger.Error( "Build script '{0}' not found.", options.Script ); return -1; } ICakeArguments arguments = new CakeArguments(options.Arguments); var context = new CakeContext( fileSystem, environment, globber, logger, arguments, processRunner, windowsRegistry, locator ); // Copy the arguments from the options. // Set the working directory: the solution directory. environment.WorkingDirectory = new DirectoryPath( _solutionDirectory ); // Adds additional paths from chosen build. foreach( var p in choosenBuild.AdditionnalPatternPaths ) { environment.AddPath( p ); } logger.Information( "Path(s) added: " + string.Join( ", ", environment.EnvironmentAddedPaths ) ); logger.Information( "Dynamic pattern path(s) added: " + string.Join( ", ", environment.EnvironmentDynamicPaths ) ); try { // Instanciates the script object. CodeCakeHost._injectedActualHost = new BuildScriptHost( engine, context ); CodeCakeHost c = (CodeCakeHost)Activator.CreateInstance( choosenBuild.Type ); var strategy = new DefaultExecutionStrategy( logger ); var report = engine.RunTarget( context, strategy, context.Arguments.GetArgument( "target" ) ?? "Default" ); if( report != null && !report.IsEmpty ) { var printerReport = new CakeReportPrinter( console ); printerReport.Write( report ); } } catch( CakeTerminateException ex ) { switch( ex.Option ) { case CakeTerminationOption.Error: logger.Error( "Termination with Error: '{0}'.", ex.Message ); return -1; case CakeTerminationOption.Warning: logger.Warning( "Termination with Warning: '{0}'.", ex.Message ); break; default: Debug.Assert( ex.Option == CakeTerminationOption.Success ); logger.Information( "Termination with Success: '{0}'.", ex.Message ); break; } } catch( TargetInvocationException ex ) { logger.Error( "Error occurred: '{0}'.", ex.InnerException?.Message ?? ex.Message ); return -1; } catch( Exception ex ) { logger.Error( "Error occurred: '{0}'.", ex.Message ); return -1; } return 0; }