public void First() { var deserializer = new YamlDotNet.Serialization.Deserializer(); var dict = deserializer.Deserialize <Dictionary <string, string> >("hello: world"); Console.WriteLine(dict["hello"]); }
public static BuildConfig Load(string env) { var configFilePath = Path.Combine(ConfigDir, env + ".yaml"); Debug.Log("Load build config file: " + configFilePath); if (!File.Exists(configFilePath)) { throw new System.ArgumentException("対応する設定ファイルが見つかりませんでした。 path: " + configFilePath); } var yaml = System.IO.File.ReadAllText(configFilePath); var reader = new System.IO.StringReader(yaml); var deserializer = new YamlDotNet.Serialization.Deserializer( ignoreUnmatched: false, namingConvention: new YamlDotNet.Serialization.NamingConventions.UnderscoredNamingConvention() ); var config = deserializer.Deserialize <BuildConfig>(reader); config.Env = env; return(config); }
public static string UpdateCodeLocationInYamlTemplate(string templateBody, string s3Bucket, string s3Key) { var s3Url = $"s3://{s3Bucket}/{s3Key}"; var deserialize = new YamlDotNet.Serialization.Deserializer(); var root = deserialize.Deserialize(new StringReader(templateBody)) as Dictionary <object, object>; if (root == null) { return(templateBody); } if (!root.ContainsKey("Resources")) { return(templateBody); } var resources = root["Resources"] as IDictionary <object, object>; foreach (var kvp in resources) { var resource = kvp.Value as IDictionary <object, object>; if (resource == null) { continue; } if (!resource.ContainsKey("Properties")) { continue; } var properties = resource["Properties"] as IDictionary <object, object>; if (!resource.ContainsKey("Type")) { continue; } var type = resource["Type"]?.ToString(); if (string.Equals(type, "AWS::Serverless::Function", StringComparison.Ordinal)) { properties["CodeUri"] = s3Url; } if (string.Equals(type, "AWS::Lambda::Function", StringComparison.Ordinal)) { var code = new Dictionary <object, object>(); code["S3Bucket"] = s3Bucket; code["S3Key"] = s3Key; properties["Code"] = code; } } var serializer = new Serializer(); var updatedTemplateBody = serializer.Serialize(root); return(updatedTemplateBody); }
public void StartServer(int port, string prefix) { Console.WriteLine("Starting the Spider Http Server"); string config = File.ReadAllText(Directory.GetCurrentDirectory() + @"\sconfig.yml"); var deserializer = new YamlDotNet.Serialization.Deserializer(); var dict = deserializer.Deserialize <Dictionary <string, string> >(config); if (!File.Exists(dict["startPage"])) { Console.WriteLine("startPage does not exist! Please look at your sconfig."); StopServer("Invalid startPage in sconfig"); } else { pageContents = File.ReadAllText(dict["startPage"]); } htplst.Prefixes.Add(prefix); htplst.Start(); Console.WriteLine("Server started. Listening..."); serverRunning = true; while (serverRunning) { var t = Task.Factory.StartNew(() => Listen()); if (t.IsCompleted) { t.Start(); } System.AppDomain.CurrentDomain.ProcessExit += (s, e) => { StopServer("User Exited"); }; } }
static void Main(string[] args) { Console.WriteLine("Starting Spider v0.1"); Console.WriteLine("Written by Mason Meirs on a shitty 2020 summer evening whilst on the phone with Kallie"); if (!File.Exists("sconfig.yml")) { var serializer = new YamlDotNet.Serialization.Serializer(); using (TextWriter wrt = File.CreateText("sconfig.yml")) { serializer.Serialize(wrt, new { port = "80", startPage = "index.html", prefix = "http://localhost/" }); } } else { string config = File.ReadAllText(Directory.GetCurrentDirectory() + @"\sconfig.yml"); var deserializer = new YamlDotNet.Serialization.Deserializer(); var dict = deserializer.Deserialize <Dictionary <string, string> >(config); port = int.Parse(dict["port"]); prefix = dict["prefix"]; } Console.WriteLine("Init sequence complete..."); Spider spd = new Spider(); spd.StartServer(port, prefix); }
//設定の読み込み public static PixelSeqParam Create(string yaml) { using (var sr = new StreamReader(yaml)) { var deserializer = new YamlDotNet.Serialization.Deserializer(); return(deserializer.Deserialize <PixelSeqParam>(sr)); } }
public static ScreenCaptureConfig ReadConfig(string path) { var deserializer = new YamlDotNet.Serialization.Deserializer(namingConvention: new CamelCaseNamingConvention()); using (var io = System.IO.File.OpenText(path)) { var config = deserializer.Deserialize <ScreenCaptureConfig>(io); return(config); } }
public override void Reload() { if (TextDefinitionAsset) { var deserializer = new YamlDotNet.Serialization.Deserializer(); TextDefinitions = deserializer.Deserialize <Dictionary <string, string> >(TextDefinitionAsset.text); } KeyboardKeyText = new Dictionary <string, string>(); GamepadKeyText = new Dictionary <string, string>(); input?.Disable(); input = new MAJIKAInput(); var regGamePad = new Regex(@"<Gamepad>/(\S+)", RegexOptions.IgnoreCase | RegexOptions.ECMAScript); var regKeyboard = new Regex(@"<Keyboard>/(\S+)", RegexOptions.IgnoreCase | RegexOptions.ECMAScript); input.ForEach(action => { var actionName = action.name.ToLower(); InputActions.Add(actionName); action.bindings.Where(binding => !binding.isComposite) .ForEach(binding => { Debug.Log(binding.path); // Gamepad var match = regGamePad.Match(binding.path); if (match.Success) { if (!GamepadKeyText.ContainsKey(actionName)) { GamepadKeyText[actionName] = TextDefinitions[binding.path]; TouchScreenText[actionName] = TextDefinitions[$"<Touch>/{match.Groups[1]}"]; } else { GamepadKeyText[actionName] = Utility.StringJoin(",", GamepadKeyText[actionName], TextDefinitions[binding.path]); TouchScreenText[actionName] = Utility.StringJoin(",", KeyboardKeyText[actionName], TextDefinitions[$"<Touch>/{match.Groups[1]}"]); } } // Keyboard match = regKeyboard.Match(binding.path); if (match.Success) { if (!KeyboardKeyText.ContainsKey(actionName)) { KeyboardKeyText[actionName] = TextDefinitions[binding.path]; } else { KeyboardKeyText[actionName] = Utility.StringJoin(",", KeyboardKeyText[actionName], TextDefinitions[binding.path]); } } }); }); }
static void Main(string[] args) { const string basePath = @"D:\Program Files (x86)\Steam\steamapps\common\DARK SOULS III\Game"; const string actionSetupPath = "Res/TaeToWeaponKind.yml"; TAEAnalyzerData analyzerData = new YamlDotNet.Serialization.Deserializer().Deserialize <TAEAnalyzerData>(new System.IO.StreamReader(actionSetupPath)); var reader = new BND4Reader(System.IO.Path.Combine(basePath, "chr/c0000.anibnd.dcx")); const int jumpTableEventType = 0; const int attackEventType = 1; int[] comboBehSubIds = new[] { 4, 116 }; var taeTemplate = TAE.Template.ReadXMLFile(@"Res/TAE.Template.DS3.xml"); var jumpTableEventTemplate = taeTemplate[21][jumpTableEventType]; var attackEventTemplate = taeTemplate[21][attackEventType]; var analyzedWeapons = analyzerData.weapons.Select(weaponKvp => (kvp: weaponKvp, taeFileHeader: reader.Files // get all TAE headers .Where(header => header.Name.EndsWith("tae")) .Single(header => System.IO.Path.GetFileName(header.Name) == $"a{weaponKvp.Key}.tae"))) .Select(weaponData => (weaponData: weaponData, fileContents: reader.ReadFile(weaponData.taeFileHeader))) .Where(weaponData => TAE.Is(weaponData.fileContents)) .Select((weaponData) => (kvp: weaponData.weaponData.kvp, weaponTae: TAE.Read(weaponData.fileContents))) .SelectMany(myTuple => analyzerData.animKind.Select(animKindKvp => (weaponKindKvp: myTuple.kvp, animKindKvp: animKindKvp, weaponTae: myTuple.weaponTae))) .SelectMany(myTuple => { var attackTimings = myTuple.weaponTae.Animations.Select(anim => { bool didFind = myTuple.animKindKvp.Value.TryGetDetails(myTuple.animKindKvp.Key, anim, out string details); return(found: didFind, myTuple: myTuple, anim, details); }) .Where(d => d.found) .Select(anim => (anim, events: anim.anim.Events.Where(taeEvent => taeEvent.Type == attackEventType || taeEvent.Type == jumpTableEventType))) .Where(events => events.events.Any()) .Select(anim => anim.events.Aggregate(new AttackInfo(), (attackInfo, taeEvent) => { attackInfo.anim = anim.anim.anim; attackInfo.details = anim.anim.details; if (taeEvent.Type == attackEventType) { taeEvent.ApplyTemplate(false, attackEventTemplate); if (taeEvent.Parameters["Unk04"].Equals(0)) { attackInfo.Attacks.Add((attackStart: taeEvent.StartTime, attackEnd: taeEvent.EndTime)); } }
static void check_modified(string output_root) { var path = getconfpath(); if (File.Exists(path) == false) { try { Directory.Delete(output_root, true); }catch (System.Exception) { } return; } int prefix = output_root.Length; int c = output_root[output_root.Length - 1]; if (c != '\\' && c != '/') { prefix += 1; } var str = File.ReadAllText(getconfpath()); var reader = new YamlDotNet.Serialization.Deserializer(); var abm = reader.Deserialize <AssetBundleInfo>(str); var bundle_list = Directory.GetFiles(output_root, "*"); foreach (var bundle_path in bundle_list) { if (bundle_path.EndsWith(".manifest")) { continue; } string[] assets_depend = null; var bundle_name = bundle_path.Substring(prefix); var bundle_time = File.GetLastWriteTime(bundle_path); if (!abm.AssetBundles.TryGetValue(bundle_name, out assets_depend)) { Debug.Log("ABT check_modified asset bundle:" + bundle_name + " useless"); File.Delete(bundle_path); File.Delete(bundle_path + ".manifest"); } else { foreach (var asset_name in assets_depend) { var asset_time = File.GetLastWriteTime(Path.Combine(PROJECT_PATH, asset_name)); if (asset_time > bundle_time) { Debug.Log("ABT check_modified asset bundle:" + bundle_name + " is invalid"); File.Delete(bundle_path); File.Delete(bundle_path + ".manifest"); break; } } } } }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); deployTool.WebApi.logger.Debug("Start"); var deserializer = new YamlDotNet.Serialization.Deserializer(); var mappedPath = System.Web.Hosting.HostingEnvironment.MapPath("~/config.yaml"); string config = System.IO.File.ReadAllText(mappedPath); configuration = deserializer.Deserialize <List <Models.ConfigurationItem> >(config); }
static void import() { var str = File.ReadAllText(getconfpath()); var reader = new YamlDotNet.Serialization.Deserializer(); var abm = reader.Deserialize <AssetBundleInfo>(str); foreach (var s in abm.AssetBundles) { foreach (var g in s.Value) { set_bundle_name(g, s.Key); } } AssetDatabase.RemoveUnusedAssetBundleNames(); AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); }
static void Main() { System.Console.WriteLine("生成元のCSVファイルを入力してください。"); var filePath = System.Console.ReadLine(); var outputPath = "./out/result.sql"; var settingFilePath = "./settings.yaml"; //設定ファイル読み込み var stream = new StreamReader(settingFilePath); var desirializer = new YamlDotNet.Serialization.Deserializer(); var yamlData = desirializer.Deserialize <YamlSetting>(stream); //変換処理を実行 var converter = new Converter(yamlData); converter.execute(filePath, outputPath); }
private static Dictionary <string, string?> UpdateLocatorList(Dictionary <string, string?> newDictionary) { var dictionary = new Dictionary <string, string?>(); if (File.Exists(locatorFile)) { using var reader = new StreamReader(locatorFile); dictionary = new YamlDotNet.Serialization.Deserializer().Deserialize <Dictionary <string, string?> >(reader) ?? new Dictionary <string, string?>(); } foreach (var pair in newDictionary) { if (!dictionary.ContainsKey(pair.Key)) { dictionary[pair.Key] = pair.Value; } } using var writer = new StreamWriter(locatorFile); new YamlDotNet.Serialization.Serializer().Serialize(writer, dictionary); return(dictionary); }
/** * Deserializer constructor. */ public Deserializer() { this.deserializer = new DeserializerBuilder() .WithNamingConvention(new CamelCaseNamingConvention()) .Build(); }
public void ACI_Queue_DacpacSource_ForceApplyCustom_eyVault_Secrets_Success(string settingsFile, string imageTag, int containerCount, int concurrency, ConcurrencyType concurrencyType) { settingsFile = Path.GetFullPath(settingsFile); var overrideFile = Path.GetFullPath("TestConfig/databasetargets.cfg"); int removeCount = 1; string server, database; var overrideFileContents = File.ReadAllLines(overrideFile).ToList(); string firstOverride = overrideFileContents.First(); (server, database) = DatabaseHelper.ExtractServerAndDbFromLine(firstOverride); string server2, database2; string thirdOverride = overrideFileContents.ElementAt(2); (server2, database2) = DatabaseHelper.ExtractServerAndDbFromLine(thirdOverride); string minusFirst = Path.GetFullPath("TestConfig/minusFirst.cfg"); File.WriteAllLines(minusFirst, DatabaseHelper.ModifyTargetList(overrideFileContents, removeCount)); //Get the creds locally from the K8s file var secretsFile = Path.GetFullPath("TestConfig/secrets.yaml"); var ymlD = new ydn.Deserializer(); var obj = ymlD.Deserialize <dynamic>(File.ReadAllText(secretsFile)); var pw = Encoding.UTF8.GetString(Convert.FromBase64String(obj["data"]["Password"])); var un = Encoding.UTF8.GetString(Convert.FromBase64String(obj["data"]["UserName"])); var cmdLine = new CommandLineArgs() { UserName = un, Password = pw }; DatabaseHelper.CreateRandomTable(cmdLine, new List <string>() { firstOverride, thirdOverride }); string dacpacName = DatabaseHelper.CreateDacpac(cmdLine, server, database); //get the size of the log file before we start int startingLine = TestHelper.LogFileCurrentLineCount(); RootCommand rootCommand = CommandLineBuilder.SetUp(); string jobName = TestHelper.GetUniqueJobName("aci"); string outputFile = Path.Combine(Directory.GetCurrentDirectory(), jobName + ".json"); //Prep the build var args = new string[] { "aci", "prep", "--settingsfile", settingsFile, "--tag", imageTag, "--jobname", jobName, "--platinumdacpac", dacpacName, "--outputfile", outputFile, "--containercount", containerCount.ToString(), "--concurrencytype", concurrencyType.ToString(), "--concurrency", concurrency.ToString(), "--override", minusFirst }; var val = rootCommand.InvokeAsync(args); val.Wait(); int result = val.Result; Assert.AreEqual(0, result); //Create another table in the first that will be applied when the custom DACPAC is created DatabaseHelper.CreateRandomTable(cmdLine, firstOverride); //enqueue the topic messages args = new string[] { "aci", "enqueue", "--settingsfile", settingsFile, "--jobname", jobName, "--concurrencytype", concurrencyType.ToString(), "--override", minusFirst }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); //monitor for completion args = new string[] { "aci", "deploy", "--settingsfile", settingsFile, "--templatefile", outputFile, "--override", minusFirst, "--unittest", "true", "--monitor", "true", "--stream", "true" }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); var logFileContents = TestHelper.ReleventLogFileContents(startingLine); Assert.IsTrue(logFileContents.Contains("Committed - With Custom Dacpac"), "A custom DACPAC should have been required for a database"); }
public static (KlineArrayInfo info, Stream stream) DeserializeStream(string path) { var yamlBuilder = new StringBuilder(); Stream stream; stream = File.OpenRead(path); var buffer = new List <byte>(); bool hasCarriageReturn = false; bool done = false; int i = 0; var p = UTF8Encoding.UTF8.Preamble; var pn = 0; for (; !done; i++) { int b = stream.ReadByte(); if (i < p.Length && pn >= 0) { if (p[i] == b) { pn++; if (pn == p.Length) { buffer.Clear(); continue; } } } if (b == -1) { throw new IOException("End of file reached in header."); } if (b == 13) { hasCarriageReturn = true; } else if (b == 10 && hasCarriageReturn) { string line = Encoding.UTF8.GetString(buffer.ToArray(), 0, buffer.Count); buffer.Clear(); hasCarriageReturn = false; if (line.StartsWith("...")) { stream.Seek(i + 1, SeekOrigin.Begin); break; } else { yamlBuilder.AppendLine(line); } } else { if (hasCarriageReturn) { buffer.Add(13); } hasCarriageReturn = false; buffer.Add((byte)b); } } //s1 = yamlBuilder.ToString(); //Console.WriteLine(yamlBuilder.ToString().Length); //yamlBuilder.Clear(); //if(false) //{ // var sr = new StreamReader(path); // string? line; // for (line = sr.ReadLine(); line != "..."; line = sr.ReadLine()) // { // yamlBuilder.AppendLine(line); // } // //stream = sr.BaseStream; // //Console.WriteLine(yamlBuilder.ToString().Length); //} //int x(char x) => x; //if (false) //{ // s2 = yamlBuilder.ToString(); // for (int i = 0; i < s1.Length || i < s2.Length; i++) // { // if (i >= s1.Length) { Console.WriteLine("s1 Missing: " + x(s2[i])); continue; } // if (i >= s2.Length) { Console.WriteLine("s2 Missing: " + x(s1[i])); continue; } // if (s1[i] != s2[i]) { Console.WriteLine($"{i}: {x(s1[i])} != {x(s2[i])}"); } // } //} var deserializer = new YamlDotNet.Serialization.Deserializer(); var info = deserializer.Deserialize <KlineArrayInfo>(yamlBuilder.ToString()); //Console.WriteLine("Data index: " + i); return(info, stream); }
/// <summary> /// Creates a new <see cref="Deserializer" /> according to the current configuration. /// </summary> public Deserializer Build() { return(Deserializer.FromValueDeserializer(BuildValueDeserializer())); }
public void Kubernetes_Queue_DacpacSource_ForceApplyCustom_KeyVault_Secrets_Success(string runtimeFile, string secretsFile, string secretsProviderFile, string podIdentityFile, string deployFile) { var prc = new ProcessHelper(); secretsProviderFile = Path.GetFullPath(secretsProviderFile); podIdentityFile = Path.GetFullPath(podIdentityFile); runtimeFile = Path.GetFullPath(runtimeFile); deployFile = Path.GetFullPath(deployFile); secretsFile = Path.GetFullPath(secretsFile); var overrideFile = Path.GetFullPath("TestConfig/databasetargets.cfg"); int removeCount = 1; string server, database; var overrideFileContents = File.ReadAllLines(overrideFile).ToList(); string firstOverride = overrideFileContents.First(); (server, database) = DatabaseHelper.ExtractServerAndDbFromLine(firstOverride); string server2, database2; string thirdOverride = overrideFileContents.ElementAt(2); (server2, database2) = DatabaseHelper.ExtractServerAndDbFromLine(thirdOverride); string minusFirst = Path.GetFullPath("TestConfig/minusFirst.cfg"); File.WriteAllLines(minusFirst, DatabaseHelper.ModifyTargetList(overrideFileContents, removeCount)); var ymlD = new ydn.Deserializer(); var obj = ymlD.Deserialize <dynamic>(File.ReadAllText(secretsFile)); var pw = Encoding.UTF8.GetString(Convert.FromBase64String(obj["data"]["Password"])); var un = Encoding.UTF8.GetString(Convert.FromBase64String(obj["data"]["UserName"])); var cmdLine = new CommandLineArgs() { UserName = un, Password = pw }; DatabaseHelper.CreateRandomTable(cmdLine, new List <string>() { firstOverride, thirdOverride }); string dacpacName = DatabaseHelper.CreateDacpac(cmdLine, server, database); //get the size of the log file before we start int startingLine = TestHelper.LogFileCurrentLineCount(); RootCommand rootCommand = CommandLineBuilder.SetUp(); //Clear any exiting pods var result = prc.ExecuteProcess("kubectl", $"delete job sqlbuildmanager "); //Prep the build var args = new string[] { "k8s", "prep", "--secretsfile", secretsFile, "--runtimefile", runtimeFile, "--jobname", TestHelper.GetUniqueJobName("k8s-kv"), "--platinumdacpac", dacpacName, "--override", minusFirst }; var val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); //Create another table in the first that will be applied when the custom DACPAC is created DatabaseHelper.CreateRandomTable(cmdLine, firstOverride); //enqueue the topic messages args = new string[] { "k8s", "enqueue", "--secretsfile", secretsFile, "--runtimefile", runtimeFile, "--override", minusFirst }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); result = prc.ExecuteProcess("kubectl", $"apply -f {secretsProviderFile}"); Assert.AreEqual(0, result, "Failed to apply secrets provider file"); result = prc.ExecuteProcess("kubectl", $"apply -f {podIdentityFile}"); Assert.AreEqual(0, result, "Failed to apply pod identity file"); result = prc.ExecuteProcess("kubectl", $"apply -f {runtimeFile}"); Assert.AreEqual(0, result, "Failed to apply runtime file"); result = prc.ExecuteProcess("kubectl", $"apply -f {deployFile}"); Assert.AreEqual(0, result, "Failed to apply deploy file"); result = prc.ExecuteProcess("kubectl", $"get pods"); Assert.AreEqual(0, result); //monitor for completion args = new string[] { "k8s", "monitor", "--secretsfile", secretsFile, "--runtimefile", runtimeFile, "--override", minusFirst, "--unittest", "true", "--stream", "true" }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); var logFileContents = TestHelper.ReleventLogFileContents(startingLine); Assert.IsTrue(logFileContents.Contains("Committed - With Custom Dacpac"), "A custom DACPAC should have been required for a database"); }