public void Constructor_FieldsShouldSetCorrectly() { //arrange IDictionary <string, string> primitiveTypeDictionary = new Dictionary <string, string>(); //act YAMLParser testClass = new YAMLParser(primitiveTypeDictionary); //assert testClass._primitiveTypeDictionary.Should().NotBeNull(); }
public static int Main(string[] args) { string currentDirectory = Directory.GetCurrentDirectory(); Console.WriteLine(currentDirectory); int result = Parser.Default.ParseArguments <Options>(args).MapResult( o => { YAMLParser yamlParser = new YAMLParser(); string destinationPath = o.DestinationPath == null ? null : currentDirectory + Path.DirectorySeparatorChar + o.DestinationPath; string outputPath = o.OutputPath ?? o.Local; bool createBackup = o.CreateBackup; bool success = yamlParser.Parse(o.Base, o.Local, o.Remote, outputPath, destinationPath, createBackup); if (success) { Console.WriteLine("Merge successful."); } else { Console.WriteLine("Merged with errors."); } return(success ? 0 : 1); }, errors => { foreach (Error error in errors) { Console.WriteLine(error.ToString()); } return(-1); } ); return(result); }
/// <summary> /// 处理器 /// </summary> /// <param name="data"></param> /// <returns></returns> public static string Convertor(object data) { while (true) { resetEvent.WaitOne(); string datastr = data as string; YAMLParser yaml = new YAMLParser(); #region 方法一 object yamlObject = yaml.ParseYamlString(datastr); string jsonStr1 = yaml.ToJson(datastr); #endregion #region 方法二 JSONParser json = new JSONParser(); string jsonStr2 = json.ParseJsonObject(yamlObject); #endregion resetEvent.Reset(); return(jsonStr1); } }