/// <summary> /// Installs syntax highlighter for Sublime Text 3 /// </summary> public void ConfigureSublime() { Debug.Log("called"); var sublimeDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Sublime Text 3"); if (Directory.Exists(sublimeDir)) { Debug.Log("Found directory"); var packagesDir = Path.Combine(sublimeDir, "Packages"); if (!Directory.Exists(packagesDir)) { Directory.CreateDirectory(packagesDir); } var userPackagesDir = Path.Combine(packagesDir, "User"); if (!Directory.Exists(userPackagesDir)) { Directory.CreateDirectory(userPackagesDir); } var toolsDir = ConfigurationFiles.ConfigurationDirectory("Tools"); if (!Directory.Exists(toolsDir)) { Debug.Log("No directory!"); } File.Copy( Path.Combine(toolsDir, SyntaxFile), Path.Combine(userPackagesDir, SyntaxFile), true); } }
public ImageMagickConfiguration() { ConfigurationFiles configFiles = ConfigurationFiles.Default; configFiles.Policy.Data = @" <policymap> <policy domain=""resource"" name=""temporary-path"" value=""/tmp""/> <policy domain=""resource"" name=""memory"" value=""2GiB""/> <policy domain=""resource"" name=""map"" value=""4GiB""/> <policy domain=""resource"" name=""area"" value=""1GB""/> <policy domain=""resource"" name=""disk"" value=""16EB""/> <policy domain=""resource"" name=""file"" value=""768""/> <policy domain=""resource"" name=""thread"" value=""4""/> <policy domain=""resource"" name=""throttle"" value=""0""/> <policy domain=""resource"" name=""time"" value=""unlimited""/> <policy domain=""system"" name=""precision"" value=""6""/> <policy domain=""cache"" name=""shared-secret"" value=""passphrase""/> <policy domain=""coder"" rights=""none"" pattern=""EPHEMERAL"" /> <policy domain=""coder"" rights=""none"" pattern=""URL"" /> <policy domain=""coder"" rights=""none"" pattern=""HTTPS"" /> <policy domain=""coder"" rights=""none"" pattern=""MVG"" /> <policy domain=""coder"" rights=""none"" pattern=""MSL"" /> <policy domain=""coder"" rights=""none"" pattern=""TEXT"" /> <policy domain=""coder"" rights=""none"" pattern=""SHOW"" /> <policy domain=""coder"" rights=""none"" pattern=""WIN"" /> <policy domain=""coder"" rights=""none"" pattern=""PLT"" /> <policy domain=""path"" rights=""none"" pattern=""@*"" /> </policymap> "; MagickNET.Initialize(configFiles, TemporaryImagesFilePath); }
/// <summary> /// Initializes ImageMagick with the specified configuration files in the specified the path. /// </summary> /// <param name="configFiles">The configuration files ot initialize ImageMagick with.</param> /// <param name="path">The directory to save the configuration files in.</param> public static void Initialize(ConfigurationFiles configFiles, string path) { Throw.IfNull(nameof(configFiles), configFiles); string newPath = FileHelper.GetFullPath(path); InitializePrivate(configFiles, newPath); }
public ImageMagickConfiguration(string policyMap, string temporaryImagesFilePath) { ConfigurationFiles configFiles = ConfigurationFiles.Default; configFiles.Policy.Data = policyMap; TemporaryImagesFilePath = temporaryImagesFilePath; MagickNET.Initialize(configFiles, TemporaryImagesFilePath); }
public static void InitializeWithCustomPolicy(TestContext context) { #if !NETCORE MagickNET.SetGhostscriptDirectory(@"C:\Program Files (x86)\gs\gs9.26\bin"); #endif ConfigurationFiles configFiles = ConfigurationFiles.Default; configFiles.Policy.Data = ModifyPolicy(configFiles.Policy.Data); _path = MagickNET.Initialize(configFiles); }
/// <summary> /// Initializes ImageMagick with the specified configuration files and returns the path to the /// temporary directory where the xml files were saved. /// </summary> /// <param name="configFiles">The configuration files ot initialize ImageMagick with.</param> /// <returns>The path of the folder that was created and contains the configuration files.</returns> public static string Initialize(ConfigurationFiles configFiles) { Throw.IfNull(nameof(configFiles), configFiles); string path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(path); InitializePrivate(configFiles, path); return(path); }
static Inflection() { Inflections = InflectionProcess.FromFile(ConfigurationFiles.PathTo("Inflections", "Regular nouns")); foreach (var entry in File.ReadAllLines(ConfigurationFiles.PathTo("Inflections", "Irregular nouns"))) { var split = entry.Split('\t'); var singular = split[0]; var plural = split[1]; IrregularPlurals[singular] = plural; IrregularSingulars[plural] = singular; } }
public static IServiceCollection AddImageTools(this IServiceCollection serviceCollection) { if (serviceCollection.Any(x => x.ServiceType == typeof(ImageTool))) { return(serviceCollection); } ConfigurationFiles configFiles = ConfigurationFiles.Default; string temporaryDirectory = MagickNET.Initialize(configFiles); serviceCollection.AddSingleton <ImageTool>(); return(serviceCollection); }
public void Initialize_WithCustomPolicy_PolicyIsWrittenToDisk() { string policy = @"<test/>"; string path = null; try { ConfigurationFiles configFiles = ConfigurationFiles.Default; configFiles.Policy.Data = policy; path = MagickNET.Initialize(configFiles); Assert.AreEqual(policy, File.ReadAllText(Path.Combine(path, "policy.xml"))); } finally { Cleanup.DeleteDirectory(path); } }
private static void InitializePrivate(ConfigurationFiles configFiles, string newPath) { configFiles.WriteInDirectory(newPath); Environment.SetEnv("MAGICK_CONFIGURE_PATH", newPath); }
// ReSharper disable once IdentifierTypo public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) { ConfigurationFiles.UnityPath = Application.dataPath; var buildDirectory = Path.GetDirectoryName(pathToBuiltProject); if (buildDirectory == null) { throw new FileNotFoundException("Invalid build directory", pathToBuiltProject); } string dataDirectory; switch (target) { case BuildTarget.StandaloneWindows: case BuildTarget.StandaloneWindows64: case BuildTarget.StandaloneLinux64: dataDirectory = Path.ChangeExtension(pathToBuiltProject, null) + "_data"; break; case BuildTarget.StandaloneOSX: dataDirectory = pathToBuiltProject + "/Contents"; break; default: throw new ArgumentException("Don't know how to build Prolog code for target: " + target); } void CopyDirectory(string directoryName) { CopyTree( ConfigurationFiles.ConfigurationDirectory(directoryName), Path.Combine(dataDirectory, directoryName) ); } // Recursively copy subtree from to subtree to. void CopyTree(string from, string to) { //if (Directory.Exists(to)) // Directory.Delete(to, true); Directory.CreateDirectory(to); foreach (var d in Directory.GetDirectories(from)) { var name = Path.GetFileName(d); CopyTree( Path.Combine(from, name), Path.Combine(to, name) ); } foreach (var f in Directory.GetFiles(from)) { // Ignore internal files of emacs and Unity if (f.EndsWith("~") || f.EndsWith(".meta")) { continue; } var name = Path.GetFileName(f); if (name.StartsWith("#")) { break; // emacs temp file } File.Copy( Path.Combine(from, name), Path.Combine(to, name) ); } } foreach (var d in DataDirectories) { CopyDirectory(d); } }
public Task RunAsync(bool Interactive = false) { var cmdParser = new CommandLineParser(); IsInteractiveMode = Interactive; if (Manager != null) { cmdParser.Header = Manager.Description; if (!string.IsNullOrEmpty(Manager.ExampleOfUsage)) { cmdParser.Footer = "\nExample of usage:\n\n" + Manager.ExampleOfUsage; } } cmdParser.AfterPrintHelp = () => IsHelpPrint = true; if (IsHelpPrint) { IsInteractiveMode = true; var h = new HostBuilder() .ConfigureServices((hostContext, services) => { services.Configure <ConsoleLifetimeOptions>(opt => opt.SuppressStatusMessages = true); services.AddHostedService <Application <T> >(); }) .Build(); return(h.RunAsync()); } ; var host = new HostBuilder() .ConfigureAppConfiguration((hostContext, configApp) => { /* Supposed that Config directory placed in the same forlder where is EXE * or will be searched closest Config directory in levels upper of EXE till root * of disk. Ex: * C:\MyProject\bin\MyApplication\Application.exe * Will be searched first presented folder in: * - C:\MyProject\bin\MyApplication\Config * - C:\MyProject\bin\Config * - C:\MyProject\Config * - C:\Config */ var cfgDir = StartDirectory; if (cfgDir == null) { #pragma warning disable CA1303 // Do not pass literals as localized parameters throw new Exception("Can't get entry assembly name!"); #pragma warning restore CA1303 // Do not pass literals as localized parameters } while (!Directory.Exists(Path.Combine(cfgDir, "Config")) && Path.GetPathRoot(cfgDir) != cfgDir) { cfgDir = Path.GetFullPath(Path.Combine(cfgDir, "..")); } cfgDir = Path.Combine(cfgDir, "Config"); if (Directory.Exists(cfgDir)) { cfgDir = Path.GetFullPath(cfgDir); cfgDir = cfgDir.TrimEnd('/', '\\'); var commonCfgFileName = Path.Combine(cfgDir, "Common.json"); var serviceCfgFileName = Path.Combine(cfgDir, ServiceName + ".json"); if (File.Exists(commonCfgFileName)) { configApp.AddJsonFile(Path.Combine(cfgDir, commonCfgFileName)); ConfigurationFiles.Add(commonCfgFileName); } if (File.Exists(serviceCfgFileName)) { configApp.AddJsonFile(Path.Combine(cfgDir, serviceCfgFileName)); ConfigurationFiles.Add(serviceCfgFileName); } } }) .ConfigureServices((hostContext, services) => { if (Manager != null && Logger != null) { Manager.SetLogger(Logger); } services.Configure <ConsoleLifetimeOptions>(opt => opt.SuppressStatusMessages = true); services.AddHostedService <Application <T> >(); }) .Build(); return(host.RunAsync()); }