예제 #1
0
        public void WriteYamlTest()
        {
            YamlTestObject parent = CreateTestObject();
            YamlConfig     config = new YamlConfig();

            config.OmitTagForRootNode = true;
            string yaml = parent.ToYaml(config);

            OutLine(yaml, ConsoleColor.Cyan);
            FileInfo testFile = GetTestFile();

            using (StreamWriter sw = new StreamWriter(testFile.FullName))
            {
                sw.Write(yaml);
            }
        }
예제 #2
0
        private YamlTestObject CreateTestObject(bool setChild = true, bool setObjArray = true)
        {
            YamlTestObject obj = new YamlTestObject {
                Name = 8.RandomLetters()
            };

            if (setChild)
            {
                obj.Child = CreateTestObject(false);
            }
            if (setObjArray)
            {
                List <YamlTestObject> objList = new List <YamlTestObject>();
                4.Times(i =>
                {
                    objList.Add(CreateTestObject(false, false));
                });
                obj.ObjectArray = objList.ToArray();
            }

            obj.StringArrayProperty = new[] { 9.RandomLetters(), 5.RandomLetters(), 4.RandomLetters() };
            return(obj);
        }