/// <summary> /// Main entry point which is called by QMods. Specified in mod.json /// </summary> public static void Load() { Config = YamlConfigReader.Readconfig <FishOverflowDistributorConfig>( ConfigFilePath, x => { Console.WriteLine( $"[{ModName}] [Fatal] Error parsing config file '{ConfigFilePath}. {Environment.NewLine}"); Console.WriteLine(ExceptionUtils.GetExceptionErrorString(x)); }); if (Config == null) { return; } Logger = new QModLogger() .WithTarget(new QModFileLoggerTarget(LogFilePath, Config.LogLevel)) .WithTarget(new SubnauticaConsoleLoggerTarget(ModName, LogLevel.Error)) .Open(); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; OnGameStart(); }
private static void Main(string[] args) { try { var consoleParameters = new ConsoleParametrsParse(args); IConfigReader configReader = new YamlConfigReader(ConfigurationManager.AppSettings.Get("pathConfigFile")); StructureConfig configParameters = configReader.Parameters; bool tryConsoleParameters = consoleParameters.TryGetParameters(); if (!tryConsoleParameters) { throw new IncorrectParametersException(consoleParameters.ErrorParameters); } configParameters.JoinConfig(consoleParameters.Parameters); var generator = new LogFileGenerator(configParameters); generator.GenerateLogFile(); } catch (GeneratorAppException exception) { IErrorView view = new ConsoleErrorView(exception); view.DisplayMessage(); } }
public ServiceBusMessageQueueTest() { var config = YamlConfigReader.ReadConfig(null, "..\\..\\..\\..\\config\\test_connections.yaml", null); var connection = ConnectionParams.FromString(config.GetAsString("sb_queue")); Queue = new ServiceBusMessageQueue("TestQueue", connection); Queue.OpenAsync(null).Wait(); Fixture = new MessageQueueFixture(Queue); }
public ServiceBusMessageTopicTest() { var config = YamlConfigReader.ReadConfig(null, @"..\\..\\..\\..\\config\\test_connections.yaml", null); var connection = ConnectionParams.FromString(config.GetAsString("sb_topic")); Topic = new ServiceBusMessageTopic("TestTopic", connection); Topic.OpenAsync(null).Wait(); Fixture = new MessageQueueFixture(Topic); }
private void Scan() { var configReader = new YamlConfigReader(configPath); var localPath = configReader.ReadPath() ?? path; var directoryScanner = new DirectoryScanner(localPath); var explorerItems = directoryScanner.Scan(); var imageFileNames = explorerItems.Select(p => p.ImageFileName).ToList(); if (imageFileNamesSnapshot != null && imageFileNames.SequenceEqual(imageFileNamesSnapshot)) { return; } imageFileNamesSnapshot = imageFileNames; Debug.Log("changed"); var objects = transform.GetComponentsInChildren <Transform>().Where(p => p != transform); foreach (var obj in objects) { Object.Destroy(obj.gameObject); } foreach (var explorerItem in explorerItems) { var bytes = File.ReadAllBytes(explorerItem.ImageFileName); var texture = new Texture2D(2, 2); texture.LoadImage(bytes); var rect = new Rect(0F, 0F, texture.width, texture.height); var border = new Vector4(0F, 0F, texture.width, texture.height); var sprite = Sprite.Create(texture, rect, Vector3.zero, 100F, 0, SpriteMeshType.FullRect, border); var panel = new GameObject("Cell").AddComponent <RectTransform>(); panel.SetParent(transform); var image = new GameObject("Picture").AddComponent <Image>(); image.transform.SetParent(panel); image.sprite = sprite; image.preserveAspect = true; var text = new GameObject("Name").AddComponent <Text>(); text.transform.SetParent(panel); text.font = Resources.GetBuiltinResource <Font>("Arial.ttf"); text.fontSize = 22; text.color = Color.black; text.text = explorerItem.Name; text.alignment = TextAnchor.UpperCenter; var textRectTransform = text.GetComponent <RectTransform>(); textRectTransform.anchorMin = new Vector2(0.1F, 0.1F); textRectTransform.anchorMax = new Vector2(0.9F, 0.9F); textRectTransform.anchoredPosition = Vector2.zero; textRectTransform.sizeDelta = Vector2.zero; } }
public StorageMessageQueueTest() { var config = YamlConfigReader.ReadConfig(null, "..\\..\\..\\..\\config\\test_connections.yaml", null); var connection = ConnectionParams.FromString(config.GetAsString("storage_queue")); Queue = new StorageMessageQueue("TestQueue", connection); //Queue.SetReferences(new MockReferences()); Queue.Interval = 50; Queue.OpenAsync(null).Wait(); Fixture = new MessageQueueFixture(Queue); }
public void TestReadConfig() { var parameters = ConfigParams.FromTuples( "param1", "Test Param 1", "param2", "Test Param 2"); ConfigParams config = YamlConfigReader.ReadConfig(null, "../../../../data/config.yml", parameters); Assert.Equal(9, config.Count); Assert.Equal(123, config.GetAsInteger("field1.field11")); Assert.Equal("ABC", config.GetAsString("field1.field12")); Assert.Equal(123, config.GetAsInteger("field2.0")); Assert.Equal("ABC", config.GetAsString("field2.1")); Assert.Equal(543, config.GetAsInteger("field2.2.field21")); Assert.Equal("XYZ", config.GetAsString("field2.2.field22")); Assert.Equal(true, config.GetAsBoolean("field3")); }
public StorageMessageQueueBackwardCompatibilityTest() { var config = YamlConfigReader.ReadConfig(null, "..\\..\\..\\..\\config\\test_connections.yaml", null); var connection = ConnectionParams.FromString(config.GetAsString("storage_queue")); QueueOld = new StorageMessageQueue("TestQueue", connection) { Interval = 50 }; QueueOld.OpenAsync(null).Wait(); var connection2 = ConnectionParams.FromString(config.GetAsString("storage_queue2")); QueueNew = new StorageMessageQueue("TestQueue", connection2) { Interval = 50 }; QueueNew.OpenAsync(null).Wait(); Fixture = new MessageQueueFixtureBackwardCompatibility(QueueOld, QueueNew); }
public static ContainerConfig ReadFromYamlFile(string correlationId, string path) { var config = YamlConfigReader.ReadConfig(correlationId, path); return(ContainerConfig.FromConfig(config)); }
private void OnExecute() { string outPath = OutputFilePath ?? (Path.GetFileNameWithoutExtension(DataFilePath) + "_output" + Path.GetExtension(DataFilePath)); // load configuration file // YamlConfigReader configFile = new YamlConfigReader(".\\resources\\config.yaml"); YamlConfigReader configFile = new YamlConfigReader(MetadataFilePath); DataProtectionConfig protectionConfig = configFile.Read(); bool sourceIsEncrypted = false; bool targetIsEncrypted = true; string outputFileName = ""; switch (Command.ToLower()) { case "encrypt": sourceIsEncrypted = false; targetIsEncrypted = true; outputFileName = DataFilePath.Split('.')[0] + "-encrypted." + DataFilePath.Split('.')[1]; break; case "decrypt": sourceIsEncrypted = true; targetIsEncrypted = false; outputFileName = DataFilePath.Split('.')[0] + "-decrypted." + DataFilePath.Split('.')[1]; break; default: Console.WriteLine("Not a valid command. Try 'encrypt' or 'decrypt' as a command."); break; } // For encryption operations, we're going to remove output settings // open input and output file streams // Stream inputFile = File.OpenRead (".\\resources\\userdata.parquet"); // Stream outputFile = File.OpenWrite (".\\resources\\userdata.parquet"); Stream outputFile = File.OpenWrite(outputFileName); // Create reader // using ParquetFileReader reader = new ParquetFileReader (inputFile); CSVDataReader reader = new CSVDataReader(new StreamReader(DataFilePath), protectionConfig, TokenCredential, sourceIsEncrypted); // Copy source settings as target settings /* * List<FileEncryptionSettings> writerSettings = reader.FileEncryptionSettings * .Select (s => Copy (s)) * .ToList (); */ // Create and pass the target settings to the writer // using ParquetFileWriter writer = new ParquetFileWriter (outputFile, writerSettings); using CSVDataWriter writer = new CSVDataWriter(new StreamWriter(outputFile), protectionConfig, TokenCredential, reader.Header, targetIsEncrypted); // Process the file ColumnarCryptographer cryptographer = new ColumnarCryptographer(reader, writer); try { cryptographer.Transform(); Console.WriteLine($"File processed successfully. Verify output file contains encrypted data."); } catch (Exception e) { Console.WriteLine(e.Message); } }